Skip to content

Commit 35222d1

Browse files
author
Olexandr Lysenko
committed
Merge branch 'develop' into bugfixes
2 parents 45b582b + d0495a9 commit 35222d1

File tree

20 files changed

+600
-92
lines changed

20 files changed

+600
-92
lines changed

app/code/Magento/Backend/view/adminhtml/web/template/dynamic-rows/grid.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</label>
3535

3636
<div class="admin__field-control" data-role="grid-wrapper">
37-
<div class="admin__control-table-pagination" visible="!!$data.recordData().length">
37+
<div class="admin__control-table-pagination" visible="!!element.getRecordCount()">
3838
<div class="admin__data-grid-pager">
3939
<button class="action-previous" type="button" data-bind="attr: {title: $t('Previous Page')}, click: previousPage, disable: isFirst()"></button>
4040
<input class="admin__control-text" type="number" data-bind="attr: {id: ++ko.uid}, value: currentPage">
@@ -51,10 +51,10 @@
5151

5252
<th repeat="foreach: labels, item: '$label'"
5353
class="data-grid-th"
54-
translate="$label().label"
5554
visible="$label().visible"
5655
disable="$label().disabled"
5756
css="setClasses($label())">
57+
<span translate="$label().label"/>
5858
</th>
5959
</tr>
6060
</thead>

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/Composite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function modifyData(array $data)
120120
'is_default' => ($productLink->getIsDefault()) ? '1' : '0',
121121
'selection_price_value' => $productLink->getPrice(),
122122
'selection_price_type' => $productLink->getPriceType(),
123-
'selection_qty' => (bool)$integerQty ? (int)$productLink->getQty() : $productLink->getQty(),
123+
'selection_qty' => $integerQty ? (int)$productLink->getQty() : $productLink->getQty(),
124124
'selection_can_change_qty' => $productLink->getCanChangeQuantity(),
125125
'selection_qty_is_integer' => (bool)$integerQty,
126126
'position' => $productLink->getPosition(),

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-option-qty.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,28 @@ define([
1111
return Abstract.extend({
1212
defaults: {
1313
valueUpdate: 'input',
14-
isInteger: true
14+
isInteger: true,
15+
validation: {
16+
'validate-number': true
17+
}
1518
},
1619

1720
/**
18-
* update event
21+
* @inheritdoc
1922
*/
2023
onUpdate: function () {
21-
this.validation['validate-number'] = true;
2224
this.validation['validate-digits'] = this.isInteger;
23-
this.validate();
25+
this._super();
26+
},
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
hasChanged: function () {
32+
var notEqual = this.value() !== this.initialValue.toString();
33+
34+
return !this.visible() ? false : notEqual;
2435
}
36+
2537
});
2638
});

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ protected function getOptionsGridConfig($sortOrder)
362362
'collapsibleHeader' => true,
363363
'sortOrder' => $sortOrder,
364364
'dataProvider' => static::CUSTOM_OPTIONS_LISTING,
365-
'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'],
365+
'imports' => ['insertData' => '${ $.provider }:${ $.dataProvider }'],
366366
],
367367
],
368368
],
@@ -478,8 +478,7 @@ protected function getImportOptionsModalConfig()
478478
'ns' => static::CUSTOM_OPTIONS_LISTING,
479479
'render_url' => $this->urlBuilder->getUrl('mui/index/render'),
480480
'realTimeLink' => true,
481-
'behaviourType' => 'edit',
482-
'externalFilterMode' => true,
481+
'externalFilterMode' => false,
483482
'currentProductId' => $this->locator->getProduct()->getId(),
484483
'dataLinks' => [
485484
'imports' => false,

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

Lines changed: 78 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,108 @@
44
*/
55

66
define([
7-
'Magento_Ui/js/dynamic-rows/dynamic-rows',
7+
'Magento_Ui/js/dynamic-rows/dynamic-rows-grid',
8+
'underscore',
89
'mageUtils'
9-
], function (DynamicRows, utils) {
10+
], function (DynamicRows, _, utils) {
1011
'use strict';
1112

13+
var maxId = 0,
14+
15+
/**
16+
* Stores max option_id value of the options from recordData once on initialization
17+
* @param {Array} data - array with records data
18+
*/
19+
initMaxId = function (data) {
20+
if (data && data.length) {
21+
maxId = ~~_.max(data, function (record) {
22+
return ~~record['option_id'];
23+
})['option_id'];
24+
}
25+
};
26+
1227
return DynamicRows.extend({
1328
defaults: {
14-
dataProvider: '',
15-
insertData: [],
16-
listens: {
17-
'insertData': 'processingInsertData'
18-
}
29+
mappingSettings: {
30+
enabled: false,
31+
distinct: false
32+
},
33+
update: true,
34+
map: {
35+
'option_id': 'option_id'
36+
},
37+
identificationProperty: 'option_id',
38+
identificationDRProperty: 'option_id'
1939
},
2040

21-
/**
22-
* Calls 'initObservable' of parent
23-
*
24-
* @returns {Object} Chainable.
25-
*/
26-
initObservable: function () {
27-
this._super()
28-
.observe([
29-
'insertData'
30-
]);
41+
/** @inheritdoc */
42+
initialize: function () {
43+
this._super();
44+
initMaxId(this.recordData());
3145

3246
return this;
3347
},
3448

35-
/**
36-
* Parsed data
37-
*
38-
* @param {Array} data - array with data
39-
* about selected records
40-
*/
49+
/** @inheritdoc */
4150
processingInsertData: function (data) {
42-
if (!data.length) {
43-
return false;
44-
}
51+
var options = [],
52+
currentOption;
4553

46-
data.each(function (options) {
47-
options.options.each(function (option) {
48-
var path = this.dataScope + '.' + this.index + '.' + this.recordIterator,
49-
curOption = utils.copy(option);
54+
if (!data) {
55+
return;
56+
}
57+
data.each(function (item) {
58+
if (!item.options) {
59+
return;
60+
}
61+
item.options.each(function (option) {
62+
currentOption = utils.copy(option);
5063

51-
if (curOption.hasOwnProperty('sort_order')) {
52-
delete curOption['sort_order'];
64+
if (currentOption.hasOwnProperty('sort_order')) {
65+
delete currentOption['sort_order'];
5366
}
67+
currentOption['option_id'] = ++maxId;
68+
options.push(currentOption);
69+
});
70+
});
5471

55-
this.source.set(path, curOption);
56-
this.addChild(curOption, false);
57-
}, this);
72+
if (!options.length) {
73+
return;
74+
}
75+
this.cacheGridData = options;
76+
options.each(function (opt) {
77+
this.mappingValue(opt);
5878
}, this);
79+
80+
this.insertData([]);
5981
},
6082

6183
/**
6284
* Set empty array to dataProvider
6385
*/
6486
clearDataProvider: function () {
6587
this.source.set(this.dataProvider, []);
88+
},
89+
90+
/** @inheritdoc */
91+
processingAddChild: function (ctx, index, prop) {
92+
if (ctx && !_.isNumber(ctx['option_id'])) {
93+
ctx['option_id'] = ++maxId;
94+
} else if (!ctx) {
95+
this.showSpinner(true);
96+
this.addChild(ctx, index, prop);
97+
98+
return;
99+
}
100+
101+
this._super(ctx, index, prop);
102+
},
103+
104+
/**
105+
* Mutes parent method
106+
*/
107+
updateInsertData: function () {
108+
return false;
66109
}
67110
});
68111
});

app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,4 +544,12 @@ public function setWriter(AbstractAdapter $writer)
544544

545545
return $this;
546546
}
547+
548+
/**
549+
* Clean cached values
550+
*/
551+
public function __destruct()
552+
{
553+
self::$attrCodes = null;
554+
}
547555
}

app/code/Magento/Ui/view/base/ui_component/etc/definition.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@
211211
<actionDelete class="Magento\Ui\Component\Form\Element\ActionDelete">
212212
<argument name="data" xsi:type="array">
213213
<item name="config" xsi:type="array">
214-
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
215-
<item name="elementTmpl" xsi:type="string">ui/dynamic-rows/cells/action-delete</item>
214+
<item name="component" xsi:type="string">Magento_Ui/js/dynamic-rows/action-delete</item>
216215
<item name="template" xsi:type="string">ui/dynamic-rows/cells/action-delete</item>
217216
</item>
218217
</argument>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Ui/js/form/element/abstract'
8+
], function (Abstract) {
9+
'use strict';
10+
11+
return Abstract.extend({
12+
defaults: {
13+
links: {
14+
value: false
15+
}
16+
},
17+
18+
/**
19+
* Delete record handler.
20+
*
21+
* @param {Number} index
22+
* @param {Number} id
23+
*/
24+
deleteRecord: function (index, id) {
25+
this.bubble('deleteRecord', index, id);
26+
}
27+
});
28+
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ define([
135135
drEl.instance = recordNode = this.processingStyles(recordNode, elem);
136136
drEl.instanceCtx = this.getRecord(originRecord[0]);
137137
drEl.eventMousedownY = isTouchDevice ? event.originalEvent.touches[0].pageY : event.pageY;
138-
drEl.minYpos = $table.offset().top - originRecord.offset().top + $table.find('thead').outerHeight();
138+
drEl.minYpos =
139+
$table.offset().top - originRecord.offset().top + $table.find('thead').outerHeight();
139140
drEl.maxYpos = drEl.minYpos + $table.find('tbody').outerHeight() - originRecord.outerHeight();
140141
$tableWrapper.append(recordNode);
141142

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

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ define([
2323
listens: {
2424
'insertData': 'processingInsertData',
2525
'recordData': 'initElements setToInsertData'
26+
},
27+
mappingSettings: {
28+
enabled: true,
29+
distinct: true
2630
}
2731
},
2832

@@ -100,10 +104,20 @@ define([
100104
* @param {String|Number} recordId
101105
*/
102106
deleteRecord: function (index, recordId) {
107+
this._super();
108+
109+
this.updateInsertData(recordId);
110+
},
111+
112+
/**
113+
* Updates insertData when record is deleted
114+
*
115+
* @param {String|Number} recordId
116+
*/
117+
updateInsertData: function (recordId) {
103118
var data = this.getElementData(this.insertData(), recordId),
104-
prop = this.map[this.identificationDRProperty];
119+
prop = this.map[this.identificationDRProperty];
105120

106-
this._super();
107121
this.insertData(_.reject(this.source.get(this.dataProvider), function (recordData) {
108122
return ~~recordData[prop] === ~~data[prop];
109123
}, this));
@@ -163,7 +177,7 @@ define([
163177
var changes = [],
164178
tmpObj = {};
165179

166-
if (data.length !== this.relatedData) {
180+
if (data.length !== this.relatedData.length) {
167181
data.forEach(function (obj) {
168182
tmpObj[this.identificationDRProperty] = obj[this.identificationDRProperty];
169183

@@ -210,21 +224,27 @@ define([
210224
var obj = {},
211225
tmpObj = {};
212226

213-
_.each(this.map, function (prop, index) {
214-
obj[index] = !_.isUndefined(data[prop]) ? data[prop] : '';
215-
}, this);
227+
if (this.mappingSettings.enabled) {
228+
_.each(this.map, function (prop, index) {
229+
obj[index] = !_.isUndefined(data[prop]) ? data[prop] : '';
230+
}, this);
231+
} else {
232+
obj = data;
233+
}
216234

217-
tmpObj[this.identificationDRProperty] = obj[this.identificationDRProperty];
235+
if (this.mappingSettings.distinct) {
236+
tmpObj[this.identificationDRProperty] = obj[this.identificationDRProperty];
237+
238+
if (_.findWhere(this.recordData(), tmpObj)) {
239+
return false;
240+
}
241+
}
218242

219243
if (!obj.hasOwnProperty(this.positionProvider)) {
220244
this.setMaxPosition();
221245
obj[this.positionProvider] = this.maxPosition;
222246
}
223247

224-
if (_.findWhere(this.recordData(), tmpObj)) {
225-
return false;
226-
}
227-
228248
this.source.set(this.dataScope + '.' + this.index + '.' + this.recordData().length, obj);
229249
},
230250

0 commit comments

Comments
 (0)