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:
denise 2012-07-23 12:42:00 -04:00
parent 952a584f10
commit 64185dac95
7 changed files with 73 additions and 37 deletions

View file

@ -79,9 +79,9 @@ class PlaylistController extends Zend_Controller_Action
$form = new Application_Form_SmartPlaylist();
$form->removeDecorator('DtDdWrapper');
$form->startForm($pl->getId());
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
/*$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
$form->removeDecorator('DtDdWrapper');
$form->addSubForm($subform, 'sp_set_1');
$form->addSubForm($subform, 'sp_set_1');*/
$this->view->form = $form;

View file

@ -28,7 +28,7 @@ class Application_Form_SmartPlaylist extends Zend_Form
// load criteria from db
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
*/
$storedCrit = array();
/*$storedCrit = array();
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
@ -40,11 +40,7 @@ class Application_Form_SmartPlaylist extends Zend_Form
}else{
$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->setAttrib('class', 'ui-button ui-state-default sp-button');
@ -70,12 +66,16 @@ class Application_Form_SmartPlaylist extends Zend_Form
$shuffle->setDecorators(array('viewHelper'));
$this->addElement($shuffle);
$openSmartPlaylistOption = false;
$numOfSubForm = 3;
for ($i=0;$i<$numOfSubForm;$i++) {
for ($i=0; $i<$numOfSubForm; $i++) {
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
$subform->setCriteriaSetNumber($i);
$subform->startForm($p_playlistId);
$this->addSubForm($subform, 'sp_set_'.$i);
if ($subform->getIsOpen()) {
$openSmartPlaylistOption = true;
}
}
//getting playlist content candidate count that meets criteria

View file

@ -2,6 +2,7 @@
class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
{
private $setNumber;
private $openSubset;
public function init(){
@ -131,15 +132,20 @@ class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
$extra = $crit->getDbExtra();
if($criteria == "limit"){
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
$storedCrit[]["limit"] = array("value"=>$value, "modifier"=>$modifier);
}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;
$this->openSubset = $openSmartPlaylistOption;
}
if(!empty($subsetOpen)){
$openSmartPlaylistOption = true;
}
$numElements = count($criteriaOptions);
@ -232,4 +238,9 @@ class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
'criteriasLength' => count($criteriaOptions), 'poolCount' => $files['count'], 'setNumber' => $this->setNumber))
));
}
public function getIsOpen()
{
return $this->openSubset;
}
}

View file

@ -1,5 +1,7 @@
<h2 class="collapsible-header close"><span class="arrow-icon"></span>Set <?php echo $this->setNumber?></h2>
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?>' id='sp_set_<?php echo $this->setNumber?>'>
<h2 class="collapsible-header close" id='sp_set_<?php echo $this->setNumber?>' <?php echo $this->openOption || $this->setNumber == 0 ? "" : "style='display:none'"?>>
<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'>
<dd id='sp_criteria-element'>

View file

@ -23,10 +23,9 @@
</dd>
</dl>
<?php
for($i=0;$i<$this->numOfSubForm;$i++){
for($i=0; $i<$this->numOfSubForm; $i++){
echo $this->parent_form->getSubform('sp_set_'.$i);
}
?>
</fieldset>
</form>

View file

@ -481,6 +481,10 @@ input.input_text.sp_extra_input_text{
.sp-label{
padding: 0px !important;
}
.sp-closed{
border-width: 0 0 0 !important;
}
/***** SMART PLAYLIST SPECIFIC STYLES END *****/
label {
@ -2144,7 +2148,7 @@ fieldset.closed, fieldset.display_field.closed {
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;
}

View file

@ -3,9 +3,21 @@ $(document).ready(function() {
});
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(){
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
div.show();
@ -319,33 +331,41 @@ function removeSuccessMsg() {
}
function appendAddButton() {
var rows = $('#smart-playlist-form');
var add_button = "<a class='ui-button sp-ui-button-icon-only criteria_add'>" +
"<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) {
rows.find('select[name^="sp_criteria_field"]:enabled:last')
.siblings('a[id^="criteria_remove"]')
.after(add_button);
} else {
rows.find('select[name^="sp_criteria_field"]:enabled')
.siblings('span[id="extra_criteria"]')
.after(add_button);
}
sets.each(function(index, ele){
var set = $(ele);
set.find('.criteria_add').remove();
if (set.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
set.find('select[name^="sp_criteria_field"]:enabled:last')
.siblings('a[id^="criteria_remove"]')
.after(add_button);
} else {
set.find('select[name^="sp_criteria_field"]:enabled')
.siblings('span[id="extra_criteria"]')
.after(add_button);
}
});
}
function removeButtonCheck() {
var rows = $('#smart-playlist-form');
if (rows.find('select[name^="sp_criteria_field"]:enabled').length == 1) {
rows.find('a[id="criteria_remove_0"]').attr('disabled', 'disabled');
rows.find('a[id="criteria_remove_0"]').hide();
} else {
rows.find('a[id="criteria_remove_0"]').removeAttr('disabled');
rows.find('a[id="criteria_remove_0"]').show();
}
var sets = $('fieldset[id^=sp_set]');
sets.each(function(index, ele){
var set = $(ele);
var temp = set.find('select[name^="sp_criteria_field"]:enabled');
var ex = temp.siblings('a[id^="criteria_remove"]');
if (temp.length == 1) {
ex.attr('disabled', 'disabled');
ex.hide();
} else {
ex.removeAttr('disabled');
ex.show();
}
});
}
var criteriaTypes = {