Skip to content

Commit f7b8337

Browse files
authored
ENGCOM-3558: [Forwardport] Fix for Issue #4136, MAGETWO-53440 #19390
2 parents 89eca53 + 7447d5c commit f7b8337

File tree

9 files changed

+137
-15
lines changed

9 files changed

+137
-15
lines changed

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ abstract class AbstractCondition extends \Magento\Framework\DataObject implement
6262
protected $_layout;
6363

6464
/**
65-
* Base name for hidden elements
65+
* Base name for hidden elements.
66+
*
6667
* @var string
6768
*/
6869
protected $elementName = 'rule';
@@ -116,8 +117,9 @@ public function getDefaultOperatorInputByType()
116117
}
117118

118119
/**
119-
* Default operator options getter
120-
* Provides all possible operator options
120+
* Default operator options getter.
121+
*
122+
* Provides all possible operator options.
121123
*
122124
* @return array
123125
*/
@@ -141,6 +143,8 @@ public function getDefaultOperatorOptions()
141143
}
142144

143145
/**
146+
* Get rule form.
147+
*
144148
* @return Form
145149
*/
146150
public function getForm()
@@ -149,6 +153,8 @@ public function getForm()
149153
}
150154

151155
/**
156+
* Get condition as array.
157+
*
152158
* @param array $arrAttributes
153159
* @return array
154160
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -195,6 +201,8 @@ public function getMappedSqlField()
195201
}
196202

197203
/**
204+
* Get condition as xml.
205+
*
198206
* @return string
199207
*/
200208
public function asXml()
@@ -214,6 +222,8 @@ public function asXml()
214222
}
215223

216224
/**
225+
* Load condition from array.
226+
*
217227
* @param array $arr
218228
* @return $this
219229
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -229,6 +239,8 @@ public function loadArray($arr)
229239
}
230240

231241
/**
242+
* Load condition from xml.
243+
*
232244
* @param string|array $xml
233245
* @return $this
234246
*/
@@ -242,6 +254,8 @@ public function loadXml($xml)
242254
}
243255

244256
/**
257+
* Load attribute options.
258+
*
245259
* @return $this
246260
*/
247261
public function loadAttributeOptions()
@@ -250,6 +264,8 @@ public function loadAttributeOptions()
250264
}
251265

252266
/**
267+
* Get attribute options.
268+
*
253269
* @return array
254270
*/
255271
public function getAttributeOptions()
@@ -258,6 +274,8 @@ public function getAttributeOptions()
258274
}
259275

260276
/**
277+
* Get attribute select options.
278+
*
261279
* @return array
262280
*/
263281
public function getAttributeSelectOptions()
@@ -270,6 +288,8 @@ public function getAttributeSelectOptions()
270288
}
271289

272290
/**
291+
* Get attribute name.
292+
*
273293
* @return string
274294
*/
275295
public function getAttributeName()
@@ -278,6 +298,8 @@ public function getAttributeName()
278298
}
279299

280300
/**
301+
* Load operator options.
302+
*
281303
* @return $this
282304
*/
283305
public function loadOperatorOptions()
@@ -300,6 +322,8 @@ public function getInputType()
300322
}
301323

302324
/**
325+
* Get operator select options.
326+
*
303327
* @return array
304328
*/
305329
public function getOperatorSelectOptions()
@@ -316,6 +340,8 @@ public function getOperatorSelectOptions()
316340
}
317341

318342
/**
343+
* Get operator name.
344+
*
319345
* @return array
320346
*/
321347
public function getOperatorName()
@@ -324,6 +350,8 @@ public function getOperatorName()
324350
}
325351

326352
/**
353+
* Load value options.
354+
*
327355
* @return $this
328356
*/
329357
public function loadValueOptions()
@@ -333,6 +361,8 @@ public function loadValueOptions()
333361
}
334362

335363
/**
364+
* Get value select options.
365+
*
336366
* @return array
337367
*/
338368
public function getValueSelectOptions()
@@ -380,6 +410,8 @@ public function isArrayOperatorType()
380410
}
381411

382412
/**
413+
* Get value.
414+
*
383415
* @return mixed
384416
*/
385417
public function getValue()
@@ -395,6 +427,8 @@ public function getValue()
395427
}
396428

397429
/**
430+
* Get value name.
431+
*
398432
* @return array|string
399433
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
400434
*/
@@ -446,6 +480,8 @@ public function getNewChildSelectOptions()
446480
}
447481

448482
/**
483+
* Get new child name.
484+
*
449485
* @return string
450486
*/
451487
public function getNewChildName()
@@ -454,6 +490,8 @@ public function getNewChildName()
454490
}
455491

456492
/**
493+
* Get this condition as html.
494+
*
457495
* @return string
458496
*/
459497
public function asHtml()
@@ -467,6 +505,8 @@ public function asHtml()
467505
}
468506

469507
/**
508+
* Get this condition with subconditions as html.
509+
*
470510
* @return string
471511
*/
472512
public function asHtmlRecursive()
@@ -475,6 +515,8 @@ public function asHtmlRecursive()
475515
}
476516

477517
/**
518+
* Get type element.
519+
*
478520
* @return AbstractElement
479521
*/
480522
public function getTypeElement()
@@ -493,6 +535,8 @@ public function getTypeElement()
493535
}
494536

495537
/**
538+
* Get type element html.
539+
*
496540
* @return string
497541
*/
498542
public function getTypeElementHtml()
@@ -501,6 +545,8 @@ public function getTypeElementHtml()
501545
}
502546

503547
/**
548+
* Get attribute element.
549+
*
504550
* @return $this
505551
*/
506552
public function getAttributeElement()
@@ -528,6 +574,8 @@ public function getAttributeElement()
528574
}
529575

530576
/**
577+
* Get attribute element html.
578+
*
531579
* @return string
532580
*/
533581
public function getAttributeElementHtml()
@@ -536,8 +584,9 @@ public function getAttributeElementHtml()
536584
}
537585

538586
/**
539-
* Retrieve Condition Operator element Instance
540-
* If the operator value is empty - define first available operator value as default
587+
* Retrieve Condition Operator element Instance.
588+
*
589+
* If the operator value is empty - define first available operator value as default.
541590
*
542591
* @return \Magento\Framework\Data\Form\Element\Select
543592
*/
@@ -568,6 +617,8 @@ public function getOperatorElement()
568617
}
569618

570619
/**
620+
* Get operator element html.
621+
*
571622
* @return string
572623
*/
573624
public function getOperatorElementHtml()
@@ -587,6 +638,8 @@ public function getValueElementType()
587638
}
588639

589640
/**
641+
* Get value element renderer.
642+
*
590643
* @return \Magento\Rule\Block\Editable
591644
*/
592645
public function getValueElementRenderer()
@@ -598,6 +651,8 @@ public function getValueElementRenderer()
598651
}
599652

600653
/**
654+
* Get value element.
655+
*
601656
* @return $this
602657
*/
603658
public function getValueElement()
@@ -615,6 +670,9 @@ public function getValueElement()
615670
// date format intentionally hard-coded
616671
$elementParams['input_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
617672
$elementParams['date_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
673+
$elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
674+
$elementParams['autocomplete'] = 'off';
675+
$elementParams['readonly'] = 'true';
618676
}
619677
return $this->getForm()->addField(
620678
$this->getPrefix() . '__' . $this->getId() . '__value',
@@ -626,6 +684,8 @@ public function getValueElement()
626684
}
627685

628686
/**
687+
* Get value element html.
688+
*
629689
* @return string
630690
*/
631691
public function getValueElementHtml()
@@ -634,6 +694,8 @@ public function getValueElementHtml()
634694
}
635695

636696
/**
697+
* Get add link html.
698+
*
637699
* @return string
638700
*/
639701
public function getAddLinkHtml()
@@ -643,6 +705,8 @@ public function getAddLinkHtml()
643705
}
644706

645707
/**
708+
* Get remove link html.
709+
*
646710
* @return string
647711
*/
648712
public function getRemoveLinkHtml()
@@ -655,6 +719,8 @@ public function getRemoveLinkHtml()
655719
}
656720

657721
/**
722+
* Get chooser container html.
723+
*
658724
* @return string
659725
*/
660726
public function getChooserContainerHtml()
@@ -664,6 +730,8 @@ public function getChooserContainerHtml()
664730
}
665731

666732
/**
733+
* Get this condition as string.
734+
*
667735
* @param string $format
668736
* @return string
669737
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -674,6 +742,8 @@ public function asString($format = '')
674742
}
675743

676744
/**
745+
* Get this condition with subconditions as string.
746+
*
677747
* @param int $level
678748
* @return string
679749
*/
@@ -816,6 +886,8 @@ protected function _compareValues($validatedValue, $value, $strict = true)
816886
}
817887

818888
/**
889+
* Validate model.
890+
*
819891
* @param \Magento\Framework\Model\AbstractModel $model
820892
* @return bool
821893
*/

app/code/Magento/Rule/view/adminhtml/web/rules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ define([
220220

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

223+
jQuery(elem).trigger('contentUpdated');
224+
223225
if (elem) {
224226
elem.focus();
225227

app/design/adminhtml/Magento/backend/web/css/styles-old.less

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,26 @@
38453845

38463846
.rule-param-edit .element {
38473847
display: inline;
3848+
position: relative;
3849+
}
3850+
3851+
.rule-param-edit .element input.input-date,
3852+
.rule-param-edit .element input.input-date[readonly] {
3853+
background-color: @color-white;
3854+
min-width: 140px;
3855+
width: 140px !important;
3856+
cursor: pointer;
3857+
text-align: center;
3858+
opacity: 1;
3859+
margin-right: 10px;
3860+
padding-right: 40px;
3861+
3862+
+ .ui-datepicker-trigger {
3863+
position: absolute;
3864+
width: 140px;
3865+
text-align: right;
3866+
left: 0;
3867+
}
38483868
}
38493869

38503870
.rule-param-edit .element .addafter {

0 commit comments

Comments
 (0)