Skip to content

Commit 0a8053d

Browse files
committed
Merge pull request #446 from magento-vanilla/PR
[Vanilla] Bug fixes
2 parents a644422 + 596daa7 commit 0a8053d

File tree

26 files changed

+290
-165
lines changed

26 files changed

+290
-165
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,19 +586,10 @@ protected function customizeAdvancedPricing()
586586
'componentType' => Modal::NAME,
587587
'dataScope' => '',
588588
'provider' => 'product_form.product_form_data_source',
589-
'onCancel' => 'actionCancel',
589+
'onCancel' => 'actionDone',
590590
'options' => [
591591
'title' => __('Advanced Pricing'),
592592
'buttons' => [
593-
[
594-
'text' => __('Cancel'),
595-
'actions' => [
596-
[
597-
'targetName' => '${ $.name }',
598-
'actionName' => 'actionCancel'
599-
]
600-
]
601-
],
602593
[
603594
'text' => __('Done'),
604595
'class' => 'action-primary',

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ protected function getOptionsGridConfig($sortOrder)
388388
],
389389
],
390390
'children' => [
391+
static::FIELD_SORT_ORDER_NAME => $this->getPositionFieldConfig(40),
391392
static::CONTAINER_COMMON_NAME => $this->getCommonContainerConfig(10),
392393
static::CONTAINER_TYPE_STATIC_NAME => $this->getStaticTypeContainerConfig(20),
393-
static::GRID_TYPE_SELECT_NAME => $this->getSelectTypeGridConfig(30),
394-
static::FIELD_SORT_ORDER_NAME => $this->getPositionFieldConfig(40)
394+
static::GRID_TYPE_SELECT_NAME => $this->getSelectTypeGridConfig(30)
395395
]
396396
],
397397
]

app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define([
2121
var self = this;
2222

2323
this.modal = $('<div id="create_new_attribute"/>').modal({
24-
title: $.mage.__('New Attribute'),
24+
title: $.mage.__('New Attribute'),
2525
type: 'slide',
2626
buttons: [],
2727
opened: function () {
@@ -32,7 +32,7 @@ define([
3232
});
3333
self.modal.append(self.iframe);
3434
self._changeIframeSize();
35-
$(window).off().on('resize', _.debounce(self._changeIframeSize.bind(self), 400));
35+
$(window).off().on('resize.modal', _.debounce(self._changeIframeSize.bind(self), 400));
3636
},
3737
closed: function () {
3838
var doc = self.iframe.get(0).document;
@@ -43,6 +43,7 @@ define([
4343
self.iframe.remove();
4444
}
4545
self.modal.data('modal').modal.remove();
46+
$(window).off('resize.modal');
4647
}
4748
});
4849
},

app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
*/
55

66
define([
7-
'Magento_Ui/js/dynamic-rows/dynamic-rows'
8-
], function (dynamicRows) {
7+
'Magento_Ui/js/dynamic-rows/dynamic-rows',
8+
'mageUtils'
9+
], function (DynamicRows, utils) {
910
'use strict';
1011

11-
return dynamicRows.extend({
12+
return DynamicRows.extend({
1213
defaults: {
1314
dataProvider: '',
1415
insertData: [],
@@ -44,10 +45,15 @@ define([
4445

4546
data.each(function (options) {
4647
options.options.each(function (option) {
47-
var path = this.dataScope + '.' + this.index + '.' + this.recordIterator;
48+
var path = this.dataScope + '.' + this.index + '.' + this.recordIterator,
49+
curOption = utils.copy(option);
4850

49-
this.source.set(path, option);
50-
this.addChild(option, false);
51+
if (curOption.hasOwnProperty('sort_order')) {
52+
delete curOption['sort_order'];
53+
}
54+
55+
this.source.set(path, curOption);
56+
this.addChild(curOption, false);
5157
}, this);
5258
}, this);
5359
},

app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@
1111
<item name="config" xsi:type="array">
1212
<item name="dataScope" xsi:type="string">data.product</item>
1313
<item name="provider" xsi:type="string">product_form.product_form_data_source</item>
14-
<item name="onCancel" xsi:type="string">actionCancel</item>
14+
<item name="onCancel" xsi:type="string">actionDone</item>
1515
<item name="options" xsi:type="array">
1616
<item name="title" xsi:type="string">Advanced Inventory</item>
1717
<item name="buttons" xsi:type="array">
1818
<item name="0" xsi:type="array">
19-
<item name="text" xsi:type="string">Cancel</item>
20-
<item name="actions" xsi:type="array">
21-
<item name="0" xsi:type="array">
22-
<item name="targetName" xsi:type="string">${ $.name }</item>
23-
<item name="actionName" xsi:type="string">actionCancel</item>
24-
</item>
25-
</item>
26-
</item>
27-
<item name="1" xsi:type="array">
2819
<item name="text" xsi:type="string">Done</item>
2920
<item name="class" xsi:type="string">action-primary</item>
3021
<item name="actions" xsi:type="array">

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ public function getFieldHtml()
181181
'value' => $this->getValue(),
182182
'date_format' => $this->getDateFormat(),
183183
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
184+
'years_range' => '-120y:c+nn',
185+
'max_date' => '-1d',
186+
'change_month' => 'true',
187+
'change_year' => 'true',
188+
'show_on' => 'both'
184189
]);
185190
return $this->dateElement->getHtml();
186191
}

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,8 @@
453453
<item name="config" xsi:type="array">
454454
<item name="dataType" xsi:type="string">boolean</item>
455455
<item name="formElement" xsi:type="string">checkbox</item>
456+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/boolean</item>
457+
<item name="elementTmpl" xsi:type="string">ui/form/element/checkbox</item>
456458
<item name="displayArea" xsi:type="string">head</item>
457459
<item name="uniqueNs" xsi:type="string">default_billing</item>
458460
<item name="uniqueProp" xsi:type="string">value</item>
@@ -462,10 +464,6 @@
462464
<item name="targetField" xsi:type="string">default_billing</item>
463465
<item name="referencedField" xsi:type="string">entity_id</item>
464466
</item>
465-
<item name="valueMap" xsi:type="array">
466-
<item name="true" xsi:type="boolean">true</item>
467-
<item name="false" xsi:type="string"/>
468-
</item>
469467
</item>
470468
</argument>
471469
</field>
@@ -474,6 +472,8 @@
474472
<item name="config" xsi:type="array">
475473
<item name="dataType" xsi:type="string">boolean</item>
476474
<item name="formElement" xsi:type="string">checkbox</item>
475+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/boolean</item>
476+
<item name="elementTmpl" xsi:type="string">ui/form/element/checkbox</item>
477477
<item name="displayArea" xsi:type="string">head</item>
478478
<item name="uniqueNs" xsi:type="string">default_shipping</item>
479479
<item name="uniqueProp" xsi:type="string">value</item>
@@ -483,10 +483,6 @@
483483
<item name="targetField" xsi:type="string">default_shipping</item>
484484
<item name="referencedField" xsi:type="string">entity_id</item>
485485
</item>
486-
<item name="valueMap" xsi:type="array">
487-
<item name="true" xsi:type="boolean">true</item>
488-
<item name="false" xsi:type="string"/>
489-
</item>
490486
</item>
491487
</argument>
492488
</field>

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dnd.js

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ define([
1212
], function (ko, $, _, Element) {
1313
'use strict';
1414

15-
var transformProp;
15+
var transformProp,
16+
isTouchDevice = typeof document.ontouchstart !== 'undefined';
1617

1718
/**
1819
* Get element context
@@ -33,14 +34,14 @@ define([
3334
vi = vendors.length,
3435
property;
3536

36-
if (typeof style.transform != 'undefined') {
37+
if (typeof style.transform !== 'undefined') {
3738
return 'transform';
3839
}
3940

4041
while (vi--) {
4142
property = vendors[vi] + base;
4243

43-
if (typeof style[property] != 'undefined') {
44+
if (typeof style[property] !== 'undefined') {
4445
return property;
4546
}
4647
}
@@ -49,7 +50,8 @@ define([
4950
return Element.extend({
5051
defaults: {
5152
rootSelector: '${ $.recordsProvider }:div.admin__field',
52-
tableSelector: '${ $.rootSelector } -> table.admin__dynamic-rows',
53+
tableClass: 'table.admin__dynamic-rows',
54+
tableSelector: '${ $.rootSelector } -> ${ $.tableClass }',
5355
separatorsClass: {
5456
top: '_dragover-top',
5557
bottom: '_dragover-bottom'
@@ -72,7 +74,6 @@ define([
7274
_.bindAll(
7375
this,
7476
'initTable',
75-
'mousedownHandler',
7677
'mousemoveHandler',
7778
'mouseupHandler'
7879
);
@@ -111,6 +112,20 @@ define([
111112
}
112113
},
113114

115+
/**
116+
* Init listens to start drag
117+
*
118+
* @param {Object} elem - DOM element
119+
* @param {Object} data - element data
120+
*/
121+
initListeners: function (elem, data) {
122+
if (isTouchDevice) {
123+
$(elem).on('touchstart', this.mousedownHandler.bind(this, data, elem));
124+
} else {
125+
$(elem).on('mousedown', this.mousedownHandler.bind(this, data, elem));
126+
}
127+
},
128+
114129
/**
115130
* Mouse down handler
116131
*
@@ -129,14 +144,21 @@ define([
129144
drEl.originRow = originRecord;
130145
drEl.instance = recordNode = this.processingStyles(recordNode, elem);
131146
drEl.instanceCtx = this.getRecord(originRecord[0]);
132-
drEl.eventMousedownY = event.pageY;
147+
drEl.eventMousedownY = isTouchDevice ? event.originalEvent.touches[0].pageY : event.pageY;
133148
drEl.minYpos =
134149
this.table.offset().top - originRecord.offset().top +
135150
this.table.outerHeight() - this.table.find('tbody').outerHeight();
136151
drEl.maxYpos = drEl.minYpos + this.table.find('tbody').outerHeight() - originRecord.outerHeight();
137152
this.tableWrapper.append(recordNode);
138-
this.body.bind('mousemove', this.mousemoveHandler);
139-
this.body.bind('mouseup', this.mouseupHandler);
153+
154+
if (isTouchDevice) {
155+
this.body.bind('touchmove', this.mousemoveHandler);
156+
this.body.bind('touchend', this.mouseupHandler);
157+
} else {
158+
this.body.bind('mousemove', this.mousemoveHandler);
159+
this.body.bind('mouseup', this.mouseupHandler);
160+
}
161+
140162
},
141163

142164
/**
@@ -146,12 +168,16 @@ define([
146168
*/
147169
mousemoveHandler: function (event) {
148170
var depEl = this.draggableElement,
149-
positionY = event.pageY - depEl.eventMousedownY,
171+
pageY = isTouchDevice ? event.originalEvent.touches[0].pageY : event.pageY,
172+
positionY = pageY - depEl.eventMousedownY,
150173
processingPositionY = positionY + 'px',
151174
processingMaxYpos = depEl.maxYpos + 'px',
152175
processingMinYpos = depEl.minYpos + 'px',
153176
depElement = this.getDepElement(depEl.instance, positionY);
154177

178+
event.stopPropagation();
179+
event.preventDefault();
180+
155181
if (depElement) {
156182
depEl.depElement ? depEl.depElement.elem.removeClass(depEl.depElement.className) : false;
157183
depEl.depElement = depElement;
@@ -187,8 +213,15 @@ define([
187213
}
188214

189215
drEl.originRow.removeClass(this.draggableElementClass);
190-
this.body.unbind('mousemove', this.mousemoveHandler);
191-
this.body.unbind('mouseup', this.mouseupHandler);
216+
217+
if (isTouchDevice) {
218+
this.body.unbind('touchmove', this.mousemoveHandler);
219+
this.body.unbind('touchend', this.mouseupHandler);
220+
} else {
221+
this.body.unbind('mousemove', this.mousemoveHandler);
222+
this.body.unbind('mouseup', this.mouseupHandler);
223+
}
224+
192225
drEl.instance.remove();
193226
this.draggableElement = {};
194227
},
@@ -218,7 +251,10 @@ define([
218251
*/
219252

220253
getDepElement: function (curInstance, position) {
221-
var recordsCollection = this.table.find('tbody > tr'),
254+
var tableSelector = this.tableClass + ' tr',
255+
recordsCollection = this.table.find('tbody > tr').filter(function (index, elem) {
256+
return !$(elem).parents(tableSelector).length;
257+
}),
222258
curInstancePositionTop = $(curInstance).position().top,
223259
curInstancePositionBottom = curInstancePositionTop + $(curInstance).height();
224260

app/code/Magento/Ui/view/base/web/js/form/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ define([
1515
*
1616
* @param {Object} data
1717
* @param {String} url
18+
* @param {String} selectorPrefix
19+
* @param {String} messagesClass
1820
* @returns {*}
1921
*/
20-
function beforeSave(data, url) {
22+
function beforeSave(data, url, selectorPrefix, messagesClass) {
2123
var save = $.Deferred();
2224

2325
data = utils.serialize(data);
@@ -58,7 +60,9 @@ define([
5860
* @param {String} msg
5961
*/
6062
insertMethod: function (msg) {
61-
$('.page-main-actions').after(msg);
63+
var $wrapper = $('<div/>').addClass(messagesClass).html(msg);
64+
65+
$('.page-main-actions', selectorPrefix).after($wrapper);
6266
}
6367
});
6468
});
@@ -84,7 +88,7 @@ define([
8488
var url = this.urls.beforeSave,
8589
save = this._save.bind(this, data, options);
8690

87-
beforeSave(data, url).then(save);
91+
beforeSave(data, url, this.selectorPrefix, this.messagesClass).then(save);
8892

8993
return this;
9094
},

app/code/Magento/Ui/view/base/web/js/form/components/insert-form.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ define([
5252
},
5353
imports: {
5454
toolbarSection: '${ $.toolbarContainer }:toolbarSection',
55-
prefix: '${ $.toolbarContainer }:rootSelector'
55+
prefix: '${ $.toolbarContainer }:rootSelector',
56+
messagesClass: '${ $.externalFormName }:messagesClass'
5657
},
5758
settings: {
5859
ajax: {
@@ -121,9 +122,10 @@ define([
121122
},
122123

123124
/**
124-
* Remove actions tollbar.
125+
* Remove actions toolbar.
125126
*/
126127
removeActions: function () {
128+
$(this.formHeader).siblings('.' + this.messagesClass).remove();
127129
$(this.formHeader).remove();
128130
this.formHeader = $();
129131
},

0 commit comments

Comments
 (0)