CC-4109: Playlist Builder: Add a button to remove all the items in the current editing playlist

This commit is contained in:
denise 2013-01-23 12:09:21 -05:00
parent d4e89df94e
commit 384298f680
7 changed files with 42 additions and 2 deletions

View File

@ -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()
{

View File

@ -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

View File

@ -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()

View File

@ -16,6 +16,9 @@ if (isset($this->obj)) {
</ul>
</div>
<?php if (isset($this->obj)) : ?>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Empty playlist content") ?>' type="button" id="pl-bl-clear-content"><? echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><? echo _("Shuffle") ?></button>
</div>

View File

@ -16,6 +16,9 @@ if (isset($this->obj)) {
</ul>
</div>
<?php if (isset($this->obj)) : ?>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Empty smart block content") ?>' type="button" id="pl-bl-clear-content"><? echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><? echo _("Save") ?></button>
</div>

View File

@ -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() {

View File

@ -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')) {