CC-4192: Smart Playlist Builder: make save button save title, description, and criteria
-done
This commit is contained in:
parent
bad418062e
commit
e674654cb1
|
@ -24,7 +24,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
->addActionContext('set-playlist-description', 'json')
|
||||
->addActionContext('playlist-preview', 'json')
|
||||
->addActionContext('get-playlist', 'json')
|
||||
->addActionContext('smart-block-criteria-save', 'json')
|
||||
->addActionContext('save', 'json')
|
||||
->addActionContext('smart-block-generate', 'json')
|
||||
->addActionContext('smart-block-shuffle', 'json')
|
||||
->addActionContext('get-block-info', 'json')
|
||||
|
@ -478,14 +478,17 @@ class PlaylistController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function setPlaylistNameAction()
|
||||
public function setPlaylistNameDescAction()
|
||||
{
|
||||
$name = $this->_getParam('name', 'Unknown Playlist');
|
||||
$description = $this->_getParam('description', "");
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
try {
|
||||
$obj = $this->getPlaylist($type);
|
||||
$obj->setName($name);
|
||||
$obj->setDescription($description);
|
||||
$this->view->description = $obj->getDescription();
|
||||
$this->view->playlistName = $name;
|
||||
$this->view->modified = $obj->getLastModified("U");
|
||||
} catch (PlaylistOutDatedException $e) {
|
||||
|
@ -497,6 +500,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public function setPlaylistDescriptionAction()
|
||||
{
|
||||
$description = $this->_getParam('description', "");
|
||||
|
@ -515,13 +519,22 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public function smartBlockCriteriaSaveAction()
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
$result = $bl->saveSmartBlockCriteria($params['data']);
|
||||
$result = array();
|
||||
|
||||
$this->setPlaylistNameDescAction();
|
||||
|
||||
if ($params['type'] == 'block') {
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
$result = $bl->saveSmartBlockCriteria($params['criteria']);
|
||||
}
|
||||
|
||||
$result["modified"] = $this->view->modified;
|
||||
die(json_encode($result));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php echo $this->element->getElement('save_button') ?>
|
||||
<?php echo $this->element->getElement('generate_button') ?>
|
||||
<?php echo $this->element->getElement('shuffle_button') ?>
|
||||
</dd>
|
||||
|
@ -96,10 +95,5 @@
|
|||
|
||||
|
||||
</dl>
|
||||
<?php /*
|
||||
for($i=0; $i<$this->numOfSubForm; $i++){
|
||||
echo $this->parent_form->getSubform('sp_set_'.$i);
|
||||
}*/
|
||||
?>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -12,6 +12,8 @@ if (isset($this->obj)) {
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<button class="ui-button ui-state-default sp-button" type="button" id="save_button">Save</button>
|
||||
|
||||
<?php if (isset($this->obj)) : ?>
|
||||
<input id="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input>
|
||||
<input id="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"></input>
|
||||
|
@ -22,6 +24,7 @@ if (isset($this->obj)) {
|
|||
</h3>
|
||||
<h4 id="spl_length"><?php echo $this->length; ?></h4>
|
||||
</div>
|
||||
<div id='sp-success' class='success' style='display:none'></div>
|
||||
|
||||
<fieldset class="toggle closed" id="fieldset-metadate_change">
|
||||
<legend style="cursor: pointer;"><span class="ui-icon ui-icon-triangle-2-n-s"></span>View / edit description</legend>
|
||||
|
@ -30,11 +33,6 @@ if (isset($this->obj)) {
|
|||
<dd id="description-element">
|
||||
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
||||
</dd>
|
||||
<dt id="submit-label" style="display: none;"> </dt>
|
||||
<dd id="submit-element" class="buttons">
|
||||
<input class="ui-button ui-state-default" type="submit" value="Cancel" id="description_cancel" name="cancel">
|
||||
<input class="ui-button ui-state-default" type="submit" value="Save" id="description_save" name="submit">
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ if (isset($this->obj)) {
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->form->getElement('save_button');?>
|
||||
|
||||
<?php if (isset($this->obj)) : ?>
|
||||
<input id="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input>
|
||||
<input id="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"></input>
|
||||
|
@ -30,11 +32,6 @@ if (isset($this->obj)) {
|
|||
<dd id="description-element">
|
||||
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
||||
</dd>
|
||||
<dt id="submit-label" style="display: none;"> </dt>
|
||||
<dd id="submit-element" class="buttons">
|
||||
<input class="ui-button ui-state-default" type="submit" value="Cancel" id="description_cancel" name="cancel">
|
||||
<input class="ui-button ui-state-default" type="submit" value="Save" id="description_save" name="submit">
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
|
|
@ -590,41 +590,39 @@ var AIRTIME = (function(AIRTIME){
|
|||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
)
|
||||
$pl.on("click", "#description_save", function(){
|
||||
var textarea = $pl.find("#fieldset-metadate_change textarea"),
|
||||
description = textarea.val(),
|
||||
url,
|
||||
lastMod = getModified(),
|
||||
type = $('#obj_type').val();
|
||||
|
||||
url = '/Playlist/set-playlist-description';
|
||||
|
||||
$.post(url,
|
||||
{format: "json", description: description, modified: lastMod, type: type},
|
||||
function(json){
|
||||
if (json.error !== undefined){
|
||||
playlistError(json);
|
||||
}
|
||||
else{
|
||||
setModified(json.modified);
|
||||
textarea.val(json.description);
|
||||
$pl.find("#fieldset-metadate_change").addClass("closed");
|
||||
redrawLib();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$pl.on("click", "#description_cancel", function(){
|
||||
var textarea = $pl.find("#fieldset-metadate_change textarea");
|
||||
|
||||
textarea.val(cachedDescription);
|
||||
$pl.find("#fieldset-metadate_change").addClass("closed");
|
||||
});
|
||||
//end edit playlist description events.
|
||||
});
|
||||
|
||||
$('#save_button').live("click", function(event){
|
||||
/* Smart blocks: get name, description, and criteria
|
||||
* Playlists: get name, description
|
||||
*/
|
||||
var criteria = $('form').serializeArray(),
|
||||
block_name = $('#playlist_name_display').text(),
|
||||
block_desc = $('textarea[name="description"]').val(),
|
||||
save_action = 'Playlist/save',
|
||||
obj_id = $('input[id="obj_id"]').val(),
|
||||
obj_type = $('#obj_type').val(),
|
||||
lastMod = getModified(),
|
||||
dt = $('table[id="library_display"]').dataTable();
|
||||
enableLoadingIcon();
|
||||
$.post(save_action,
|
||||
{format: "json", criteria: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod},
|
||||
function(data){
|
||||
var json = $.parseJSON(data);
|
||||
setModified(json.modified);
|
||||
if (obj_type == "block") {
|
||||
callback(data, "save");
|
||||
} else {
|
||||
$('.success').text('Playlist saved');
|
||||
$('.success').show();
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
dt.fnStandingRedraw();
|
||||
}
|
||||
setFadeIcon();
|
||||
disableLoadingIcon();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function setUpPlaylist() {
|
||||
|
|
|
@ -186,17 +186,21 @@ function setSmartPlaylistEvents() {
|
|||
});
|
||||
|
||||
/********** SAVE ACTION **********/
|
||||
form.find('button[id="save_button"]').live("click", function(event){
|
||||
var data = $('form').serializeArray(),
|
||||
save_action = 'Playlist/smart-block-criteria-save',
|
||||
/* moved to spl.js
|
||||
$('#save_button').live("click", function(event){
|
||||
var criteria = $('form').serializeArray(),
|
||||
block_name = $('#playlist_name_display').text(),
|
||||
block_desc = $('textarea[name="description"]').val(),
|
||||
save_action = 'Playlist/save',
|
||||
obj_id = $('input[id="obj_id"]').val();
|
||||
enableLoadingIcon();
|
||||
$.post(save_action, {format: "json", data: data, obj_id: obj_id}, function(data){
|
||||
$.post(save_action, {format: "json", criteria: criteria, name: block_name, desc: block_desc, obj_id: obj_id}, function(data){
|
||||
callback(data, "save");
|
||||
setFadeIcon();
|
||||
disableLoadingIcon();
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/********** GENERATE ACTION **********/
|
||||
form.find('button[id="generate_button"]').live("click", function(event){
|
||||
|
@ -482,8 +486,6 @@ function callback(data, type) {
|
|||
} else {
|
||||
form.find('.success').text('Criteria saved');
|
||||
form.find('.success').show();
|
||||
//redraw library table incase block changed from static to dynamic or vice versa
|
||||
dt.fnStandingRedraw();
|
||||
|
||||
/* Update number of files that meet criteria and change icon to success/warning
|
||||
* as appropriate. This is also done in the form but we do not pass the form
|
||||
|
@ -515,7 +517,7 @@ function callback(data, type) {
|
|||
}
|
||||
|
||||
function removeSuccessMsg() {
|
||||
var $status = $('#smart-playlist-form').find('.success');
|
||||
var $status = $('.success');
|
||||
|
||||
$status.fadeOut("slow", function(){$status.empty()});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue