From 4b11979eff2da410525bfb11d18c7c6686d85a18 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Thu, 29 Oct 2015 12:17:52 -0400 Subject: [PATCH] Remove station podcast from podcast datatable; editor now opens from button in podcasts view --- .../controllers/LocaleController.php | 1 + .../application/modules/rest/Bootstrap.php | 10 ++++++++ .../rest/controllers/PodcastController.php | 25 +++++++++++++------ .../public/js/airtime/library/library.js | 20 +++++++++------ .../public/js/airtime/library/podcast.js | 9 +++++++ 5 files changed, 49 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/controllers/LocaleController.php b/airtime_mvc/application/controllers/LocaleController.php index c63ecfec0..48cce2567 100644 --- a/airtime_mvc/application/controllers/LocaleController.php +++ b/airtime_mvc/application/controllers/LocaleController.php @@ -120,6 +120,7 @@ class LocaleController extends Zend_Controller_Action "Input must be a number" => _("Input must be a number"), "Input must be in the format: yyyy-mm-dd" => _("Input must be in the format: yyyy-mm-dd"), "Input must be in the format: hh:mm:ss.t" => _("Input must be in the format: hh:mm:ss.t"), + "My Station Podcast" => _("My Station Podcast"), //library/plupload.js "You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?" => _("You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?"), diff --git a/airtime_mvc/application/modules/rest/Bootstrap.php b/airtime_mvc/application/modules/rest/Bootstrap.php index 808912c9a..2d84354e4 100644 --- a/airtime_mvc/application/modules/rest/Bootstrap.php +++ b/airtime_mvc/application/modules/rest/Bootstrap.php @@ -23,6 +23,16 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap ); $router->addRoute('podcast-bulk', $podcastBulkRoute); + $stationPodcastRoute = new Zend_Controller_Router_Route( + 'rest/podcast/station', + array( + 'controller' => 'podcast', + 'action' => 'station', + 'module' => 'rest' + ) + ); + $router->addRoute('station-podcast', $stationPodcastRoute); + $route = new Rest_RouteController($front, 'rest/podcast/:id/episodes', array( diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastController.php b/airtime_mvc/application/modules/rest/controllers/PodcastController.php index ca0b41dd4..1d972f1c7 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastController.php @@ -27,7 +27,9 @@ class Rest_PodcastController extends Zend_Rest_Controller $sortColumn = $this->_getParam('sort', PodcastPeer::ID); $sortDir = $this->_getParam('sort_dir', Criteria::ASC); + // Don't return the Station podcast - we fetch it separately $query = PodcastQuery::create() + ->filterByDbId(Application_Model_Preference::getStationPodcastId(), Criteria::NOT_EQUAL) ->setLimit($limit) ->setOffset($offset) ->orderBy($sortColumn, $sortDir); @@ -173,17 +175,13 @@ class Rest_PodcastController extends Zend_Rest_Controller foreach($ids as $id) { Application_Service_PodcastService::deletePodcastById($id); } - // XXX: do we need this to be more descriptive? - // Should we even bother passing back a response message here? - $responseBody = "Successfully deleted podcasts"; break; case HttpRequestType::GET: foreach($ids as $id) { - // TODO: This should use the same code path as the GET action. - // It essentially does, except for the rendering of the tab layout. - // That said, not every GET is going to need the page rendered... - // Where should the rendering code for the podcast tabs go? -- Duncan - $responseBody[] = Application_Service_PodcastService::buildPodcastEditorResponse($id, $this->view); + $responseBody[] = array( + "podcast" => Application_Service_PodcastService::getPodcastById($id), + "html" => $this->view->render('podcast/podcast.phtml') + ); } break; } @@ -191,6 +189,17 @@ class Rest_PodcastController extends Zend_Rest_Controller $this->_helper->json->sendJson($responseBody); } + public function stationAction() { + $stationPodcastId = Application_Model_Preference::getStationPodcastId(); + $podcast = Application_Service_PodcastService::getPodcastById($stationPodcastId); + $path = 'podcast/station_podcast.phtml'; + $this->view->podcast = $podcast; + $this->_helper->json->sendJson(array( + "podcast" => json_encode($podcast), + "html" => $this->view->render($path), + )); + } + private function getId() { if (!$id = $this->_getParam('id', false)) { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index c020a1ef0..6fad8e7a3 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1277,14 +1277,18 @@ var AIRTIME = (function(AIRTIME) { var podcastToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons(); podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW].title = $.i18n._('Add'); //"New" Podcast is misleading - podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW].eventHandlers.click = function(e) { - AIRTIME.podcast.createUrlDialog(); - }; - podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT].eventHandlers.click = function(e) { - AIRTIME.podcast.editSelectedPodcasts(); - }; - podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE].eventHandlers.click = function(e) { - AIRTIME.podcast.deleteSelectedPodcasts(); + podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW].eventHandlers.click = AIRTIME.podcast.createUrlDialog; + podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT].eventHandlers.click = AIRTIME.podcast.editSelectedPodcasts; + podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE].eventHandlers.click = AIRTIME.podcast.deleteSelectedPodcasts; + // Add a button to view the station podcast + podcastToolbarButtons["StationPodcast"] = { + 'title' : $.i18n._("My Station Podcast"), + 'iconClass' : "icon-music", + extraBtnClass : "", + elementId : "", + eventHandlers : { + click: AIRTIME.podcast.openStationPodcast + } }; //Set up the div with id "podcast_table" as a datatable. diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 2206f9cd1..3fc482487 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -216,6 +216,15 @@ var AIRTIME = (function (AIRTIME) { }); }; + /** + * Open a tab to view and edit the station podcast + */ + mod.openStationPodcast = function() { + $.get(endpoint + 'station', function(json) { + _initAppFromResponse(json); + }) + }; + /** * Create a bulk request to edit all currently selected podcasts. */