work in progress - need to write rules to parse when to show vs hide datetime select and add it to value field
This commit is contained in:
parent
c630a69b89
commit
c78979c19c
|
@ -5,6 +5,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
private $stringCriteriaOptions;
|
||||
private $numericCriteriaOptions;
|
||||
private $dateTimeCriteriaOptions;
|
||||
private $timePeriodCriteriaOptions;
|
||||
private $sortOptions;
|
||||
private $limitOptions;
|
||||
|
||||
|
@ -135,15 +136,16 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
}
|
||||
|
||||
|
||||
private function getTimePeriodCriteriaOptions() {
|
||||
private function getTimePeriodCriteriaOptions()
|
||||
{
|
||||
if (!isset($this->timePeriodCriteriaOptions)) {
|
||||
$this->timePeriodCriteriaOptions = array(
|
||||
"0" => _("Select unit of time"),
|
||||
"minute" => _("minute"),
|
||||
"hour" => _("hour"),
|
||||
"day" => _("day"),
|
||||
"week" => _("week"),
|
||||
"year" => _("year")
|
||||
"minute" => _("minute(s)"),
|
||||
"hour" => _("hour(s)"),
|
||||
"day" => _("day(s)"),
|
||||
"week" => _("week(s)"),
|
||||
"year" => _("year(s)")
|
||||
);
|
||||
}
|
||||
return $this->timePeriodCriteriaOptions;
|
||||
|
@ -343,6 +345,28 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
}
|
||||
$this->addElement($criteriaValue);
|
||||
|
||||
|
||||
/****************** DATETIME SELECT *************/
|
||||
$criteriaDatetimeSelect = new Zend_Form_Element_Select("sp_criteria_datetime_select_".$i."_".$j);
|
||||
$criteriaDatetimeSelect->setAttrib('class','input_select sp_input_select')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaDatetimeSelect->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
// need to determine how this is stored in the database if using plaintext need to parse the value
|
||||
/* @todo figure this out */
|
||||
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
||||
$criteriaDatetimeSelect->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
||||
$criteriaDatetimeSelect->setAttrib('class', 'input_text sp_datetime_input_select');
|
||||
} else {
|
||||
$criteriaDatetimeSelect->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
||||
/* TODO FIX THIS */
|
||||
$criteriaDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions());
|
||||
// $criteriaDatetimeSelect->setMultiOptions(array('0' => _('Select modifier')));
|
||||
$this->addElement($criteriaDatetimeSelect);
|
||||
|
||||
/****************** EXTRA ***********/
|
||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j);
|
||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||
|
|
|
@ -93,8 +93,11 @@
|
|||
echo 'style=display:none';
|
||||
} ?> >
|
||||
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) /* @todo finish this */?>
|
||||
|
||||
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
|
||||
<span class='sp_text_font' id="datetime_select" <?php echo $this->element->getElement("sp_criteria_datetime_select_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>><?php echo $this->element->getElement('sp_criteria_datetime_select_'.$i."_".$j) ?><?php echo _(" ago "); ?></span>
|
||||
|
||||
<a class='btn btn-small btn-new' id='modifier_add_<?php echo $i ?>'>
|
||||
<i class='icon-white icon-plus'></i><?php echo(_("New Modifier")); ?>
|
||||
</a>
|
||||
|
|
|
@ -66,6 +66,7 @@ function setSmartBlockEvents() {
|
|||
newRowVal.val('');
|
||||
newRowExtra.val('');
|
||||
disableAndHideExtraField(newRowVal);
|
||||
disableAndHideDateTimeDropdown(newRowVal);
|
||||
sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
|
||||
|
||||
//remove the 'criteria add' button from new modifier row
|
||||
|
@ -112,7 +113,10 @@ function setSmartBlockEvents() {
|
|||
|
||||
var criteria_value = next.find('[name^="sp_criteria_value"]').val();
|
||||
curr.find('[name^="sp_criteria_value"]').val(criteria_value);
|
||||
|
||||
|
||||
/* @todo need to add something regarding hiding datetime_select here */
|
||||
|
||||
|
||||
/* if current and next row have the extra criteria value
|
||||
* (for 'is in the range' modifier), then assign the next
|
||||
* extra value to current and remove that element from
|
||||
|
@ -241,6 +245,7 @@ function setSmartBlockEvents() {
|
|||
|
||||
// disable extra field and hide the span
|
||||
disableAndHideExtraField($(this), index);
|
||||
disableAndHideDateTimeDropdown($(this), index);
|
||||
populateModifierSelect(this, true);
|
||||
});
|
||||
|
||||
|
@ -248,7 +253,22 @@ function setSmartBlockEvents() {
|
|||
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){
|
||||
var criteria_value = $(this).next(),
|
||||
index_num = getRowIndex($(this).parent());
|
||||
|
||||
|
||||
if ($(this).val().match('before|after|between')) {
|
||||
enableAndShowDateTimeDropdown(criteria_value, index_num);
|
||||
|
||||
if ($(this).val() == 'between') {
|
||||
enableAndShowExtraField(criteria_value,index_num);
|
||||
}
|
||||
else {
|
||||
disableAndHideExtraField(criteria_value, index_num);
|
||||
}
|
||||
}
|
||||
else {
|
||||
disableAndHideDateTimeDropdown(criteria_value, index_num);
|
||||
|
||||
}
|
||||
|
||||
if ($(this).val() == 'is in the range') {
|
||||
enableAndShowExtraField(criteria_value, index_num);
|
||||
} else {
|
||||
|
@ -439,6 +459,30 @@ function setupUI() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function enableAndShowDateTimeDropdown(valEle, index) {
|
||||
alert('enabled')
|
||||
var spanDatetime = valEle.nextAll("#datetime_select");
|
||||
spanDatetime.children('#sp_criteria_datetime_select_'+index).removeAttr("disabled");
|
||||
spanDatetime.show();
|
||||
|
||||
//make value input smaller since we have extra element now
|
||||
var criteria_val = $('#sp_criteria_value_'+index);
|
||||
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
|
||||
}
|
||||
|
||||
function disableAndHideDateTimeDropdown(valEle, index) {
|
||||
alert('disabled')
|
||||
var spanDatetime = valEle.nextAll("#datetime_select");
|
||||
spanDatetime.children('#sp_criteria_datetime_select_'+index).val("").attr("disabled", "disabled");
|
||||
spanDatetime.hide();
|
||||
|
||||
//make value input larger since we don't have extra field now
|
||||
var criteria_value = $('#sp_criteria_value_'+index);
|
||||
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
||||
}
|
||||
|
||||
|
||||
function enableAndShowExtraField(valEle, index) {
|
||||
var spanExtra = valEle.nextAll("#extra_criteria");
|
||||
spanExtra.children('#sp_criteria_extra_'+index).removeAttr("disabled");
|
||||
|
|
Loading…
Reference in New Issue