CC-84: Smart Playlists
- subforms now open and close on the click event - fixed add and remove criteria to work with new subforms
This commit is contained in:
parent
952a584f10
commit
64185dac95
7 changed files with 73 additions and 37 deletions
|
@ -79,9 +79,9 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$form = new Application_Form_SmartPlaylist();
|
$form = new Application_Form_SmartPlaylist();
|
||||||
$form->removeDecorator('DtDdWrapper');
|
$form->removeDecorator('DtDdWrapper');
|
||||||
$form->startForm($pl->getId());
|
$form->startForm($pl->getId());
|
||||||
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
/*$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
||||||
$form->removeDecorator('DtDdWrapper');
|
$form->removeDecorator('DtDdWrapper');
|
||||||
$form->addSubForm($subform, 'sp_set_1');
|
$form->addSubForm($subform, 'sp_set_1');*/
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Application_Form_SmartPlaylist extends Zend_Form
|
||||||
// load criteria from db
|
// load criteria from db
|
||||||
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
|
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
|
||||||
*/
|
*/
|
||||||
$storedCrit = array();
|
/*$storedCrit = array();
|
||||||
foreach ($out as $crit) {
|
foreach ($out as $crit) {
|
||||||
$criteria = $crit->getDbCriteria();
|
$criteria = $crit->getDbCriteria();
|
||||||
$modifier = $crit->getDbModifier();
|
$modifier = $crit->getDbModifier();
|
||||||
|
@ -40,11 +40,7 @@ class Application_Form_SmartPlaylist extends Zend_Form
|
||||||
}else{
|
}else{
|
||||||
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
$openSmartPlaylistOption = false;
|
|
||||||
if (!empty($storedCrit)) {
|
|
||||||
$openSmartPlaylistOption = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$save = new Zend_Form_Element_Button('save_button');
|
$save = new Zend_Form_Element_Button('save_button');
|
||||||
$save->setAttrib('class', 'ui-button ui-state-default sp-button');
|
$save->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||||
|
@ -70,12 +66,16 @@ class Application_Form_SmartPlaylist extends Zend_Form
|
||||||
$shuffle->setDecorators(array('viewHelper'));
|
$shuffle->setDecorators(array('viewHelper'));
|
||||||
$this->addElement($shuffle);
|
$this->addElement($shuffle);
|
||||||
|
|
||||||
|
$openSmartPlaylistOption = false;
|
||||||
$numOfSubForm = 3;
|
$numOfSubForm = 3;
|
||||||
for ($i=0;$i<$numOfSubForm;$i++) {
|
for ($i=0; $i<$numOfSubForm; $i++) {
|
||||||
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
||||||
$subform->setCriteriaSetNumber($i);
|
$subform->setCriteriaSetNumber($i);
|
||||||
$subform->startForm($p_playlistId);
|
$subform->startForm($p_playlistId);
|
||||||
$this->addSubForm($subform, 'sp_set_'.$i);
|
$this->addSubForm($subform, 'sp_set_'.$i);
|
||||||
|
if ($subform->getIsOpen()) {
|
||||||
|
$openSmartPlaylistOption = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting playlist content candidate count that meets criteria
|
//getting playlist content candidate count that meets criteria
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
|
class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
private $setNumber;
|
private $setNumber;
|
||||||
|
private $openSubset;
|
||||||
|
|
||||||
public function init(){
|
public function init(){
|
||||||
|
|
||||||
|
@ -131,15 +132,20 @@ class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
|
||||||
$extra = $crit->getDbExtra();
|
$extra = $crit->getDbExtra();
|
||||||
|
|
||||||
if($criteria == "limit"){
|
if($criteria == "limit"){
|
||||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
$storedCrit[]["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||||
}else{
|
}else{
|
||||||
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
$storedCrit[]["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$openSmartPlaylistOption = false;
|
$openSmartPlaylistOption = false;
|
||||||
if (!empty($storedCrit)) {
|
if (!empty($storedCrit)) {
|
||||||
$openSmartPlaylistOption = true;
|
$openSmartPlaylistOption = true;
|
||||||
|
$this->openSubset = $openSmartPlaylistOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($subsetOpen)){
|
||||||
|
$openSmartPlaylistOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$numElements = count($criteriaOptions);
|
$numElements = count($criteriaOptions);
|
||||||
|
@ -232,4 +238,9 @@ class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
|
||||||
'criteriasLength' => count($criteriaOptions), 'poolCount' => $files['count'], 'setNumber' => $this->setNumber))
|
'criteriasLength' => count($criteriaOptions), 'poolCount' => $files['count'], 'setNumber' => $this->setNumber))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIsOpen()
|
||||||
|
{
|
||||||
|
return $this->openSubset;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
<h2 class="collapsible-header close"><span class="arrow-icon"></span>Set <?php echo $this->setNumber?></h2>
|
<h2 class="collapsible-header close" id='sp_set_<?php echo $this->setNumber?>' <?php echo $this->openOption || $this->setNumber == 0 ? "" : "style='display:none'"?>>
|
||||||
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?>' id='sp_set_<?php echo $this->setNumber?>'>
|
<span class="arrow-icon"></span>Set <?php echo $this->setNumber?>
|
||||||
|
</h2>
|
||||||
|
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed sp-closed"?>' id='sp_set_<?php echo $this->setNumber?>'>
|
||||||
<dl class='zend_form'>
|
<dl class='zend_form'>
|
||||||
|
|
||||||
<dd id='sp_criteria-element'>
|
<dd id='sp_criteria-element'>
|
||||||
|
|
|
@ -23,10 +23,9 @@
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<?php
|
<?php
|
||||||
for($i=0;$i<$this->numOfSubForm;$i++){
|
for($i=0; $i<$this->numOfSubForm; $i++){
|
||||||
echo $this->parent_form->getSubform('sp_set_'.$i);
|
echo $this->parent_form->getSubform('sp_set_'.$i);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
|
@ -481,6 +481,10 @@ input.input_text.sp_extra_input_text{
|
||||||
.sp-label{
|
.sp-label{
|
||||||
padding: 0px !important;
|
padding: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sp-closed{
|
||||||
|
border-width: 0 0 0 !important;
|
||||||
|
}
|
||||||
/***** SMART PLAYLIST SPECIFIC STYLES END *****/
|
/***** SMART PLAYLIST SPECIFIC STYLES END *****/
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
@ -2144,7 +2148,7 @@ fieldset.closed, fieldset.display_field.closed {
|
||||||
margin-left: 1px;
|
margin-left: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldset.closed dl, fieldset.closed textarea, fieldset.closed div {
|
fieldset.closed dl, fieldset.closed textarea, fieldset.closed div, fieldset.closed h2 {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,21 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function setSmartPlaylistEvents() {
|
function setSmartPlaylistEvents() {
|
||||||
var form = $('#smart-playlist-form');
|
var form = $('#smart-playlist-form'),
|
||||||
|
sets = form.find('h2[id^=sp_set]');
|
||||||
|
|
||||||
|
sets.each(function(index, set){
|
||||||
|
$(set).live('click', function(){
|
||||||
|
if ($(this).next().hasClass('closed')) {
|
||||||
|
$(this).next().removeClass('closed sp-closed');
|
||||||
|
} else {
|
||||||
|
$(this).next().addClass('closed sp-closed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
form.find('.criteria_add').live('click', function(){
|
form.find('.criteria_add').live('click', function(){
|
||||||
|
|
||||||
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
|
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
|
||||||
|
|
||||||
div.show();
|
div.show();
|
||||||
|
@ -319,33 +331,41 @@ function removeSuccessMsg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendAddButton() {
|
function appendAddButton() {
|
||||||
var rows = $('#smart-playlist-form');
|
|
||||||
var add_button = "<a class='ui-button sp-ui-button-icon-only criteria_add'>" +
|
var add_button = "<a class='ui-button sp-ui-button-icon-only criteria_add'>" +
|
||||||
"<span class='ui-icon ui-icon-plusthick'></span></a>";
|
"<span class='ui-icon ui-icon-plusthick'></span></a>";
|
||||||
|
|
||||||
rows.find('.criteria_add').remove();
|
var sets = $('fieldset[id^=sp_set]');
|
||||||
|
|
||||||
if (rows.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
|
sets.each(function(index, ele){
|
||||||
rows.find('select[name^="sp_criteria_field"]:enabled:last')
|
var set = $(ele);
|
||||||
.siblings('a[id^="criteria_remove"]')
|
set.find('.criteria_add').remove();
|
||||||
.after(add_button);
|
|
||||||
} else {
|
if (set.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
|
||||||
rows.find('select[name^="sp_criteria_field"]:enabled')
|
set.find('select[name^="sp_criteria_field"]:enabled:last')
|
||||||
.siblings('span[id="extra_criteria"]')
|
.siblings('a[id^="criteria_remove"]')
|
||||||
.after(add_button);
|
.after(add_button);
|
||||||
}
|
} else {
|
||||||
|
set.find('select[name^="sp_criteria_field"]:enabled')
|
||||||
|
.siblings('span[id="extra_criteria"]')
|
||||||
|
.after(add_button);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeButtonCheck() {
|
function removeButtonCheck() {
|
||||||
var rows = $('#smart-playlist-form');
|
var sets = $('fieldset[id^=sp_set]');
|
||||||
|
sets.each(function(index, ele){
|
||||||
if (rows.find('select[name^="sp_criteria_field"]:enabled').length == 1) {
|
var set = $(ele);
|
||||||
rows.find('a[id="criteria_remove_0"]').attr('disabled', 'disabled');
|
var temp = set.find('select[name^="sp_criteria_field"]:enabled');
|
||||||
rows.find('a[id="criteria_remove_0"]').hide();
|
var ex = temp.siblings('a[id^="criteria_remove"]');
|
||||||
} else {
|
if (temp.length == 1) {
|
||||||
rows.find('a[id="criteria_remove_0"]').removeAttr('disabled');
|
ex.attr('disabled', 'disabled');
|
||||||
rows.find('a[id="criteria_remove_0"]').show();
|
ex.hide();
|
||||||
}
|
} else {
|
||||||
|
ex.removeAttr('disabled');
|
||||||
|
ex.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var criteriaTypes = {
|
var criteriaTypes = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue