backend mostly done for show, can remove a scheduled group from a show.

This commit is contained in:
naomiaro 2011-01-15 14:59:41 -05:00
parent f2560a6aa6
commit 25c7d4cb90
5 changed files with 98 additions and 64 deletions

View file

@ -64,6 +64,7 @@
<actionMethod actionName="clearShow"/> <actionMethod actionName="clearShow"/>
<actionMethod actionName="findPlaylists"/> <actionMethod actionName="findPlaylists"/>
<actionMethod actionName="removeGroup"/> <actionMethod actionName="removeGroup"/>
<actionMethod actionName="scheduleShowDialog"/>
</controllerFile> </controllerFile>
<controllerFile controllerName="Api"> <controllerFile controllerName="Api">
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
@ -246,6 +247,9 @@
<viewControllerScriptsDirectory forControllerName="Schedule"> <viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="removeGroup"/> <viewScriptFile forActionName="removeGroup"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="scheduleShowDialog"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -2,6 +2,7 @@
class ScheduleController extends Zend_Controller_Action class ScheduleController extends Zend_Controller_Action
{ {
protected $sched_sess = null;
public function init() public function init()
{ {
@ -18,11 +19,14 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('resize-show', 'json') ->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json') ->addActionContext('delete-show', 'json')
->addActionContext('schedule-show', 'json') ->addActionContext('schedule-show', 'json')
->addActionContext('schedule-show-dialog', 'json')
->addActionContext('clear-show', 'json') ->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json') ->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'html') ->addActionContext('find-playlists', 'html')
->addActionContext('remove-group', 'json') ->addActionContext('remove-group', 'json')
->initContext(); ->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
} }
public function indexAction() public function indexAction()
@ -143,9 +147,10 @@ class ScheduleController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$start_timestamp = $this->_getParam('start'); $start_timestamp = $this->sched_sess->showStart;
$showId = $this->_getParam('showId'); $showId = $this->sched_sess->showId;
$search = $this->_getParam('search', null); $search = $this->_getParam('search', null);
$plId = $this->_getParam('plId');
if($search == "") { if($search == "") {
$search = null; $search = null;
@ -156,12 +161,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id, $userInfo->type); $user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId); $show = new Show($user, $showId);
if($request->isPost()) {
$plId = $this->_getParam('plId');
$show->scheduleShow($start_timestamp, array($plId)); $show->scheduleShow($start_timestamp, array($plId));
}
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search); $this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
$this->view->showContent = $show->getShowContent($start_timestamp); $this->view->showContent = $show->getShowContent($start_timestamp);
@ -202,8 +202,8 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction() public function findPlaylistsAction()
{ {
$search = $this->_getParam('search'); $search = $this->_getParam('search');
$show_id = $this->_getParam('showId'); $show_id = $this->sched_sess->showId;
$start_timestamp = $this->_getParam('start'); $start_timestamp = $this->sched_sess->showStart;
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type), $show_id); $show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
@ -213,8 +213,8 @@ class ScheduleController extends Zend_Controller_Action
public function removeGroupAction() public function removeGroupAction()
{ {
$group_id = $this->_getParam('groupId'); $group_id = $this->_getParam('groupId');
$start_timestamp = $this->_getParam('start'); $start_timestamp = $this->sched_sess->showStart;
$show_id = $this->_getParam('showId'); $show_id = $this->sched_sess->showId;
$search = $this->_getParam('search', null); $search = $this->_getParam('search', null);
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -232,6 +232,30 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->playlists); unset($this->view->playlists);
} }
public function scheduleShowDialogAction()
{
$start_timestamp = $this->_getParam('start');
$showId = $this->_getParam('showId');
$this->sched_sess->showId = $showId;
$this->sched_sess->showStart = $start_timestamp;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId);
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp);
$this->view->showContent = $show->getShowContent($start_timestamp);
$this->view->choice = $this->view->render('schedule/find-playlists.phtml');
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
$this->view->dialog = $this->view->render('schedule/schedule-show.phtml');
unset($this->view->showContent);
unset($this->view->playlists);
}
} }
@ -254,6 +278,8 @@ class ScheduleController extends Zend_Controller_Action

View file

@ -0,0 +1 @@
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>scheduleShowDialog</b></center>

View file

@ -30,13 +30,9 @@ DROP FUNCTION show_content() CASCADE;
CREATE FUNCTION show_content() RETURNS trigger AS CREATE FUNCTION show_content() RETURNS trigger AS
' '
BEGIN BEGIN
IF(TG_OP=''INSERT'') THEN
UPDATE cc_show_schedule SET position = (position + 1)
WHERE (id = new.id AND position >= new.position AND id != new.id);
END IF;
IF(TG_OP=''DELETE'') THEN IF(TG_OP=''DELETE'') THEN
UPDATE cc_show_schedule SET position = (position - 1) UPDATE cc_show_schedule SET position = (position - 1)
WHERE (id = old.id AND position > old.position); WHERE (show_id = old.show_id AND show_day = old.show_day AND position > old.position);
END IF; END IF;
RETURN NULL; RETURN NULL;
END; END;

View file

@ -161,16 +161,51 @@ function openShowDialog() {
}); });
} }
function makeScheduleDialog(dialog, json, show) { function setScheduleDialogHtml(json) {
$("#schedule_playlist_choice")
.empty()
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
});
$("#schedule_playlist_chosen")
.empty()
.append(json.chosen);
}
function setScheduleDialogEvents() {
$(".ui-icon-triangle-1-e").parent().click(function(){
$(this).parent().find(".group_list").toggle();
});
$(".ui-icon-close").parent().click(function(){
var groupId, url;
groupId = $(this).parent().attr("id").split("_").pop();
url = '/Schedule/remove-group/format/json';
$.post(url,
{groupId: groupId},
function(json){
setScheduleDialogHtml(json);
setScheduleDialogEvents();
});
});
}
function makeScheduleDialog(dialog, json) {
dialog.find("#schedule_playlist_search").keyup(function(){ dialog.find("#schedule_playlist_search").keyup(function(){
var url, string, start_date; var url, string;
url = "/Schedule/find-playlists/format/html"; url = "/Schedule/find-playlists/format/html";
string = $(this).val(); string = $(this).val();
start_date = makeTimeStamp(show.start);
$.post(url, {search: string, showId: show.id, start: start_date}, function(html){ $.post(url, {search: string}, function(html){
$("#schedule_playlist_choice") $("#schedule_playlist_choice")
.empty() .empty()
@ -194,35 +229,19 @@ function makeScheduleDialog(dialog, json, show) {
.append(json.chosen) .append(json.chosen)
.droppable({ .droppable({
drop: function(event, ui) { drop: function(event, ui) {
var li, pl_id, url, start_date, search; var pl_id, url, search;
search = $("#schedule_playlist_search").val(); search = $("#schedule_playlist_search").val();
pl_id = $(ui.helper).attr("id").split("_").pop(); pl_id = $(ui.helper).attr("id").split("_").pop();
start_date = makeTimeStamp(show.start);
url = '/Schedule/schedule-show/format/json'; url = '/Schedule/schedule-show/format/json';
$.post(url, $.post(url,
{plId: pl_id, start: start_date, showId: show.id, search: search}, {plId: pl_id, search: search},
function(json){ function(json){
var x; setScheduleDialogHtml(json);
setScheduleDialogEvents();
$("#schedule_playlist_choice")
.empty()
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
}); });
$("#schedule_playlist_chosen")
.empty()
.append(json.chosen);
});
} }
}); });
@ -231,27 +250,17 @@ function makeScheduleDialog(dialog, json, show) {
}); });
dialog.find(".ui-icon-close").parent().click(function(){ dialog.find(".ui-icon-close").parent().click(function(){
var groupId, url, start_date; var groupId, url, search;
start_date = makeTimeStamp(show.start); search = $("#schedule_playlist_search").val();
groupId = $(this).parent().attr("id").split("_").pop(); groupId = $(this).parent().attr("id").split("_").pop();
url = '/Schedule/remove-group/format/json'; url = '/Schedule/remove-group/format/json';
$.post(url, $.post(url,
{start: start_date, showId: show.id, groupId: groupId}, {groupId: groupId, search: search},
function(json){ function(json){
setScheduleDialogHtml(json);
$("#schedule_playlist_choice") setScheduleDialogEvents();
.empty()
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
});
$("#schedule_playlist_chosen")
.empty()
.append(json.chosen);
}); });
}); });
} }
@ -259,13 +268,12 @@ function makeScheduleDialog(dialog, json, show) {
function openScheduleDialog(show) { function openScheduleDialog(show) {
var url, start_date, end_date; var url, start_date, end_date;
url = '/Schedule/schedule-show/format/json'; url = '/Schedule/schedule-show-dialog/format/json';
start_date = makeTimeStamp(show.start); start_date = makeTimeStamp(show.start);
end_date = makeTimeStamp(show.end);
$.get(url, $.post(url,
{start: start_date, end: end_date, showId: show.id}, {start: start_date, showId: show.id},
function(json){ function(json){
var dialog = $(json.dialog); var dialog = $(json.dialog);
@ -471,6 +479,5 @@ $(document).ready(function() {
$('#schedule_add_show').click(openShowDialog); $('#schedule_add_show').click(openShowDialog);
}); });