CC-3463 : timeline usability
moving multiple files within the timeline.
This commit is contained in:
parent
ff2907823b
commit
e76cffd8b0
|
@ -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();
|
||||
|
|
|
@ -50,10 +50,10 @@ var AIRTIME = (function(AIRTIME){
|
|||
}
|
||||
|
||||
if (selected.length === 1) {
|
||||
message = "Moving "+selected.length+" Item.";
|
||||
message = "Adding "+selected.length+" Item.";
|
||||
}
|
||||
else {
|
||||
message = "Moving "+selected.length+" Items.";
|
||||
message = "Adding "+selected.length+" Items.";
|
||||
}
|
||||
|
||||
container = $('<div class="helper"/>')
|
||||
|
|
|
@ -51,10 +51,10 @@ var AIRTIME = (function(AIRTIME){
|
|||
}
|
||||
|
||||
if (selected.length === 1) {
|
||||
message = "Moving "+selected.length+" Item.";
|
||||
message = "Adding "+selected.length+" Item.";
|
||||
}
|
||||
else {
|
||||
message = "Moving "+selected.length+" Items.";
|
||||
message = "Adding "+selected.length+" Items.";
|
||||
}
|
||||
|
||||
container = $('<div/>').attr('id', 'draggingContainer')
|
||||
|
|
|
@ -222,14 +222,20 @@ var AIRTIME = (function(AIRTIME) {
|
|||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
},
|
||||
hide: 'mouseout'
|
||||
|
||||
},
|
||||
hide: 'mouseout'
|
||||
});
|
||||
},
|
||||
"fnDrawCallback": AIRTIME.library.events.fnDrawCallback,
|
||||
"fnHeaderCallback": function(nHead) {
|
||||
$(nHead).find("input[type=checkbox]").attr("checked", false);
|
||||
var oTT,
|
||||
checked = $(nHead).find("input[type=checkbox]").filter(":checked");
|
||||
|
||||
if (checked.length > 0) {
|
||||
oTT = TableTools.fnGetInstance('library_display');
|
||||
checked.attr("checked", false);
|
||||
oTT.fnSelectNone();
|
||||
}
|
||||
},
|
||||
|
||||
"aaSorting": [[3, 'asc']],
|
||||
|
|
|
@ -472,7 +472,9 @@ var AIRTIME = (function(AIRTIME){
|
|||
fnReceive,
|
||||
fnUpdate,
|
||||
i,
|
||||
html;
|
||||
html,
|
||||
helperData,
|
||||
draggingContainer;
|
||||
|
||||
fnAdd = function() {
|
||||
var aMediaIds = [],
|
||||
|
@ -489,8 +491,11 @@ var AIRTIME = (function(AIRTIME){
|
|||
fnMove = function() {
|
||||
var aSelect = [],
|
||||
aAfter = [];
|
||||
|
||||
for(i = 0; i < helperData.length; i++) {
|
||||
aSelect.push({"id": helperData[i].id, "instance": helperData[i].instance, "timestamp": helperData[i].timestamp});
|
||||
}
|
||||
|
||||
aSelect.push({"id": aItemData[0].id, "instance": aItemData[0].instance, "timestamp": aItemData[0].timestamp});
|
||||
aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
|
||||
|
||||
AIRTIME.showbuilder.fnMove(aSelect, aAfter);
|
||||
|
@ -533,7 +538,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
//item was dragged in
|
||||
if (origTrs !== undefined) {
|
||||
|
||||
$("#show_builder_table tr.ui-draggable")
|
||||
tableDiv.find("tr.ui-draggable")
|
||||
.empty()
|
||||
.after(html);
|
||||
|
||||
|
@ -543,6 +548,11 @@ var AIRTIME = (function(AIRTIME){
|
|||
}
|
||||
//item was reordered.
|
||||
else {
|
||||
|
||||
ui.item
|
||||
.empty()
|
||||
.after(draggingContainer.html());
|
||||
|
||||
aItemData.push(ui.item.data("aData"));
|
||||
fnMove();
|
||||
}
|
||||
|
@ -551,9 +561,54 @@ var AIRTIME = (function(AIRTIME){
|
|||
return {
|
||||
placeholder: "placeholder show-builder-placeholder ui-state-highlight",
|
||||
forcePlaceholderSize: true,
|
||||
helper: function(event, item) {
|
||||
var oTT = TableTools.fnGetInstance('show_builder_table'),
|
||||
selected = oTT.fnGetSelectedData(),
|
||||
elements = tableDiv.find('tr:not(:first) input:checked').parents('tr'),
|
||||
thead = $("#show_builder_table thead"),
|
||||
colspan = thead.find("th").length,
|
||||
trfirst = thead.find("tr:first"),
|
||||
width = trfirst.width(),
|
||||
height = trfirst.height(),
|
||||
message;
|
||||
|
||||
//elements.hide();
|
||||
|
||||
//if nothing is checked select the dragged item.
|
||||
if (selected.length === 0) {
|
||||
selected = [item.data("aData")];
|
||||
}
|
||||
|
||||
if (selected.length === 1) {
|
||||
message = "Moving "+selected.length+" Item.";
|
||||
}
|
||||
else {
|
||||
message = "Moving "+selected.length+" Items.";
|
||||
}
|
||||
|
||||
draggingContainer = $('<tr/>')
|
||||
.addClass('sb-helper')
|
||||
.append('<td/>')
|
||||
.find("td")
|
||||
.attr("colspan", colspan)
|
||||
.width(width)
|
||||
.height(height)
|
||||
.addClass("ui-state-highlight")
|
||||
.append(message)
|
||||
.end();
|
||||
|
||||
helperData = selected;
|
||||
|
||||
return draggingContainer;
|
||||
},
|
||||
items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)',
|
||||
receive: fnReceive,
|
||||
update: fnUpdate
|
||||
update: fnUpdate,
|
||||
start: function(event, ui) {
|
||||
var elements = tableDiv.find('tr:not(:first) input:checked').parents('tr');
|
||||
|
||||
elements.hide();
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
|
|
Loading…
Reference in New Issue