From cc1e013ff822aacccf9c8bf9c6c320f5a9f1f606 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii Date: Sun, 1 Apr 2018 13:48:22 +0300 Subject: [PATCH 1/4] Updated Magento_Rule rules.js file Added calendar initializaton for Conditional Rules when a rule is created for the 1st time --- app/code/Magento/Rule/view/adminhtml/web/rules.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Rule/view/adminhtml/web/rules.js b/app/code/Magento/Rule/view/adminhtml/web/rules.js index 5c4be367b9cb3..8127ae77c3a13 100644 --- a/app/code/Magento/Rule/view/adminhtml/web/rules.js +++ b/app/code/Magento/Rule/view/adminhtml/web/rules.js @@ -220,6 +220,8 @@ define([ var elem = Element.down(elemContainer, 'input.input-text'); + jQuery(elem).trigger('contentUpdated'); + if (elem) { elem.focus(); From ff4b005c34c541951d31691515f1e5c33c75798e Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Sat, 11 Aug 2018 20:42:10 +0300 Subject: [PATCH 2/4] Disabled autocomplete for datepicker (calendar) input field --- lib/web/mage/calendar.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js index 51ee9b3a8891a..90810ec511cfa 100644 --- a/lib/web/mage/calendar.js +++ b/lib/web/mage/calendar.js @@ -377,6 +377,9 @@ .addClass('v-middle') .text('') // Remove jQuery UI datepicker generated image .append('' + pickerButtonText + ''); + + $(element).attr('autocomplete', 'off'); + this._setCurrentDate(element); }, From 6c87bb36a666e17ba7f993b436cea1763699be02 Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Thu, 8 Nov 2018 12:51:38 +0200 Subject: [PATCH 3/4] magento/magento2:#4136 - Widget condition with unexpected character not preventing from saving - Restricted user to change date input value - Open datepicker popup once user click on the date to be changed --- .../Model/Condition/AbstractCondition.php | 3 +++ .../Magento/backend/web/css/styles-old.less | 20 +++++++++++++++++++ .../Data/Form/Element/AbstractElement.php | 1 + .../Framework/Data/Form/Element/Date.php | 2 +- .../Unit/Form/Element/AbstractElementTest.php | 1 + lib/web/mage/calendar.js | 2 -- 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php index 01e715f06a27f..529ad991f3a8c 100644 --- a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php +++ b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php @@ -630,6 +630,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', diff --git a/app/design/adminhtml/Magento/backend/web/css/styles-old.less b/app/design/adminhtml/Magento/backend/web/css/styles-old.less index b66fed0c0a09a..64502936cf1ff 100644 --- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less +++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less @@ -3840,6 +3840,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 { diff --git a/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php b/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php index 8db84c27980ad..2f4f72b7fd5f3 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php @@ -238,6 +238,7 @@ public function getHtmlAttributes() 'onchange', 'disabled', 'readonly', + 'autocomplete', 'tabindex', 'placeholder', 'data-form-part', diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Date.php b/lib/internal/Magento/Framework/Data/Form/Element/Date.php index ef85876521d23..54dc1e3ad5583 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Date.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Date.php @@ -147,7 +147,7 @@ public function getValueInstance() */ public function getElementHtml() { - $this->addClass('admin__control-text input-text'); + $this->addClass('admin__control-text input-text input-date'); $dateFormat = $this->getDateFormat() ?: $this->getFormat(); $timeFormat = $this->getTimeFormat(); if (empty($dateFormat)) { diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php index e29b1dcf441e4..a85c1f4aa450c 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php @@ -195,6 +195,7 @@ public function testGetHtmlAttributes() 'onchange', 'disabled', 'readonly', + 'autocomplete', 'tabindex', 'placeholder', 'data-form-part', diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js index 90810ec511cfa..7ddcb7e32f1b0 100644 --- a/lib/web/mage/calendar.js +++ b/lib/web/mage/calendar.js @@ -378,8 +378,6 @@ .text('') // Remove jQuery UI datepicker generated image .append('' + pickerButtonText + ''); - $(element).attr('autocomplete', 'off'); - this._setCurrentDate(element); }, From 1d1d061ad4eb8c664d9abf9aaa84e7b620a8dd9a Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Tue, 13 Nov 2018 09:30:40 +0200 Subject: [PATCH 4/4] magento/magento2:#4136 - Widget condition with unexpected character not preventing from saving - Added autocomplete option for calendar.js --- lib/web/mage/calendar.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js index 7ddcb7e32f1b0..4d09a5c0fbd84 100644 --- a/lib/web/mage/calendar.js +++ b/lib/web/mage/calendar.js @@ -66,6 +66,9 @@ * Widget calendar */ $.widget('mage.calendar', { + options: { + autoComplete: true + }, /** * Merge global options with options passed to widget invoke @@ -378,6 +381,8 @@ .text('') // Remove jQuery UI datepicker generated image .append('' + pickerButtonText + ''); + $(element).attr('autocomplete', this.options.autoComplete ? 'on' : 'off'); + this._setCurrentDate(element); },