From 384298f6804e10ebd6e00e5eb74cd7b08432d57f Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 23 Jan 2013 12:09:21 -0500 Subject: [PATCH] CC-4109: Playlist Builder: Add a button to remove all the items in the current editing playlist --- .../controllers/PlaylistController.php | 21 +++++++++++++++++++ airtime_mvc/application/models/Block.php | 5 ++++- airtime_mvc/application/models/Playlist.php | 4 ++++ .../views/scripts/playlist/playlist.phtml | 3 +++ .../views/scripts/playlist/smart-block.phtml | 3 +++ airtime_mvc/public/js/airtime/library/spl.js | 6 ++++++ .../js/airtime/playlist/smart_blockbuilder.js | 2 +- 7 files changed, 42 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 789d4a904..11d397bc3 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -26,6 +26,7 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('smart-block-shuffle', 'json') ->addActionContext('get-block-info', 'json') ->addActionContext('shuffle', 'json') + ->addActionContext('empty-content', 'json') ->initContext(); } @@ -336,6 +337,26 @@ class PlaylistController extends Zend_Controller_Action $this->playlistUnknownError($e); } } + + public function emptyContentAction() + { + $type = $this->_getParam('obj_type'); + try { + $obj = $this->getPlaylist($type); + if ($type == 'playlist') { + $obj->deleteAllFilesFromPlaylist(); + } else { + $obj->deleteAllFilesFromBlock(); + } + $this->createUpdateResponse($obj); + } catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($e); + } catch (PlaylistNotFoundException $e) { + $this->playlistNotFound($type); + } catch (Exception $e) { + $this->playlistUnknownError($e); + } + } public function setCueAction() { diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index cda10c1a3..cb57f0715 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1001,7 +1001,10 @@ SQL; public function deleteAllFilesFromBlock() { CcBlockcontentsQuery::create()->findByDbBlockId($this->id)->delete(); - $this->block->reload(); + //$this->block->reload(); + $this->block->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); + $this->block->save($this->con); + $this->con->commit(); } // smart block functions start diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 7aaea5243..9eec7ee4f 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -930,6 +930,10 @@ SQL; public function deleteAllFilesFromPlaylist() { CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete(); + + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); + $this->pl->save($this->con); + $this->con->commit(); } public function shuffle() diff --git a/airtime_mvc/application/views/scripts/playlist/playlist.phtml b/airtime_mvc/application/views/scripts/playlist/playlist.phtml index f8496d926..3d388bf36 100644 --- a/airtime_mvc/application/views/scripts/playlist/playlist.phtml +++ b/airtime_mvc/application/views/scripts/playlist/playlist.phtml @@ -16,6 +16,9 @@ if (isset($this->obj)) { obj)) : ?> +
+ +
diff --git a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml index b1ca48da5..1b5b648c3 100644 --- a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml +++ b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml @@ -16,6 +16,9 @@ if (isset($this->obj)) { obj)) : ?> +
+ +
diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 2839ab45d..6c49443ff 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -749,6 +749,12 @@ var AIRTIME = (function(AIRTIME){ } ); }); + + $("#pl-bl-clear-content").live("click", function(event) { + var sUrl = baseUrl+"playlist/empty-content", + oData = {}; + playlistRequest(sUrl, oData); + }); } function setUpPlaylist() { diff --git a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js index 68bb71fd5..a06ee081e 100644 --- a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js +++ b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js @@ -351,7 +351,7 @@ function setupUI() { * It is only active if playlist is not empty */ var plContents = $('#spl_sortable').children(); - var shuffleButton = $('button[id="shuffle_button"], button[id="playlist_shuffle_button"]'); + var shuffleButton = $('button[id="shuffle_button"], button[id="playlist_shuffle_button"], button[id="pl-bl-clear-content"]'); if (!plContents.hasClass('spl_empty')) { if (shuffleButton.hasClass('ui-state-disabled')) {