CC-3463 : timeline usability
moving multiple files within the timeline.
This commit is contained in:
parent
ff2907823b
commit
e76cffd8b0
5 changed files with 147 additions and 64 deletions
|
@ -285,62 +285,84 @@ class Application_Model_Scheduler {
|
|||
public function moveItem($selectedItems, $afterItems, $adjustSched = true) {
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$origSelTs = intval($selectedItems[0]["timestamp"]);
|
||||
$origAfterTs = intval($afterItems[0]["timestamp"]);
|
||||
|
||||
Logging::log("Moving item {$selectedItems[0]["id"]}");
|
||||
Logging::log("After {$afterItems[0]["id"]}");
|
||||
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItems[0]["id"], $this->con);
|
||||
if (is_null($selected)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
|
||||
//checks on whether the item to move after is ok.
|
||||
Logging::log("Moving after item: {$afterItems[0]["id"]}");
|
||||
$origAfterTs = intval($afterItems[0]["timestamp"]);
|
||||
|
||||
if (intval($afterItems[0]["id"]) === 0) {
|
||||
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
|
||||
}
|
||||
else {
|
||||
$after = CcScheduleQuery::create()->findPk($afterItems[0]["id"], $this->con);
|
||||
if (is_null($after)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
$afterInstance = $after->getCcShowInstances($this->con);
|
||||
}
|
||||
|
||||
$currTs = intval($afterInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origAfterTs !== $currTs) {
|
||||
$show = $afterInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
$selectedInstance = $selected->getCcShowInstances($this->con);
|
||||
|
||||
if (intval($afterItems[0]["id"]) === 0) {
|
||||
|
||||
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
|
||||
}
|
||||
else {
|
||||
$after = CcScheduleQuery::create()->findPk($afterItems[0]["id"], $this->con);
|
||||
if (is_null($after)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
|
||||
//map show instances to cc_schedule primary keys.
|
||||
$modifiedMap = array();
|
||||
$movedData = array();
|
||||
|
||||
//prepare each of the selected items.
|
||||
for ($i = 0; $i < count($selectedItems); $i++) {
|
||||
|
||||
Logging::log("Moving item {$selectedItems[$i]["id"]}");
|
||||
|
||||
$origSelTs = intval($selectedItems[$i]["timestamp"]);
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItems[$i]["id"], $this->con);
|
||||
if (is_null($selected)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
$selectedInstance = $selected->getCcShowInstances($this->con);
|
||||
|
||||
if (is_null($selectedInstance) || is_null($afterInstance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$currTs = intval($selectedInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origSelTs !== $currTs) {
|
||||
$show = $selectedInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
$afterInstance = $after->getCcShowInstances($this->con);
|
||||
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $selected->getDbFileId();
|
||||
$data["cliplength"] = $selected->getDbClipLength();
|
||||
$data["cuein"] = $selected->getDbCueIn();
|
||||
$data["cueout"] = $selected->getDbCueOut();
|
||||
$data["fadein"] = $selected->getDbFadeIn();
|
||||
$data["fadeout"] = $selected->getDbFadeOut();
|
||||
$data["sched_id"] = $selected->getDbId();
|
||||
|
||||
$movedData[] = $data;
|
||||
|
||||
//figure out which items must be removed from calculated show times.
|
||||
$showInstanceId = $selectedInstance->getDbId();
|
||||
$schedId = $selected->getDbId();
|
||||
if (isset($modifiedMap[$showInstanceId])) {
|
||||
array_push($modifiedMap[$showInstanceId], $schedId);
|
||||
}
|
||||
else {
|
||||
$modifiedMap[$showInstanceId] = array($schedId);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate times excluding the to be moved items.
|
||||
foreach ($modifiedMap as $instance => $schedIds) {
|
||||
$this->removeGaps($instance, $schedIds);
|
||||
}
|
||||
|
||||
if (is_null($selectedInstance) || is_null($afterInstance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$currTs = intval($selectedInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origSelTs !== $currTs) {
|
||||
$show = $selectedInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
$currTs = intval($afterInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origAfterTs !== $currTs) {
|
||||
$show = $afterInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
$this->removeGaps($selectedInstance->getDbId(), $selected->getDbId());
|
||||
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $selected->getDbFileId();
|
||||
$data["cliplength"] = $selected->getDbClipLength();
|
||||
$data["cuein"] = $selected->getDbCueIn();
|
||||
$data["cueout"] = $selected->getDbCueOut();
|
||||
$data["fadein"] = $selected->getDbFadeIn();
|
||||
$data["fadeout"] = $selected->getDbFadeOut();
|
||||
$data["sched_id"] = $selected->getDbId();
|
||||
|
||||
$this->insertAfter($afterItems, array($data), $adjustSched);
|
||||
|
||||
|
||||
$this->insertAfter($afterItems, $movedData, $adjustSched);
|
||||
$this->con->commit();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue