CC-84: Smart Playlists

-disabled non-visible form elements
This commit is contained in:
denise 2012-07-11 15:18:47 -04:00
parent 5fb0364f2d
commit 7358b00c81
3 changed files with 18 additions and 6 deletions

View File

@ -76,12 +76,15 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
$this->addElement($spType);
$numElements = count($criteriaOptions);
for($i = 1; $i <= $numElements; $i++) {
for ($i = 1; $i <= $numElements; $i++) {
$criteria = new Zend_Form_Element_Select('sp_criteria_'.$i);
$criteria->setAttrib('class', 'input_select');
$criteria->setValue(0);
$criteria->setDecorators(array('viewHelper'));
$criteria->setMultiOptions($criteriaOptions);
if ($i != 1){
$criteria->setAttrib('disabled', 'disabled');
}
$this->addElement($criteria);
$criteriaModifers = new Zend_Form_Element_Select('sp_criteria_modifier_'.$i);
@ -89,11 +92,17 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
$criteriaModifers->setAttrib('class', 'input_select');
$criteriaModifers->setDecorators(array('viewHelper'));
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
if ($i != 1){
$criteriaModifers->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaModifers);
$criteriaValue = new Zend_Form_Element_Text('sp_criteria_value_'.$i);
$criteriaValue->setAttrib('class', 'input_text');
$criteriaValue->setDecorators(array('viewHelper'));
if ($i != 1){
$criteriaValue->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaValue);
}

View File

@ -17,16 +17,17 @@
</dd>
<dd id='sp_criteria-element'>
<?php for($i = 1; $i <= $this->criteriasLength; $i++) {?>
<div <?php if(($i > 1) && ($this->element->getElement('sp_criteria_'.$i)->getValue() == "0" &&
$this->element->getElement('sp_criteria_modifier_'.$i)->getValue() == "0")) {
<?php for ($i = 1; $i <= $this->criteriasLength; $i++) {?>
<div <?php if (($i > 1) && ($this->element->getElement('sp_criteria_'.$i)->getAttrib('disabled') == 'disabled')) {
echo 'style=display:none';
} ?>>
<?php echo $this->element->getElement('sp_criteria_'.$i) ?>
<?php echo $this->element->getElement('sp_criteria_modifier_'.$i) ?>
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?>
<a href='#' id='criteria_remove_<?php echo $i ?>'>Remove</a>
<?php if ($i != 1) { ?>
<a href='#' id='criteria_remove_<?php echo $i ?>'>Remove</a>
<?php } ?>
</div>
<?php } ?>
<a href='#' id='criteria_add'>Add</a>

View File

@ -9,6 +9,7 @@ function setSmartPlaylistEvents() {
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last').next();
div.show();
div.children().removeAttr('disabled');
div = div.next();
if(div.length === 0) {
$(this).hide();
@ -35,6 +36,7 @@ function setSmartPlaylistEvents() {
next = curr.next();
}
list.find('div:visible:last').children().attr('disabled', 'disabled');
list.find("div:visible:last")
.find('[name^="sp_criteria"]').val('').end()
.find('[name^="sp_criteria_modifier"]').val('').end()
@ -47,7 +49,7 @@ function setSmartPlaylistEvents() {
form.find('button[id="save_button"]').click(function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
data = $('form').serializeArray(),
static_action = 'Playlist/smart-playlist-criteria-generate',
static_action = 'Playlist/smart-playlist-generate',
dynamic_action ='Playlist/smart-playlist-criteria-save',
action,
callback;