From 5b0121712b64e3503cf4876d1a46766e27e6ea1c Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 13 Apr 2011 16:59:53 -0400 Subject: [PATCH] CC-2181: No cancel button on Update show -Pressing "Close" will now clear the form -Editing show will now hide "+ Show" button --- .../controllers/ScheduleController.php | 42 +++++++++++++++++-- .../views/scripts/schedule/edit-show.phtml | 3 +- .../views/scripts/schedule/get-form.phtml | 1 + public/js/airtime/schedule/add-show.js | 7 ++++ .../schedule/full-calendar-functions.js | 19 +++++---- public/js/playlist/nowplayingdatagrid.js | 4 +- 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 application/views/scripts/schedule/get-form.phtml diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index f713dc8cd..bada06562 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -25,6 +25,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('edit-show', 'json') ->addActionContext('add-show', 'json') ->addActionContext('cancel-show', 'json') + ->addActionContext('get-form', 'json') ->addActionContext('upload-to-sound-cloud', 'json') ->initContext(); @@ -48,8 +49,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('/css/add-show.css'); $this->view->headLink()->appendStylesheet('/css/contextmenu.css'); - $request = $this->getRequest(); - $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); @@ -66,7 +65,6 @@ class ScheduleController extends Zend_Controller_Action $formStyle->removeDecorator('DtDdWrapper'); $formRecord->removeDecorator('DtDdWrapper'); - $this->view->what = $formWhat; $this->view->when = $formWhen; $this->view->repeats = $formRepeats; @@ -399,6 +397,12 @@ class ScheduleController extends Zend_Controller_Action public function editShowAction() { + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new User($userInfo->id); + if(!$user->isAdmin()) { + return; + } + $showInstanceId = $this->_getParam('id'); $formWhat = new Application_Form_AddShowWhat(); @@ -495,6 +499,38 @@ class ScheduleController extends Zend_Controller_Action $this->view->entries = 5; } + public function getFormAction(){ + $formWhat = new Application_Form_AddShowWhat(); + $formWho = new Application_Form_AddShowWho(); + $formWhen = new Application_Form_AddShowWhen(); + $formRepeats = new Application_Form_AddShowRepeats(); + $formStyle = new Application_Form_AddShowStyle(); + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formWhat->removeDecorator('DtDdWrapper'); + $formWho->removeDecorator('DtDdWrapper'); + $formWhen->removeDecorator('DtDdWrapper'); + $formRepeats->removeDecorator('DtDdWrapper'); + $formStyle->removeDecorator('DtDdWrapper'); + $formRecord->removeDecorator('DtDdWrapper'); + + $this->view->what = $formWhat; + $this->view->when = $formWhen; + $this->view->repeats = $formRepeats; + $this->view->who = $formWho; + $this->view->style = $formStyle; + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; + $this->view->addNewShow = true; + + $formWhat->populate(array('add_show_id' => '-1')); + + $this->view->form = $this->view->render('schedule/add-show-form.phtml'); + } + public function addShowAction() { $js = $this->_getParam('data'); diff --git a/application/views/scripts/schedule/edit-show.phtml b/application/views/scripts/schedule/edit-show.phtml index 03bf357a5..bf01724e3 100644 --- a/application/views/scripts/schedule/edit-show.phtml +++ b/application/views/scripts/schedule/edit-show.phtml @@ -1,2 +1 @@ -entries; +//left empty on purpose diff --git a/application/views/scripts/schedule/get-form.phtml b/application/views/scripts/schedule/get-form.phtml new file mode 100644 index 000000000..bf01724e3 --- /dev/null +++ b/application/views/scripts/schedule/get-form.phtml @@ -0,0 +1 @@ +//left empty on purpose diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js index b2449a608..0c4659fac 100644 --- a/public/js/airtime/schedule/add-show.js +++ b/public/js/airtime/schedule/add-show.js @@ -189,6 +189,13 @@ function setAddShowEvents() { $("#schedule_calendar").width(y+z+50); $("#schedule_calendar").fullCalendar('render'); $("#add-show-form").hide(); + $.get("/Schedule/get-form", {format:"json"}, function(json){ + $("#add-show-form") + .empty() + .append(json.form); + + setAddShowEvents(); + }); makeAddShowButton(); }); diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index ce53f9737..6a21d21af 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -25,21 +25,26 @@ function makeAddShowButton(){ .append('Show') .find('span.fc-button:last > a') .click(function(){ - openAddShowForm(); - - var span = $(this).parent(); - $(span).prev().remove(); - $(span).remove(); + openAddShowForm(); + removeAddShowButton(); }); } -function beginEditShow(data){ - //alert (data.entries); +function removeAddShowButton(){ + var aTag = $('.fc-header-left') + .find("span.fc-button:last > a"); + var span = aTag.parent(); + span.prev().remove(); + span.remove(); +} + +function beginEditShow(data){ $("#add-show-form") .empty() .append(data.newForm); + removeAddShowButton(); setAddShowEvents(); openAddShowForm(); } diff --git a/public/js/playlist/nowplayingdatagrid.js b/public/js/playlist/nowplayingdatagrid.js index 33e077a19..cbb25c1e4 100644 --- a/public/js/playlist/nowplayingdatagrid.js +++ b/public/js/playlist/nowplayingdatagrid.js @@ -76,7 +76,7 @@ function getDateString(){ return (date0.getFullYear() + "-" + (parseInt(date0.getMonth())+1) + "-" + date0.getDate()); } -function getAJAXURL(){ +function getAjaxUrl(){ var url = "/Nowplaying/get-data-grid-data/format/json/view/"+viewType; if (viewType == "day"){ @@ -99,7 +99,7 @@ function updateDataTable(){ } function getData(){ - $.ajax({ url: getAJAXURL(), dataType:"json", success:function(data){ + $.ajax({ url: getAjaxUrl(), dataType:"json", success:function(data){ datagridData = data.entries; if (datagridData.currentShow.length > 0) currentShowInstanceID = datagridData.currentShow[0].instance_id;