Skip to content

Commit 8903f8d

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-59974
2 parents 3b7f4d2 + f6d1b99 commit 8903f8d

File tree

11 files changed

+228
-177
lines changed

11 files changed

+228
-177
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,6 @@ protected function customizeNameListeners(array $meta)
315315
$importsConfig = [
316316
'mask' => $this->locator->getStore()->getConfig('catalog/fields_masks/' . $listener),
317317
'component' => 'Magento_Catalog/js/components/import-handler',
318-
'imports' => [
319-
'handleNameChanges' => '${$.provider}:data.product.name',
320-
'handleDescriptionChanges' => '${$.provider}:data.product.description',
321-
'handleSkuChanges' => '${$.provider}:data.product.sku',
322-
'handleColorChanges' => '${$.provider}:data.product.color',
323-
'handleCountryChanges' => '${$.provider}:data.product.country_of_manufacture',
324-
'handleGenderChanges' => '${$.provider}:data.product.gender',
325-
'handleMaterialChanges' => '${$.provider}:data.product.material',
326-
'handleShortDescriptionChanges' => '${$.provider}:data.product.short_description',
327-
'handleSizeChanges' => '${$.provider}:data.product.size'
328-
],
329318
'allowImport' => !$this->locator->getProduct()->getId(),
330319
];
331320

app/code/Magento/Catalog/view/adminhtml/web/js/components/import-handler.js

Lines changed: 51 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -4,148 +4,78 @@
44
*/
55

66
define([
7+
'Magento_Ui/js/form/element/abstract',
78
'underscore',
8-
'Magento_Ui/js/form/element/textarea'
9-
], function (_, Textarea) {
9+
'uiRegistry'
10+
], function (Abstract, _, registry) {
1011
'use strict';
1112

12-
return Textarea.extend({
13+
return Abstract.extend({
1314
defaults: {
1415
allowImport: true,
1516
autoImportIfEmpty: false,
16-
values: {
17-
'name': '',
18-
'description': '',
19-
'sku': '',
20-
'color': '',
21-
'country_of_manufacture': '',
22-
'gender': '',
23-
'material': '',
24-
'short_description': '',
25-
'size': ''
26-
},
27-
valueUpdate: 'input',
28-
mask: ''
17+
values: {},
18+
mask: '',
19+
queryTemplate: 'ns = ${ $.ns }, index = '
2920
},
3021

31-
/**
32-
* Handle name value changes, if it's allowed
33-
*
34-
* @param {String} newValue
35-
*/
36-
handleNameChanges: function (newValue) {
37-
this.values.name = newValue;
38-
this.updateValue();
39-
},
40-
41-
/**
42-
* Handle description value changes, if it's allowed
43-
*
44-
* @param {String} newValue
45-
*/
46-
handleDescriptionChanges: function (newValue) {
47-
this.values.description = newValue;
48-
this.updateValue();
49-
},
22+
/** @inheritdoc */
23+
initialize: function () {
24+
this._super();
5025

51-
/**
52-
* Handle sku value changes, if it's allowed
53-
*
54-
* @param {String} newValue
55-
*/
56-
handleSkuChanges: function (newValue) {
57-
if (this.code !== 'sku') {
58-
this.values.sku = newValue;
59-
this.updateValue();
26+
if (this.allowImport) {
27+
this.setHandlers();
6028
}
6129
},
6230

6331
/**
64-
* Handle color value changes, if it's allowed
65-
*
66-
* @param {String} newValue
67-
*/
68-
handleColorChanges: function (newValue) {
69-
this.values.color = newValue;
70-
this.updateValue();
71-
},
72-
73-
/**
74-
* Handle country value changes, if it's allowed
75-
*
76-
* @param {String} newValue
32+
* Split mask placeholder and attach events to placeholder fields.
7733
*/
78-
handleCountryChanges: function (newValue) {
79-
this.values.country = newValue;
80-
this.updateValue();
81-
},
34+
setHandlers: function () {
35+
var str = this.mask || '',
36+
placeholders;
8237

83-
/**
84-
* Handle gender value changes, if it's allowed
85-
*
86-
* @param {String} newValue
87-
*/
88-
handleGenderChanges: function (newValue) {
89-
this.values.gender = newValue;
90-
this.updateValue();
91-
},
38+
placeholders = str.match(/{{(.*?)}}/g); // Get placeholders
9239

93-
/**
94-
* Handle material value changes, if it's allowed
95-
*
96-
* @param {String} newValue
97-
*/
98-
handleMaterialChanges: function (newValue) {
99-
this.values.material = newValue;
100-
this.updateValue();
101-
},
40+
_.each(placeholders, function (placeholder) {
41+
placeholder = placeholder.replace(/[{{}}]/g, ''); // Remove curly braces
10242

103-
/**
104-
* Handle short description value changes, if it's allowed
105-
*
106-
* @param {String} newValue
107-
*/
108-
handleShortDescriptionChanges: function (newValue) {
109-
this.values['short_description'] = newValue;
110-
this.updateValue();
43+
registry.get(this.queryTemplate + placeholder, function (component) {
44+
this.values[placeholder] = component.getPreview();
45+
component.on('value', this.updateValue.bind(this, placeholder, component));
46+
component.valueUpdate = 'keyup';
47+
}.bind(this));
48+
}, this);
11149
},
11250

11351
/**
114-
* Handle size value changes, if it's allowed
52+
* Update field with mask value, if it's allowed.
11553
*
116-
* @param {String} newValue
54+
* @param {Object} placeholder
55+
* @param {Object} component
11756
*/
118-
handleSizeChanges: function (newValue) {
119-
this.values.size = newValue;
120-
this.updateValue();
121-
},
57+
updateValue: function (placeholder, component) {
58+
var string = this.mask || '',
59+
nonEmptyValueFlag = false;
12260

123-
/**
124-
* Update field value, if it's allowed
125-
*/
126-
updateValue: function () {
127-
var str = this.mask || '',
128-
nonEmptyValueFlag = false,
129-
tmpElement;
61+
if (placeholder) {
62+
this.values[placeholder] = component.getPreview() || '';
63+
}
13064

13165
if (!this.allowImport) {
13266
return;
13367
}
13468

135-
if (str) {
136-
_.each(this.values, function (propertyValue, propertyName) {
137-
str = str.replace('{{' + propertyName + '}}', propertyValue);
138-
nonEmptyValueFlag = nonEmptyValueFlag || !!propertyValue;
139-
});
140-
}
141-
142-
// strip tags
143-
tmpElement = document.createElement('div');
144-
tmpElement.innerHTML = str;
145-
str = tmpElement.textContent || tmpElement.innerText || '';
69+
_.each(this.values, function (propertyValue, propertyName) {
70+
string = string.replace('{{' + propertyName + '}}', propertyValue);
71+
nonEmptyValueFlag = nonEmptyValueFlag || !!propertyValue;
72+
});
14673

14774
if (nonEmptyValueFlag) {
148-
this.value(str);
75+
string = string.replace(/(<([^>]+)>)/ig, ''); // Remove html tags
76+
this.value(string);
77+
} else {
78+
this.value('');
14979
}
15080
},
15181

@@ -169,13 +99,20 @@ define([
16999
* and disallow/allow import value
170100
*/
171101
userChanges: function () {
102+
103+
/**
104+
* As userChanges is called before updateValue,
105+
* we forced to get value from component by reference
106+
*/
107+
var actualValue = arguments[1].currentTarget.value;
108+
172109
this._super();
173110

174-
if (this.value() === '') {
111+
if (actualValue === '') {
175112
this.allowImport = true;
176113

177114
if (this.autoImportIfEmpty) {
178-
this.updateValue();
115+
this.updateValue(null, null);
179116
}
180117
} else {
181118
this.allowImport = false;

app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,6 @@
2828
</block>
2929
<block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
3030
<block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
31-
<!-- The following code shows how to set your own pager increments -->
32-
<!--
33-
<action method="setDefaultListPerPage">
34-
<argument name="limit" xsi:type="string">4</argument>
35-
</action>
36-
<action method="setDefaultGridPerPage">
37-
<argument name="limit" xsi:type="string">3</argument>
38-
</action>
39-
<action method="addPagerLimit">
40-
<argument name="mode" xsi:type="string">list</argument>
41-
<argument name="limit" xsi:type="string">2</argument>
42-
</action>
43-
<action method="addPagerLimit">
44-
<argument name="mode" xsi:type="string">list</argument>
45-
<argument name="limit" xsi:type="string">4</argument>
46-
</action>
47-
<action method="addPagerLimit">
48-
<argument name="mode" xsi:type="string">list</argument>
49-
<argument name="limit" xsi:type="string">6</argument>
50-
</action>
51-
<action method="addPagerLimit">
52-
<argument name="mode" xsi:type="string">list</argument>
53-
<argument name="limit" xsi:type="string">8</argument>
54-
</action>
55-
<action method="addPagerLimit" translate="label">
56-
<argument name="mode" xsi:type="string">list</argument>
57-
<argument name="limit" xsi:type="string">all</argument>
58-
<argument name="label" xsi:type="string">All</argument>
59-
</action>
60-
<action method="addPagerLimit">
61-
<argument name="mode" xsi:type="string">grid</argument>
62-
<argument name="limit" xsi:type="string">3</argument>
63-
</action>
64-
<action method="addPagerLimit">
65-
<argument name="mode" xsi:type="string">grid</argument>
66-
<argument name="limit" xsi:type="string">6</argument>
67-
</action>
68-
<action method="addPagerLimit">
69-
<argument name="mode" xsi:type="string">grid</argument>
70-
<argument name="limit" xsi:type="string">9</argument>
71-
</action>
72-
<action method="addPagerLimit" translate="label">
73-
<argument name="mode" xsi:type="string">grid</argument>
74-
<argument name="limit" xsi:type="string">all</argument>
75-
<argument name="label" xsi:type="string">All</argument>
76-
</action>
77-
-->
7831
</block>
7932
<action method="setToolbarBlockName">
8033
<argument name="name" xsi:type="string">product_list_toolbar</argument>

app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
<!-- ko foreach: getRegion('additional-login-form-fields') -->
7979
<!-- ko template: getTemplate() --><!-- /ko -->
8080
<!-- /ko -->
81-
</div>
8281
<div class="actions-toolbar">
8382
<input name="context" type="hidden" value="checkout" />
8483
<div class="primary">

app/code/Magento/Review/view/frontend/templates/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<?php if ($block->getRatings() && $block->getRatings()->getSize()): ?>
2121
<span id="input-message-box"></span>
2222
<fieldset class="field required review-field-ratings">
23-
<legend class="label"><span><?php echo $block->escapeHtml(__('Your Rating')) ?><span></legend><br/>
23+
<legend class="label"><span><?php echo $block->escapeHtml(__('Your Rating')) ?></span></legend><br/>
2424
<div class="control">
2525
<div class="nested" id="product-review-table">
2626
<?php foreach ($block->getRatings() as $_rating): ?>

app/code/Magento/Ui/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Overview
22
## Purpose of module
33

4-
The Magento\Ui module introduces a set of common UI components, which could be easily used and configured via layout XML files.
4+
The Magento\Ui module introduces a set of common UI components, which could be used and configured via layout XML files.
55

66
# Deployment
77
## System requirements

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ define([
5151

5252
observable() && $(el).datepicker(
5353
'setDate',
54-
moment(observable(), utils.normalizeDate(config.options.dateFormat)).toDate()
54+
moment(
55+
observable(),
56+
utils.normalizeDate(
57+
options.dateFormat + (options.showsTime ? ' ' + options.timeFormat : '')
58+
)
59+
).toDate()
5560
);
5661

5762
$(el).blur();

app/design/frontend/Magento/blank/etc/view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
</var>
228228
<var name="options">
229229
<var name="options">
230-
<var name="navigation">dots</var>
230+
<var name="nav">dots</var>
231231
</var>
232232
</var>
233233
</var>

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,16 @@
3434
<item name="inherit" xsi:type="number">1</item>
3535
</field>
3636
</dataset>
37+
<dataset name="attribute_product_mask_sku">
38+
<field name="catalog/fields_masks/sku" xsi:type="array">
39+
<item name="value" xsi:type="string">{{name}} {{country_of_manufacture}}</item>
40+
</field>
41+
</dataset>
42+
<dataset name="attribute_product_mask_sku_rollback">
43+
<field name="catalog/fields_masks/sku" xsi:type="array">
44+
<item name="value" xsi:type="string">{{name}}</item>
45+
<item name="inherit" xsi:type="number">1</item>
46+
</field>
47+
</dataset>
3748
</repository>
3849
</config>

0 commit comments

Comments
 (0)