CC-3174 : showbuilder

making sure an item is not added outside of a show.
This commit is contained in:
Naomi Aro 2012-02-28 16:57:53 +01:00
parent 9b639a9b6d
commit b5f510de85
2 changed files with 28 additions and 23 deletions

View file

@ -76,22 +76,6 @@ class Application_Model_ShowBuilder {
return $formatted; return $formatted;
} }
private function makeFooterRow($p_item) {
$row = $this->defaultRowArray;
$this->isAllowed($p_item, $row);
$row["footer"] = true;
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$contentDT = $this->contentDT;
$runtime = bcsub($contentDT->format("U.u"), $showEndDT->format("U.u"), 6);
$row["runtime"] = $runtime;
$row["fRuntime"] = $this->formatTimeFilled($runtime);
return $row;
}
private function isAllowed($p_item, &$row) { private function isAllowed($p_item, &$row) {
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
@ -197,16 +181,31 @@ class Application_Model_ShowBuilder {
} }
//show is empty //show is empty
else { else {
$row["empty"] = true; $row["empty"] = true;
$row["id"] = 0 ; $row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]); $row["instance"] = intval($p_item["si_id"]);
//return null;
} }
return $row; return $row;
} }
private function makeFooterRow($p_item) {
$row = $this->defaultRowArray;
$this->isAllowed($p_item, $row);
$row["footer"] = true;
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$contentDT = $this->contentDT;
$runtime = bcsub($contentDT->format("U.u"), $showEndDT->format("U.u"), 6);
$row["runtime"] = $runtime;
$row["fRuntime"] = $this->formatTimeFilled($runtime);
return $row;
}
public function GetItems() { public function GetItems() {
$current_id = -1; $current_id = -1;

View file

@ -535,8 +535,17 @@ $(document).ready(function() {
}; };
fnUpdate = function(event, ui) { fnUpdate = function(event, ui) {
var prev = ui.item.prev();
//can't add items outside of shows.
if (prev.hasClass("sb-footer")) {
alert("Cannot add an item outside a show.");
ui.item.remove();
return;
}
aItemData = []; aItemData = [];
oPrevData = ui.item.prev().data("aData"); oPrevData = prev.data("aData");
//item was dragged in //item was dragged in
if (origTrs !== undefined) { if (origTrs !== undefined) {
@ -561,10 +570,7 @@ $(document).ready(function() {
forcePlaceholderSize: true, forcePlaceholderSize: true,
items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)', items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)',
receive: fnReceive, receive: fnReceive,
update: fnUpdate, update: fnUpdate
start: function(event, ui) {
//ui.placeholder.html("PLACE HOLDER");
}
}; };
}()); }());