Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Forwardport] Fix for Issue #4136, MAGETWO-53440 #19390

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 77 additions & 5 deletions app/code/Magento/Rule/Model/Condition/AbstractCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ abstract class AbstractCondition extends \Magento\Framework\DataObject implement
protected $_layout;

/**
* Base name for hidden elements
* Base name for hidden elements.
*
* @var string
*/
protected $elementName = 'rule';
Expand Down Expand Up @@ -116,8 +117,9 @@ public function getDefaultOperatorInputByType()
}

/**
* Default operator options getter
* Provides all possible operator options
* Default operator options getter.
*
* Provides all possible operator options.
*
* @return array
*/
Expand All @@ -141,6 +143,8 @@ public function getDefaultOperatorOptions()
}

/**
* Get rule form.
*
* @return Form
*/
public function getForm()
Expand All @@ -149,6 +153,8 @@ public function getForm()
}

/**
* Get condition as array.
*
* @param array $arrAttributes
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand Down Expand Up @@ -195,6 +201,8 @@ public function getMappedSqlField()
}

/**
* Get condition as xml.
*
* @return string
*/
public function asXml()
Expand All @@ -214,6 +222,8 @@ public function asXml()
}

/**
* Load condition from array.
*
* @param array $arr
* @return $this
* @SuppressWarnings(PHPMD.NPathComplexity)
Expand All @@ -229,6 +239,8 @@ public function loadArray($arr)
}

/**
* Load condition from xml.
*
* @param string|array $xml
* @return $this
*/
Expand All @@ -242,6 +254,8 @@ public function loadXml($xml)
}

/**
* Load attribute options.
*
* @return $this
*/
public function loadAttributeOptions()
Expand All @@ -250,6 +264,8 @@ public function loadAttributeOptions()
}

/**
* Get attribute options.
*
* @return array
*/
public function getAttributeOptions()
Expand All @@ -258,6 +274,8 @@ public function getAttributeOptions()
}

/**
* Get attribute select options.
*
* @return array
*/
public function getAttributeSelectOptions()
Expand All @@ -270,6 +288,8 @@ public function getAttributeSelectOptions()
}

/**
* Get attribute name.
*
* @return string
*/
public function getAttributeName()
Expand All @@ -278,6 +298,8 @@ public function getAttributeName()
}

/**
* Load operator options.
*
* @return $this
*/
public function loadOperatorOptions()
Expand All @@ -300,6 +322,8 @@ public function getInputType()
}

/**
* Get operator select options.
*
* @return array
*/
public function getOperatorSelectOptions()
Expand All @@ -316,6 +340,8 @@ public function getOperatorSelectOptions()
}

/**
* Get operator name.
*
* @return array
*/
public function getOperatorName()
Expand All @@ -324,6 +350,8 @@ public function getOperatorName()
}

/**
* Load value options.
*
* @return $this
*/
public function loadValueOptions()
Expand All @@ -333,6 +361,8 @@ public function loadValueOptions()
}

/**
* Get value select options.
*
* @return array
*/
public function getValueSelectOptions()
Expand Down Expand Up @@ -380,6 +410,8 @@ public function isArrayOperatorType()
}

/**
* Get value.
*
* @return mixed
*/
public function getValue()
Expand All @@ -395,6 +427,8 @@ public function getValue()
}

/**
* Get value name.
*
* @return array|string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
Expand Down Expand Up @@ -446,6 +480,8 @@ public function getNewChildSelectOptions()
}

/**
* Get new child name.
*
* @return string
*/
public function getNewChildName()
Expand All @@ -454,6 +490,8 @@ public function getNewChildName()
}

/**
* Get this condition as html.
*
* @return string
*/
public function asHtml()
Expand All @@ -467,6 +505,8 @@ public function asHtml()
}

/**
* Get this condition with subconditions as html.
*
* @return string
*/
public function asHtmlRecursive()
Expand All @@ -475,6 +515,8 @@ public function asHtmlRecursive()
}

/**
* Get type element.
*
* @return AbstractElement
*/
public function getTypeElement()
Expand All @@ -493,6 +535,8 @@ public function getTypeElement()
}

/**
* Get type element html.
*
* @return string
*/
public function getTypeElementHtml()
Expand All @@ -501,6 +545,8 @@ public function getTypeElementHtml()
}

/**
* Get attribute element.
*
* @return $this
*/
public function getAttributeElement()
Expand Down Expand Up @@ -528,6 +574,8 @@ public function getAttributeElement()
}

/**
* Get attribute element html.
*
* @return string
*/
public function getAttributeElementHtml()
Expand All @@ -536,8 +584,9 @@ public function getAttributeElementHtml()
}

/**
* Retrieve Condition Operator element Instance
* If the operator value is empty - define first available operator value as default
* Retrieve Condition Operator element Instance.
*
* If the operator value is empty - define first available operator value as default.
*
* @return \Magento\Framework\Data\Form\Element\Select
*/
Expand Down Expand Up @@ -568,6 +617,8 @@ public function getOperatorElement()
}

/**
* Get operator element html.
*
* @return string
*/
public function getOperatorElementHtml()
Expand All @@ -587,6 +638,8 @@ public function getValueElementType()
}

/**
* Get value element renderer.
*
* @return \Magento\Rule\Block\Editable
*/
public function getValueElementRenderer()
Expand All @@ -598,6 +651,8 @@ public function getValueElementRenderer()
}

/**
* Get value element.
*
* @return $this
*/
public function getValueElement()
Expand All @@ -615,6 +670,9 @@ public function getValueElement()
// date format intentionally hard-coded
$elementParams['input_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['date_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['autocomplete'] = 'off';
$elementParams['readonly'] = 'true';
}
return $this->getForm()->addField(
$this->getPrefix() . '__' . $this->getId() . '__value',
Expand All @@ -626,6 +684,8 @@ public function getValueElement()
}

/**
* Get value element html.
*
* @return string
*/
public function getValueElementHtml()
Expand All @@ -634,6 +694,8 @@ public function getValueElementHtml()
}

/**
* Get add link html.
*
* @return string
*/
public function getAddLinkHtml()
Expand All @@ -643,6 +705,8 @@ public function getAddLinkHtml()
}

/**
* Get remove link html.
*
* @return string
*/
public function getRemoveLinkHtml()
Expand All @@ -655,6 +719,8 @@ public function getRemoveLinkHtml()
}

/**
* Get chooser container html.
*
* @return string
*/
public function getChooserContainerHtml()
Expand All @@ -664,6 +730,8 @@ public function getChooserContainerHtml()
}

/**
* Get this condition as string.
*
* @param string $format
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand All @@ -674,6 +742,8 @@ public function asString($format = '')
}

/**
* Get this condition with subconditions as string.
*
* @param int $level
* @return string
*/
Expand Down Expand Up @@ -816,6 +886,8 @@ protected function _compareValues($validatedValue, $value, $strict = true)
}

/**
* Validate model.
*
* @param \Magento\Framework\Model\AbstractModel $model
* @return bool
*/
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Rule/view/adminhtml/web/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ define([

var elem = Element.down(elemContainer, 'input.input-text');

jQuery(elem).trigger('contentUpdated');

if (elem) {
elem.focus();

Expand Down
20 changes: 20 additions & 0 deletions app/design/adminhtml/Magento/backend/web/css/styles-old.less
Original file line number Diff line number Diff line change
Expand Up @@ -3845,6 +3845,26 @@

.rule-param-edit .element {
display: inline;
position: relative;
}

.rule-param-edit .element input.input-date,
.rule-param-edit .element input.input-date[readonly] {
background-color: @color-white;
min-width: 140px;
width: 140px !important;
cursor: pointer;
text-align: center;
opacity: 1;
margin-right: 10px;
padding-right: 40px;

+ .ui-datepicker-trigger {
position: absolute;
width: 140px;
text-align: right;
left: 0;
}
}

.rule-param-edit .element .addafter {
Expand Down
Loading