From 8212624c4aad08d6a228c95d540ef56b69a9f6c0 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Mon, 6 Feb 2012 01:51:22 +0100 Subject: [PATCH] CC-3174 : showbuilder fixed moving an item to an earlier position in a show, timeline needs a width or connected list doesn't work. place holder still has problems with floats. --- .../application/layouts/scripts/builder.phtml | 2 +- airtime_mvc/application/models/Schedule.php | 4 +-- airtime_mvc/application/models/Scheduler.php | 29 ++++++++++++++++--- .../application/models/ShowBuilder.php | 8 ++--- .../public/js/airtime/library/library.js | 4 +++ .../public/js/airtime/showbuilder/builder.js | 24 +++++++++------ 6 files changed, 49 insertions(+), 22 deletions(-) diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index 3efba392c..e9313cd03 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -22,7 +22,7 @@
layout()->library ?>
-
layout()->builder ?>
+
layout()->builder ?>
diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 13f268cf6..71e1eb462 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -326,11 +326,11 @@ class Application_Model_Schedule { JOIN cc_show AS showt ON (showt.id = si.show_id) ) - WHERE si.starts >= '{$p_startDateTime}' AND si.ends <= '{$p_endDateTime}' + WHERE si.starts >= '{$p_startDateTime}' AND si.starts <= '{$p_endDateTime}' ORDER BY si.starts, sched.starts;"; - //Logging::log($sql); + Logging::log($sql); $rows = $CC_DBC->GetAll($sql); return $rows; diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 555641ef9..d6e21d13a 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -79,6 +79,14 @@ class Application_Model_Scheduler { try { + //dont want to recalculate times for moved items. + $excludeIds = array(); + foreach ($schedFiles as $file) { + if (isset($file["sched_id"])) { + $excludeIds[] = intval($file["sched_id"]); + } + } + foreach ($scheduleItems as $schedule) { $id = intval($schedule["id"]); @@ -104,12 +112,18 @@ class Application_Model_Scheduler { $instance = intval($schedule["instance"]); } - if ($id !== 0 && $adjustSched === true) { + Logging::log("finding items >= {$nextStartDT->format("Y-m-d H:i:s.u")}"); + if ($adjustSched === true) { $followingSchedItems = CcScheduleQuery::create() - ->filterByDBStarts($schedItem->getDbStarts("Y-m-d H:i:s.u"), Criteria::GREATER_THAN) + ->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL) ->filterByDbInstanceId($instance) + ->filterByDbId($excludeIds, Criteria::NOT_IN) ->orderByDbStarts() ->find($this->con); + + foreach ($excludeIds as $id) { + Logging::log("Excluding id {$id}"); + } } foreach($schedFiles as $file) { @@ -128,6 +142,9 @@ class Application_Model_Scheduler { else { $sched = new CcSchedule(); } + Logging::log("id {$sched->getDbId()}"); + Logging::log("start time {$nextStartDT->format("Y-m-d H:i:s.u")}"); + Logging::log("end time {$endTimeDT->format("Y-m-d H:i:s.u")}"); $sched->setDbStarts($nextStartDT); $sched->setDbEnds($endTimeDT); @@ -143,11 +160,13 @@ class Application_Model_Scheduler { $nextStartDT = $endTimeDT; } - if ($id !== 0 && $adjustSched === true) { + if ($adjustSched === true) { //recalculate the start/end times after the inserted items. foreach($followingSchedItems as $item) { + Logging::log("adjusting iterm {$item->getDbId()}"); + $durationDT = new DateTime("1970-01-01 {$item->getDbClipLength()}", new DateTimeZone("UTC")); $endTimeEpoch = $nextStartDT->format("U") + $durationDT->format("U"); $endTimeDT = DateTime::createFromFormat("U", $endTimeEpoch, new DateTimeZone("UTC")); @@ -215,12 +234,14 @@ class Application_Model_Scheduler { $selected = CcScheduleQuery::create()->findPk($selectedItem[0]["id"]); $after = CcScheduleQuery::create()->findPk($afterItem[0]["id"]); - if ($origSelIns !== $selected->getDBInstanceId() + /* + if (isset($after) && $origSelIns !== $selected->getDBInstanceId() || $origAfterIns !== $after->getDBInstanceId()) { Logging::log("items have been since updated"); return; } + */ $this->removeGaps($origSelIns, $selected->getDbId()); diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 65f8ac475..b7f462732 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -12,7 +12,7 @@ class Application_Model_ShowBuilder { "footer" => false, "empty" => false, "checkbox" => false, - "id" => "", + "id" => 0, "instance" => "", "starts" => "", "startsUnix" => null, @@ -77,11 +77,10 @@ class Application_Model_ShowBuilder { $row["header"] = true; $row["starts"] = $showStartDT->format("Y-m-d H:i"); - $row["startsUnix"] = $showStartDT->format("U"); $row["ends"] = $showEndDT->format("Y-m-d H:i"); - $row["endsUnix"] = $showEndDT->format("U"); $row["duration"] = $showEndDT->format("U") - $showStartDT->format("U"); $row["title"] = $p_item["show_name"]; + $row["instance"] = intval($p_item["si_id"]); return $row; } @@ -101,10 +100,7 @@ class Application_Model_ShowBuilder { $row["id"] = intval($p_item["sched_id"]); $row["instance"] = intval($p_item["si_id"]); $row["starts"] = $schedStartDT->format("H:i:s"); - $row["startsUnix"] = $schedStartDT->format("U"); $row["ends"] = $schedEndDT->format("H:i:s"); - $row["endsUnix"] = $schedEndDT->format("U"); - $row["duration"] = $schedEndDT->format("U") - $schedStartDT->format("U"); $row["runtime"] = $this->formatDuration($runtime); $row["title"] = $p_item["file_track_title"]; $row["creator"] = $p_item["file_artist_name"]; diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 3f3bb8b33..6853fdd14 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -443,6 +443,10 @@ $(document).ready(function() { $.post(oItems.del.url, {format: "json", media: media }, function(json){ var oTable, tr; + if (json.message) { + alert(json.message); + } + oTable = $("#library_display").dataTable(); oTable.fnDeleteRow( $tr[0] ); }); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index 0e09930b8..65a10a131 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -42,6 +42,10 @@ $(document).ready(function() { iMin, iServerOffset, iClientOffset; + + if ($(sDatePickerId).val() === "") { + return 0; + } oDate = $( sDatePickerId ).datepicker( "getDate" ); @@ -75,19 +79,18 @@ $(document).ready(function() { var iStart, iEnd, iRange, - MIN_RANGE = 60*60*24; + DEFAULT_RANGE = 60*60*24; iStart = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_start", "#show_builder_timepicker_start"); iEnd = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_end", "#show_builder_timepicker_end"); iRange = iEnd - iStart; - //return min range - if (iRange < MIN_RANGE){ - iEnd = iStart + MIN_RANGE; - iRange = MIN_RANGE; + if (iRange === 0 || iEnd < iStart) { + iEnd = iStart + DEFAULT_RANGE; + iRange = DEFAULT_RANGE; } - + return { start: iStart, end: iEnd, @@ -370,11 +373,14 @@ $(document).ready(function() { }; return { - placeholder: "placeholder show-builder-placeholder", + placeholder: "placeholder show-builder-placeholder ui-state-highlight", forcePlaceholderSize: true, - items: 'tr:not(:first):not(.sb-header):not(.sb-footer):not(.sb-not-allowed):not(.sb-empty)', + items: 'tr:not(:first):not(.sb-header):not(.sb-footer):not(.sb-not-allowed)', receive: fnReceive, - update: fnUpdate + update: fnUpdate, + start: function(event, ui) { + //ui.placeholder.html("PLACE HOLDER"); + }, }; }());