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

View file

@ -2,6 +2,7 @@
class ScheduleController extends Zend_Controller_Action
{
protected $sched_sess = null;
public function init()
{
@ -18,11 +19,14 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('resize-show', 'json')
->addActionContext('delete-show', 'json')
->addActionContext('schedule-show', 'json')
->addActionContext('schedule-show-dialog', 'json')
->addActionContext('clear-show', 'json')
->addActionContext('get-current-playlist', 'json')
->addActionContext('find-playlists', 'html')
->addActionContext('remove-group', 'json')
->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
}
public function indexAction()
@ -143,9 +147,10 @@ class ScheduleController extends Zend_Controller_Action
{
$request = $this->getRequest();
$start_timestamp = $this->_getParam('start');
$showId = $this->_getParam('showId');
$start_timestamp = $this->sched_sess->showStart;
$showId = $this->sched_sess->showId;
$search = $this->_getParam('search', null);
$plId = $this->_getParam('plId');
if($search == "") {
$search = null;
@ -156,12 +161,7 @@ class ScheduleController extends Zend_Controller_Action
$user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId);
if($request->isPost()) {
$plId = $this->_getParam('plId');
$show->scheduleShow($start_timestamp, array($plId));
}
$this->view->playlists = $show->searchPlaylistsForShow($start_timestamp, $search);
$this->view->showContent = $show->getShowContent($start_timestamp);
@ -202,8 +202,8 @@ class ScheduleController extends Zend_Controller_Action
public function findPlaylistsAction()
{
$search = $this->_getParam('search');
$show_id = $this->_getParam('showId');
$start_timestamp = $this->_getParam('start');
$show_id = $this->sched_sess->showId;
$start_timestamp = $this->sched_sess->showStart;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type), $show_id);
@ -213,8 +213,8 @@ class ScheduleController extends Zend_Controller_Action
public function removeGroupAction()
{
$group_id = $this->_getParam('groupId');
$start_timestamp = $this->_getParam('start');
$show_id = $this->_getParam('showId');
$start_timestamp = $this->sched_sess->showStart;
$show_id = $this->sched_sess->showId;
$search = $this->_getParam('search', null);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -232,6 +232,30 @@ class ScheduleController extends Zend_Controller_Action
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
'
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
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;
RETURN NULL;
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(){
var url, string, start_date;
var url, string;
url = "/Schedule/find-playlists/format/html";
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")
.empty()
@ -194,35 +229,19 @@ function makeScheduleDialog(dialog, json, show) {
.append(json.chosen)
.droppable({
drop: function(event, ui) {
var li, pl_id, url, start_date, search;
var pl_id, url, search;
search = $("#schedule_playlist_search").val();
pl_id = $(ui.helper).attr("id").split("_").pop();
start_date = makeTimeStamp(show.start);
url = '/Schedule/schedule-show/format/json';
$.post(url,
{plId: pl_id, start: start_date, showId: show.id, search: search},
{plId: pl_id, search: search},
function(json){
var x;
$("#schedule_playlist_choice")
.empty()
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
setScheduleDialogHtml(json);
setScheduleDialogEvents();
});
$("#schedule_playlist_chosen")
.empty()
.append(json.chosen);
});
}
});
@ -231,27 +250,17 @@ function makeScheduleDialog(dialog, json, show) {
});
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();
url = '/Schedule/remove-group/format/json';
$.post(url,
{start: start_date, showId: show.id, groupId: groupId},
{groupId: groupId, search: search},
function(json){
$("#schedule_playlist_choice")
.empty()
.append(json.choice)
.find('li')
.draggable({
helper: 'clone'
});
$("#schedule_playlist_chosen")
.empty()
.append(json.chosen);
setScheduleDialogHtml(json);
setScheduleDialogEvents();
});
});
}
@ -259,13 +268,12 @@ function makeScheduleDialog(dialog, json, show) {
function openScheduleDialog(show) {
var url, start_date, end_date;
url = '/Schedule/schedule-show/format/json';
url = '/Schedule/schedule-show-dialog/format/json';
start_date = makeTimeStamp(show.start);
end_date = makeTimeStamp(show.end);
$.get(url,
{start: start_date, end: end_date, showId: show.id},
$.post(url,
{start: start_date, showId: show.id},
function(json){
var dialog = $(json.dialog);
@ -471,6 +479,5 @@ $(document).ready(function() {
$('#schedule_add_show').click(openShowDialog);
});