diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index e474b9177..3f0dd66b7 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -14,6 +14,7 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('new', 'json') ->addActionContext('edit', 'json') ->addActionContext('delete', 'json') + ->addActionContext('close-playlist', 'json') ->addActionContext('play', 'json') ->addActionContext('set-playlist-fades', 'json') ->addActionContext('get-playlist-fades', 'json') @@ -246,6 +247,13 @@ class PlaylistController extends Zend_Controller_Action } } + public function closePlaylistAction() { + $type = $this->_getParam('type'); + $obj = null; + Application_Model_Library::changePlaylist($obj, $type); + $this->createFullResponse($obj); + } + public function addItemsAction() { $ids = $this->_getParam('aItems', array()); diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 6ec4a1540..5d835125e 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -322,22 +322,40 @@ var AIRTIME = (function(AIRTIME) { }; mod.fnDeleteSelectedItems = function() { - if (confirm($.i18n._('Are you sure you want to delete the selected item(s)?'))) { - var aData = AIRTIME.library.getSelectedData(), - item, - temp, - aMedia = []; - - // process selected files/playlists. - for (item in aData) { - temp = aData[item]; - if (temp !== null && temp.hasOwnProperty('id') ) { - aMedia.push({"id": temp.id, "type": temp.ftype}); - } - } - - AIRTIME.library.fnDeleteItems(aMedia); - } + if (confirm($.i18n._('Are you sure you want to delete the selected item(s)?'))) { + var aData = AIRTIME.library.getSelectedData(), + item, + temp, + aMedia = [], + currentObjId = $("#side_playlist").find("#obj_id").val(), + currentObjType = $("#side_playlist").find("#obj_type").val(), + closeObj = false; + + // process selected files/playlists. + for (item in aData) { + temp = aData[item]; + if (temp !== null && temp.hasOwnProperty('id') ) { + aMedia.push({"id": temp.id, "type": temp.ftype}); + if ( (temp.id == currentObjId && temp.ftype === currentObjType) || + temp.id == currentObjId && temp.ftype === "stream" && currentObjType === "webstream") { + closeObj = true; + } + } + } + + AIRTIME.library.fnDeleteItems(aMedia); + + // close the object (playlist/block/webstream) + // on the right side if it was just deleted + // from the library + if (closeObj) { + $.post(baseUrl+"playlist/close-playlist", + {"format": "json", "type": currentObjType}, + function(json) { + $("#side_playlist").empty().append(json.html); + }); + } + } }; libraryInit = function() {