/** * render cell template. * * @param string $columnName * * @return string */ public function renderCellTemplate($columnName) { if ($columnName == 'attribute') { return $this->_getAttributeRenderer()->setName($this->_getCellInputElementName($columnName))->setTitle($columnName)->setExtraParams('style="width:160px"')->setOptions($this->getElement()->getValues())->toHtml(); } elseif ($columnName == 'conditions') { return $this->_getConditionsRenderer()->setName($this->_getCellInputElementName($columnName))->setTitle($columnName)->setExtraParams('style="width:160px"')->setOptions($this->condition->toOptionArray())->toHtml(); } elseif ($columnName == 'cvalue') { return $this->_getValueRenderer()->setName($this->_getCellInputElementName($columnName))->setTitle($columnName)->setExtraParams('style="width:160px"')->setOptions($this->value->toOptionArray())->toHtml(); } return parent::renderCellTemplate($columnName); }
/** * Execute method. */ public function execute() { $attribute = $this->getRequest()->getParam('attribute'); $conditionName = $this->getRequest()->getParam('condition'); $valueName = $this->getRequest()->getParam('value'); if ($attribute && $conditionName && $valueName) { $type = $this->ruleType->getInputType($attribute); $conditionOptions = $this->ruleCondition->getInputTypeOptions($type); $response['condition'] = $this->_getOptionHtml('conditions', $conditionName, $conditionOptions); $elmType = $this->ruleValue->getValueElementType($attribute); if ($elmType == 'select') { $valueOptions = $this->ruleValue->getValueSelectOptions($attribute); $response['cvalue'] = $this->_getOptionHtml('cvalue', $valueName, $valueOptions); } elseif ($elmType == 'text') { $html = "<input style='width:160px' title='cvalue' class='' id='' name={$valueName} />"; $response['cvalue'] = $html; } $this->http->getHeaders()->clearHeaders(); $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response)); } }
/** * Execute method. * * @return $this */ public function execute() { $id = $this->getRequest()->getParam('ruleid'); $attribute = $this->getRequest()->getParam('attribute'); $arrayKey = $this->getRequest()->getParam('arraykey'); $conditionName = $this->getRequest()->getParam('condition'); $valueName = $this->getRequest()->getParam('value'); if ($arrayKey && $id && $attribute && $conditionName && $valueName) { $rule = $this->rulesFactory->create()->load($id); //rule not found if (!$rule->getId()) { $this->http->getHeaders()->clearHeaders(); return $this->http->setHeader('Content-Type', 'application/json')->setBody('Rule not found!'); } $conditions = $rule->getCondition(); $condition = $conditions[$arrayKey]; $selectedConditions = $condition['conditions']; $selectedValues = $condition['cvalue']; $type = $this->ruleType->getInputType($attribute); $conditionOptions = $this->ruleCondition->getInputTypeOptions($type); $response['condition'] = str_replace('value="' . $selectedConditions . '"', 'value="' . $selectedConditions . '"' . 'selected="selected"', $this->getOptionHtml('conditions', $conditionName, $conditionOptions)); $elmType = $this->ruleValue->getValueElementType($attribute); if ($elmType == 'select' or $selectedConditions == 'null') { $isEmpty = false; if ($selectedConditions == 'null') { $isEmpty = true; } $valueOptions = $this->ruleValue->getValueSelectOptions($attribute, $isEmpty); $response['cvalue'] = str_replace('value="' . $selectedValues . '"', 'value="' . $selectedValues . '"' . 'selected="selected"', $this->getOptionHtml('cvalue', $valueName, $valueOptions)); } elseif ($elmType == 'text') { $html = "<input style='width:160px' title='cvalue' name='{$valueName}' value='{$selectedValues}'/>"; $response['cvalue'] = $html; } $this->http->getHeaders()->clearHeaders(); $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response)); } }