From 83085220e2bbb49bba0d4abbff8a3e0444cb18ab Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 14 Aug 2012 09:26:49 -0400 Subject: [PATCH 1/3] CC-4220: Smart Playlists: Change indexing of criteria elements -changed Block model to reflect index changes --- airtime_mvc/application/models/Block.php | 136 ++++++----------------- 1 file changed, 32 insertions(+), 104 deletions(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index bb7f50a9e..ecee2ae54 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -976,70 +976,11 @@ EOT; } $criteriaFieldsUsed = array(); - foreach ($data['criteria'] as $key=>$d){ - $error = array(); - // check for not selected select box - if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){ - $error[] = "You must select Criteria and Modifier"; - } else if (in_array($d['sp_criteria_field'], $criteriaFieldsUsed)) { - $error[] = "Criteria fields can only be used once"; - } else { - array_push($criteriaFieldsUsed, $d['sp_criteria_field']); - $column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]); - // validation on type of column - if ($d['sp_criteria_field'] == 'length') { - if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})$/", $d['sp_criteria_value'])) { - $error[] = "'Length' should be in '00:00:00' format"; - } - } else if ($column->getType() == PropelColumnTypes::TIMESTAMP) { - if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) { - $error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"; - } else { - $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']); - if (!$result["success"]) { - // check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) - $error[] = $result["errMsg"]; - } - } - - if (isset($d['sp_criteria_extra'])) { - if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) { - $error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"; - } else { - $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']); - if (!$result["success"]) { - // check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) - $error[] = $result["errMsg"]; - } - } - } - } else if ($column->getType() == PropelColumnTypes::INTEGER) { - if (!is_numeric($d['sp_criteria_value'])) { - $error[] = "The value has to be numeric"; - } - // length check - if (intval($d['sp_criteria_value']) >= pow(2,31)) { - $error[] = "The value should be less then 2147483648"; - } - } else if ($column->getType() == PropelColumnTypes::VARCHAR) { - if (strlen($d['sp_criteria_value']) > $column->getSize()) { - $error[] = "The value should be less ".$column->getSize()." characters"; - } - } - } - - if ($d['sp_criteria_value'] == "") { - $error[] = "Value cannot be empty"; - } - if(count($error) > 0){ - $errors[] = array("element"=>"sp_criteria_field_".$key, "msg"=>$error); - } - }// foreach - if (isset($data['modrow'])) { - $modKeys = array_keys($data['modrow']); - for ($i = 0; $i < count($modKeys); $i++) { - foreach ($data['modrow'][$modKeys[$i]] as $key=>$d){ + if (isset($data['criteria'])) { + $critKeys = array_keys($data['criteria']); + for ($i = 0; $i < count($critKeys); $i++) { + foreach ($data['criteria'][$critKeys[$i]] as $key=>$d){ $error = array(); // check for not selected select box if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){ @@ -1092,9 +1033,9 @@ EOT; $error[] = "Value cannot be empty"; } if(count($error) > 0){ - $errors[] = array("element"=>"sp_criteria_field_".$modKeys[$i]."_".$key, "msg"=>$error); + $errors[] = array("element"=>"sp_criteria_field_".$critKeys[$i]."_".$key, "msg"=>$error); } - }//end mod foreach + }//end foreach }//for loop }//if @@ -1140,25 +1081,12 @@ EOT; public function storeCriteriaIntoDb($p_criteriaData){ // delete criteria under $p_blockId CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete(); - - foreach( $p_criteriaData['criteria'] as $d){ - $qry = new CcBlockcriteria(); - $qry->setDbCriteria($d['sp_criteria_field']) - ->setDbModifier($d['sp_criteria_modifier']) - ->setDbValue($d['sp_criteria_value']) - ->setDbBlockId($this->id); - - if (isset($d['sp_criteria_extra'])) { - $qry->setDbExtra($d['sp_criteria_extra']); - } - $qry->save(); - } //insert modifier rows - if (isset($p_criteriaData['modrow'])) { - $modKeys = array_keys($p_criteriaData['modrow']); - for ($i = 0; $i < count($modKeys); $i++) { - foreach( $p_criteriaData['modrow'][$modKeys[$i]] as $d){ + if (isset($p_criteriaData['criteria'])) { + $critKeys = array_keys($p_criteriaData['criteria']); + for ($i = 0; $i < count($critKeys); $i++) { + foreach( $p_criteriaData['criteria'][$critKeys[$i]] as $d){ $qry = new CcBlockcriteria(); $qry->setDbCriteria($d['sp_criteria_field']) ->setDbModifier($d['sp_criteria_modifier']) @@ -1379,6 +1307,11 @@ EOT; $index = strrpos($ele['name'], '_'); + /* Strip field name of modifier index + * Ex: sp_criteria_field_0_0 -> sp_criteria_field_0 + */ + $fieldName = substr($ele['name'], 0, $index); + /* Get criteria row index. * We only need this if there is a modifier row */ @@ -1388,32 +1321,27 @@ EOT; $critIndexPos = strlen($r[0]); $critIndex = $tempName[$critIndexPos]; } + $lastChar = substr($ele['name'], -1); - $fieldName = substr($ele['name'], 0, $index); + // If lastChar is an integer we should strip it off + if (!preg_match("/^[a-zA-Z]$/", $lastChar)) { + /* Strip field name of criteria index + * Ex: sp_criteria_field_0 -> sp_criteria_field + * We do this to check if the field name is a criteria + * or the block type + */ + $n = strrpos($fieldName, '_'); + $fieldName = substr($fieldName, 0, $n); + } - /* Determine if this is a modifier row - * We will know if $fieldName's last character is an integer - */ - $modRow = $fieldName[strlen($fieldName)-1]; - if (!preg_match("/^[a-zA-Z]$/", $modRow)) { - $modIndex = strrpos($fieldName, '_'); - $fieldName = substr($fieldName, 0, $modIndex); - if (in_array($fieldName, $fieldNames)) { - $rowNum = intval($tempName[strlen($tempName)-1]); - $output['modrow'][$critIndex][$rowNum][$fieldName] = trim($ele['value']); - }else{ - $output['etc'][$ele['name']] = $ele['value']; - } - } else { - if (in_array($fieldName, $fieldNames)) { - $rowNum = intval(substr($ele['name'], $index+1)); - $output['criteria'][$rowNum][$fieldName] = trim($ele['value']); - }else{ - $output['etc'][$ele['name']] = $ele['value']; - } + if (in_array($fieldName, $fieldNames)) { + $rowNum = intval(substr($ele['name'], $index+1)); + $output['criteria'][$critIndex][$lastChar][$fieldName] = trim($ele['value']); + }else{ + $output['etc'][$ele['name']] = $ele['value']; } } - + return $output; } // smart block functions end From c62d89d5da0ee40b5761f48d1866436a7c5d1785 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 14 Aug 2012 10:02:36 -0400 Subject: [PATCH 2/3] CC-4220: Smart Playlists: Change indexing of criteria elements -changed indexing on UI --- .../application/forms/SmartBlockCriteria.php | 165 +++++++----------- airtime_mvc/application/models/Block.php | 6 +- .../scripts/form/smart-block-criteria.phtml | 26 +-- .../airtime/playlist/smart_playlistbuilder.js | 23 +-- 4 files changed, 84 insertions(+), 136 deletions(-) diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index 016105740..31e62f593 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -112,10 +112,10 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $bl = new Application_Model_Block($p_blockId); $storedCrit = $bl->getCriteria(); - - /* $modRoadMap stores the number of modifier rows each - * criteria row has. We need to know this so we display the - * the form elements properly + + /* $modRoadMap stores the number of same criteria + * Ex: 3 Album titles, and 2 Track titles + * We need to know this so we display the form elements properly */ $modRowMap = array(); @@ -138,117 +138,78 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $critCount = 1; } - $modRowMap[$i] = $critCount-1; + $modRowMap[$i] = $critCount; /* Loop through all criteria with the same field * Ex: all criteria for 'Album' */ for ($j = 0; $j < $critCount; $j++) { /****************** CRITERIA ***********/ - if ($j < 1) { - $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i); - $criteria->setAttrib('class', 'input_select sp_input_select') - ->setValue('Select criteria') - ->setDecorators(array('viewHelper')) - ->setMultiOptions($criteriaOptions); - if ($i != 0 && !isset($criteriaKeys[$i])) { - $criteria->setAttrib('disabled', 'disabled'); - } - - if (isset($criteriaKeys[$i])) { - $criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; - $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); - } - $this->addElement($criteria); - - /****************** MODIFIER ***********/ - $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i); - $criteriaModifers->setValue('Select modifier') - ->setAttrib('class', 'input_select sp_input_select') - ->setDecorators(array('viewHelper')); - if ($i != 0 && !isset($criteriaKeys[$i])) { - $criteriaModifers->setAttrib('disabled', 'disabled'); - } - if (isset($criteriaKeys[$i])) { - if($criteriaType == "s"){ - $criteriaModifers->setMultiOptions($stringCriteriaOptions); - }else{ - $criteriaModifers->setMultiOptions($numericCriteriaOptions); - } - $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); - }else{ - $criteriaModifers->setMultiOptions(array('0' => 'Select modifier')); - } - $this->addElement($criteriaModifers); - - /****************** VALUE ***********/ - $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i); - $criteriaValue->setAttrib('class', 'input_text sp_input_text') - ->setDecorators(array('viewHelper')); - if ($i != 0 && !isset($criteriaKeys[$i])){ - $criteriaValue->setAttrib('disabled', 'disabled'); - } - if (isset($criteriaKeys[$i])) { - $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); - } - $this->addElement($criteriaValue); - - /****************** EXTRA ***********/ - $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i); - $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') - ->setDecorators(array('viewHelper')); - if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { - $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); - $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); - }else{ - $criteriaExtra->setAttrib('disabled', 'disabled'); - } - $this->addElement($criteriaExtra); - - /* This is where the additional modifier rows get defined - * The additional row count starts at 0 and gets appended - * to the parent field name - */ - } else if (count($storedCrit["crit"][$criteriaKeys[$i]]) > 1) { - $n = $j - 1; - $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$n); - $criteria->setAttrib('class', 'input_select sp_input_select sp-invisible') - ->setValue('Select criteria') - ->setDecorators(array('viewHelper')) - ->setMultiOptions($criteriaOptions) - ->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); - $this->addElement($criteria); - - $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$n); - $criteriaModifers->setValue('Select modifier') - ->setAttrib('class', 'input_select sp_input_select') - ->setDecorators(array('viewHelper')); + if ($j > 0) { + $invisible = ' sp-invisible'; + } else { + $invisible = ''; + } + + $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j); + $criteria->setAttrib('class', 'input_select sp_input_select'.$invisible) + ->setValue('Select criteria') + ->setDecorators(array('viewHelper')) + ->setMultiOptions($criteriaOptions); + if ($i != 0 && !isset($criteriaKeys[$i])) { + $criteria->setAttrib('disabled', 'disabled'); + } + + if (isset($criteriaKeys[$i])) { + $criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; + $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); + } + $this->addElement($criteria); + + /****************** MODIFIER ***********/ + $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j); + $criteriaModifers->setValue('Select modifier') + ->setAttrib('class', 'input_select sp_input_select') + ->setDecorators(array('viewHelper')); + if ($i != 0 && !isset($criteriaKeys[$i])) { + $criteriaModifers->setAttrib('disabled', 'disabled'); + } + if (isset($criteriaKeys[$i])) { if($criteriaType == "s"){ $criteriaModifers->setMultiOptions($stringCriteriaOptions); }else{ $criteriaModifers->setMultiOptions($numericCriteriaOptions); } $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); - $this->addElement($criteriaModifers); - - $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$n); - $criteriaValue->setAttrib('class', 'input_text sp_input_text') - ->setDecorators(array('viewHelper')) - ->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); - $this->addElement($criteriaValue); - - $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$n); - $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') - ->setDecorators(array('viewHelper')); - if (isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { - $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); - $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); - }else{ - $criteriaExtra->setAttrib('disabled', 'disabled'); - } - $this->addElement($criteriaExtra); + }else{ + $criteriaModifers->setMultiOptions(array('0' => 'Select modifier')); } - + $this->addElement($criteriaModifers); + + /****************** VALUE ***********/ + $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j); + $criteriaValue->setAttrib('class', 'input_text sp_input_text') + ->setDecorators(array('viewHelper')); + if ($i != 0 && !isset($criteriaKeys[$i])){ + $criteriaValue->setAttrib('disabled', 'disabled'); + } + if (isset($criteriaKeys[$i])) { + $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); + } + $this->addElement($criteriaValue); + + /****************** EXTRA ***********/ + $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j); + $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') + ->setDecorators(array('viewHelper')); + if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { + $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); + $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); + }else{ + $criteriaExtra->setAttrib('disabled', 'disabled'); + } + $this->addElement($criteriaExtra); + }//for }//for diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index ecee2ae54..9fad96c25 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -935,6 +935,7 @@ EOT; public function saveSmartBlockCriteria($p_criteria) { $data = $this->organizeSmartPlyalistCriteria($p_criteria); + // things we need to check // 1. limit value shouldn't be empty and has upperbound of 24 hrs // 2. sp_criteria or sp_criteria_modifier shouldn't be 0 @@ -1312,10 +1313,9 @@ EOT; */ $fieldName = substr($ele['name'], 0, $index); - /* Get criteria row index. - * We only need this if there is a modifier row - */ + // Get criteria row index. $tempName = $ele['name']; + // Get the last digit in the field name preg_match('/^\D*(?=\d)/', $tempName, $r); if (isset($r[0])) { $critIndexPos = strlen($r[0]); diff --git a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml index 3ee4baa83..f3e19d758 100644 --- a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml +++ b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml @@ -24,36 +24,22 @@
criteriasLength; $i++) {?> -
0) && ($this->element->getElement("sp_criteria_field_".$i)->getAttrib('disabled') == 'disabled')) { + modRowMap[$i]; $j++) {?> +
0) && ($this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled')) { echo 'style=display:none'; } ?>> - element->getElement("sp_criteria_field_".$i) ?> + element->getElement("sp_criteria_field_".$i."_".$j) ?> - element->getElement("sp_criteria_modifier_".$i) ?> - element->getElement("sp_criteria_value_".$i) ?> - element->getElement("sp_criteria_extra_".$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to element->getElement('sp_criteria_extra_'.$i) ?> + element->getElement("sp_criteria_modifier_".$i."_".$j) ?> + element->getElement("sp_criteria_value_".$i."_".$j) ?> + element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to element->getElement('sp_criteria_extra_'.$i."_".$j) ?>
- - modRowMap[$i]; $j++) {?> -
- element->getElement("sp_criteria_field_".$i."_".$j) ?> - - - - element->getElement("sp_criteria_modifier_".$i."_".$j) ?> - element->getElement("sp_criteria_value_".$i."_".$j) ?> - element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to element->getElement('sp_criteria_extra_'.$i."_".$j) ?> - - - -
-
diff --git a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js index 81dadd729..b6a02d24d 100644 --- a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js @@ -317,6 +317,7 @@ function reindexElements() { * a modifier row */ if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) { + modIndex++; $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); @@ -328,20 +329,20 @@ function reindexElements() { $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); - modIndex++; } else { index++; - $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index); - $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index); - $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index); - $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index); - $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index); - $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index); - $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index); - $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index); - $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); - $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index); modIndex = 0; + $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); + $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); + $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); + //modIndex = 0; } } else if (i > 0) { $(div).remove(); From 09f1fe6775bfbafe0b73f32e859879825e251856 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 14 Aug 2012 10:05:13 -0400 Subject: [PATCH 3/3] CC-4220: Smart Playlists: Change indexing of criteria elements -code refactoring --- .../airtime/playlist/smart_playlistbuilder.js | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js index b6a02d24d..162c901b0 100644 --- a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js @@ -318,32 +318,21 @@ function reindexElements() { */ if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) { modIndex++; - - $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); - $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); - $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); } else { index++; modIndex = 0; - $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex); - $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex); - $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); - $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); - $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); - //modIndex = 0; } + + $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex); + $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex); + $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); + $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); + $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); } else if (i > 0) { $(div).remove(); }