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('set-playlist-description', 'json')
|
||||||
->addActionContext('playlist-preview', 'json')
|
->addActionContext('playlist-preview', 'json')
|
||||||
->addActionContext('get-playlist', 'json')
|
->addActionContext('get-playlist', 'json')
|
||||||
->addActionContext('smart-block-criteria-save', 'json')
|
->addActionContext('save', 'json')
|
||||||
->addActionContext('smart-block-generate', 'json')
|
->addActionContext('smart-block-generate', 'json')
|
||||||
->addActionContext('smart-block-shuffle', 'json')
|
->addActionContext('smart-block-shuffle', 'json')
|
||||||
->addActionContext('get-block-info', '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');
|
$name = $this->_getParam('name', 'Unknown Playlist');
|
||||||
|
$description = $this->_getParam('description', "");
|
||||||
$type = $this->_getParam('type');
|
$type = $this->_getParam('type');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$obj = $this->getPlaylist($type);
|
$obj = $this->getPlaylist($type);
|
||||||
$obj->setName($name);
|
$obj->setName($name);
|
||||||
|
$obj->setDescription($description);
|
||||||
|
$this->view->description = $obj->getDescription();
|
||||||
$this->view->playlistName = $name;
|
$this->view->playlistName = $name;
|
||||||
$this->view->modified = $obj->getLastModified("U");
|
$this->view->modified = $obj->getLastModified("U");
|
||||||
} catch (PlaylistOutDatedException $e) {
|
} catch (PlaylistOutDatedException $e) {
|
||||||
|
@ -497,6 +500,7 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public function setPlaylistDescriptionAction()
|
public function setPlaylistDescriptionAction()
|
||||||
{
|
{
|
||||||
$description = $this->_getParam('description', "");
|
$description = $this->_getParam('description', "");
|
||||||
|
@ -515,13 +519,22 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$this->playlistUnknownError($e);
|
$this->playlistUnknownError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public function smartBlockCriteriaSaveAction()
|
public function saveAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$params = $request->getPost();
|
$params = $request->getPost();
|
||||||
$bl = new Application_Model_Block($params['obj_id']);
|
$result = array();
|
||||||
$result = $bl->saveSmartBlockCriteria($params['data']);
|
|
||||||
|
$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));
|
die(json_encode($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
<?php $i = $i + 1; ?>
|
<?php $i = $i + 1; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<?php echo $this->element->getElement('save_button') ?>
|
|
||||||
<?php echo $this->element->getElement('generate_button') ?>
|
<?php echo $this->element->getElement('generate_button') ?>
|
||||||
<?php echo $this->element->getElement('shuffle_button') ?>
|
<?php echo $this->element->getElement('shuffle_button') ?>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -96,10 +95,5 @@
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
<?php /*
|
|
||||||
for($i=0; $i<$this->numOfSubForm; $i++){
|
|
||||||
echo $this->parent_form->getSubform('sp_set_'.$i);
|
|
||||||
}*/
|
|
||||||
?>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -12,6 +12,8 @@ if (isset($this->obj)) {
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<button class="ui-button ui-state-default sp-button" type="button" id="save_button">Save</button>
|
||||||
|
|
||||||
<?php if (isset($this->obj)) : ?>
|
<?php if (isset($this->obj)) : ?>
|
||||||
<input id="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input>
|
<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>
|
<input id="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"></input>
|
||||||
|
@ -22,6 +24,7 @@ if (isset($this->obj)) {
|
||||||
</h3>
|
</h3>
|
||||||
<h4 id="spl_length"><?php echo $this->length; ?></h4>
|
<h4 id="spl_length"><?php echo $this->length; ?></h4>
|
||||||
</div>
|
</div>
|
||||||
|
<div id='sp-success' class='success' style='display:none'></div>
|
||||||
|
|
||||||
<fieldset class="toggle closed" id="fieldset-metadate_change">
|
<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>
|
<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">
|
<dd id="description-element">
|
||||||
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
||||||
</dd>
|
</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>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ if (isset($this->obj)) {
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php echo $this->form->getElement('save_button');?>
|
||||||
|
|
||||||
<?php if (isset($this->obj)) : ?>
|
<?php if (isset($this->obj)) : ?>
|
||||||
<input id="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input>
|
<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>
|
<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">
|
<dd id="description-element">
|
||||||
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
|
||||||
</dd>
|
</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>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
|
@ -590,41 +590,39 @@ var AIRTIME = (function(AIRTIME){
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
});
|
||||||
|
|
||||||
|
$('#save_button').live("click", function(event){
|
||||||
)
|
/* Smart blocks: get name, description, and criteria
|
||||||
$pl.on("click", "#description_save", function(){
|
* Playlists: get name, description
|
||||||
var textarea = $pl.find("#fieldset-metadate_change textarea"),
|
*/
|
||||||
description = textarea.val(),
|
var criteria = $('form').serializeArray(),
|
||||||
url,
|
block_name = $('#playlist_name_display').text(),
|
||||||
lastMod = getModified(),
|
block_desc = $('textarea[name="description"]').val(),
|
||||||
type = $('#obj_type').val();
|
save_action = 'Playlist/save',
|
||||||
|
obj_id = $('input[id="obj_id"]').val(),
|
||||||
url = '/Playlist/set-playlist-description';
|
obj_type = $('#obj_type').val(),
|
||||||
|
lastMod = getModified(),
|
||||||
$.post(url,
|
dt = $('table[id="library_display"]').dataTable();
|
||||||
{format: "json", description: description, modified: lastMod, type: type},
|
enableLoadingIcon();
|
||||||
function(json){
|
$.post(save_action,
|
||||||
if (json.error !== undefined){
|
{format: "json", criteria: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod},
|
||||||
playlistError(json);
|
function(data){
|
||||||
}
|
var json = $.parseJSON(data);
|
||||||
else{
|
setModified(json.modified);
|
||||||
setModified(json.modified);
|
if (obj_type == "block") {
|
||||||
textarea.val(json.description);
|
callback(data, "save");
|
||||||
$pl.find("#fieldset-metadate_change").addClass("closed");
|
} else {
|
||||||
redrawLib();
|
$('.success').text('Playlist saved');
|
||||||
}
|
$('.success').show();
|
||||||
});
|
setTimeout(removeSuccessMsg, 5000);
|
||||||
});
|
dt.fnStandingRedraw();
|
||||||
|
}
|
||||||
$pl.on("click", "#description_cancel", function(){
|
setFadeIcon();
|
||||||
var textarea = $pl.find("#fieldset-metadate_change textarea");
|
disableLoadingIcon();
|
||||||
|
}
|
||||||
textarea.val(cachedDescription);
|
);
|
||||||
$pl.find("#fieldset-metadate_change").addClass("closed");
|
});
|
||||||
});
|
|
||||||
//end edit playlist description events.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpPlaylist() {
|
function setUpPlaylist() {
|
||||||
|
|
|
@ -186,17 +186,21 @@ function setSmartPlaylistEvents() {
|
||||||
});
|
});
|
||||||
|
|
||||||
/********** SAVE ACTION **********/
|
/********** SAVE ACTION **********/
|
||||||
form.find('button[id="save_button"]').live("click", function(event){
|
/* moved to spl.js
|
||||||
var data = $('form').serializeArray(),
|
$('#save_button').live("click", function(event){
|
||||||
save_action = 'Playlist/smart-block-criteria-save',
|
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_id = $('input[id="obj_id"]').val();
|
||||||
enableLoadingIcon();
|
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");
|
callback(data, "save");
|
||||||
setFadeIcon();
|
setFadeIcon();
|
||||||
disableLoadingIcon();
|
disableLoadingIcon();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
/********** GENERATE ACTION **********/
|
/********** GENERATE ACTION **********/
|
||||||
form.find('button[id="generate_button"]').live("click", function(event){
|
form.find('button[id="generate_button"]').live("click", function(event){
|
||||||
|
@ -482,8 +486,6 @@ function callback(data, type) {
|
||||||
} else {
|
} else {
|
||||||
form.find('.success').text('Criteria saved');
|
form.find('.success').text('Criteria saved');
|
||||||
form.find('.success').show();
|
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
|
/* 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
|
* 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() {
|
function removeSuccessMsg() {
|
||||||
var $status = $('#smart-playlist-form').find('.success');
|
var $status = $('.success');
|
||||||
|
|
||||||
$status.fadeOut("slow", function(){$status.empty()});
|
$status.fadeOut("slow", function(){$status.empty()});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue