Skip to content

Commit 764431b

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents 12ce282 + f4ae285 commit 764431b

File tree

25 files changed

+623
-239
lines changed

25 files changed

+623
-239
lines changed

app/code/Magento/Backend/view/adminhtml/web/template/dynamic-rows/cells/action-delete.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
-->
77
<button class="action-delete"
88
data-bind="
9-
click: function(){ $parents[1].deleteRecord($parent.index, $parent.recordId); },
9+
click: function(){ $parent.processingDeleteRecord($record().index, $record().recordId); },
1010
attr: {
11-
title: $parents[1].deleteButtonLabel
11+
title: $parent.deleteButtonLabel
1212
}
1313
">
14-
<span data-bind="text: $parents[1].deleteButtonLabel"></span>
14+
<span data-bind="text: $parent.deleteButtonLabel"></span>
1515
</button>

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,44 @@
3434
</label>
3535

3636
<div class="admin__field-control" data-role="grid-wrapper">
37+
<div class="admin__control-table-pagination" visible="!!$data.recordData().length">
38+
<div class="admin__data-grid-pager">
39+
<button class="action-previous" type="button" data-bind="attr: {title: $t('Previous Page')}, click: previousPage, disable: isFirst()"></button>
40+
<input class="admin__control-text" type="number" data-bind="attr: {id: ++ko.uid}, value: currentPage">
41+
<label class="admin__control-support-text" data-bind="attr: {for: ko.uid}, text: 'of ' + pages()"></label>
42+
<button class="action-next" type="button" data-bind="attr: {title: $t('Next Page')}, click: nextPage, disable: isLast()"></button>
43+
</div>
44+
</div>
3745
<div class="admin__control-table-wrapper">
3846
<table class="admin__dynamic-rows data-grid" data-role="grid">
3947
<thead if="element.columnsHeader">
4048
<tr>
4149
<th if="dndConfig.enabled"
4250
class="data-grid-draggable-row-cell"/>
4351

44-
<!-- ko foreach: {data: labels, as: 'item'} -->
45-
<th class="data-grid-th"
46-
text="item.label"
47-
visible="item.visible"
48-
disabled="item.disabled"
49-
css="$parent.setClasses(item)">
52+
<th repeat="foreach: labels, item: '$label'"
53+
class="data-grid-th"
54+
text="$label().label"
55+
visible="$label().visible"
56+
disable="$label().disabled"
57+
css="setClasses($label())">
5058
</th>
51-
<!-- /ko -->
5259
</tr>
5360
</thead>
5461

5562
<tbody data-bind="foreach: elems">
56-
<tr class="data-row"
57-
css="'_odd-row': $index() % 2">
58-
<td if="$parent.dndConfig.enabled"
63+
<tr repeat="foreach: elems, item: '$record'"
64+
class="data-row"
65+
css="'_odd-row': $index % 2">
66+
<td if="dndConfig.enabled"
5967
class="data-grid-draggable-row-cell"
60-
template="name: $parent.dndConfig.template, data: $parent.dnd"/>
68+
template="name: dndConfig.template, data: dnd"/>
6169

62-
<!-- ko foreach: { data: elems, as: 'elem'} -->
70+
<!-- ko fastForEach: { data: $record().elems, as: 'elem'} -->
6371
<td if="elem.template"
6472
visible="elem.visible"
65-
disabled="elem.disabled"
66-
css="$parents[1].setClasses(elem)"
73+
disable="elem.disabled"
74+
css="$parent.setClasses(elem)"
6775
template="elem.template"
6876
attr="'data-index': index"/>
6977
<!-- /ko -->

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ protected function getTextColumn($dataScope, $fit, Phrase $label, $sortOrder)
627627
'componentType' => Field::NAME,
628628
'formElement' => Input::NAME,
629629
'elementTmpl' => 'ui/dynamic-rows/cells/text',
630+
'component' => 'Magento_Ui/js/form/element/text',
630631
'dataType' => Text::NAME,
631632
'dataScope' => $dataScope,
632633
'fit' => $fit,

app/code/Magento/Catalog/view/adminhtml/web/template/form/element/action-delete.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<button class="action-delete"
88
attr="{'data-action': 'remove_row'}"
99
data-bind="
10-
click: function(){ $data.deleteRecord($parents); },
10+
click: function(){ $data.processingDeleteRecord($parents); },
1111
attr: {
12-
title: $parents[1].deleteButtonLabel
12+
title: $parent.deleteButtonLabel
1313
}
1414
">
15-
<span data-bind="text: $parents[1].deleteButtonLabel"></span>
15+
<span data-bind="text: $parent.deleteButtonLabel"></span>
1616
</button>

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ protected function getRows()
502502
'config' => [
503503
'componentType' => Form\Field::NAME,
504504
'formElement' => Form\Element\Input::NAME,
505+
'component' => 'Magento_Ui/js/form/element/text',
505506
'elementTmpl' => 'ui/dynamic-rows/cells/text',
506507
'dataType' => Form\Element\DataType\Text::NAME,
507508
'label' => __('Attributes'),

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ define([
7979
openModalWithGrid: function (rowIndex) {
8080
var productSource = this.source.get(this.dataScope + '.' + this.index + '.' + rowIndex),
8181
product = {
82-
'id': productSource.id,
83-
'attributes': productSource['configurable_attribute']
84-
};
82+
'id': productSource.id,
83+
'attributes': productSource['configurable_attribute']
84+
};
8585

8686
this.modalWithGrid().openModal();
8787
this.gridWithProducts().showGridChangeProduct(rowIndex, product);
@@ -110,7 +110,8 @@ define([
110110
* @param {Number} index - row index
111111
*/
112112
deleteRecord: function (index) {
113-
var tmpArray;
113+
var tmpArray,
114+
lastRecord;
114115

115116
this.reRender = false;
116117
tmpArray = this.getUnionInsertData();
@@ -120,8 +121,26 @@ define([
120121
this.source.set('data.attributes', []);
121122
}
122123

124+
if (parseInt(this.currentPage(), 10) === this.pages()) {
125+
lastRecord =
126+
_.findWhere(this.elems(), {
127+
index: this.startIndex + this.getChildItems().length - 1
128+
}) ||
129+
_.findWhere(this.elems(), {
130+
index: (this.startIndex + this.getChildItems().length - 1).toString()
131+
});
132+
133+
lastRecord.destroy();
134+
}
135+
123136
this.unionInsertData(tmpArray);
137+
138+
if (this.pages() < parseInt(this.currentPage(), 10)) {
139+
this.currentPage(this.pages());
140+
}
141+
124142
this.reRender = true;
143+
this.showSpinner(false);
125144
},
126145

127146
/**
@@ -175,44 +194,37 @@ define([
175194
* @param {Array} data
176195
*/
177196
processingUnionInsertData: function (data) {
178-
var dataInc = 0,
179-
diff = 0,
180-
dataCount,
197+
var dataCount,
181198
elemsCount,
182-
lastRecord;
199+
tmpData,
200+
path;
183201

184-
this.source.remove(this.dataScope + '.' + this.index);
185202
this.isEmpty(data.length === 0);
186203

187-
_.each(data, function (row) {
188-
_.each(row, function (value, key) {
189-
var path = this.dataScope + '.' + this.index + '.' + dataInc + '.' + key;
204+
tmpData = data.slice(this.pageSize * (this.currentPage() - 1),
205+
this.pageSize * (this.currentPage() - 1) + this.pageSize);
190206

191-
this.source.set(path, value);
192-
}, this);
207+
this.source.set(this.dataScope + '.' + this.index, []);
193208

194-
++dataInc;
209+
_.each(tmpData, function (row, index) {
210+
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + index);
211+
this.source.set(path, row);
195212
}, this);
196213

214+
this.source.set(this.dataScope + '.' + this.index, data);
215+
this.parsePagesData(data);
216+
197217
// Render
198218
dataCount = data.length;
199219
elemsCount = this.elems().length;
200220

201221
if (dataCount > elemsCount) {
202-
for (diff = dataCount - elemsCount; diff > 0; diff--) {
203-
this.addChild(data, false);
204-
}
222+
this.getChildItems().each(function (elemData, index) {
223+
this.addChild(elemData, this.startIndex + index);
224+
}, this);
205225
} else {
206-
for (diff = elemsCount - dataCount; diff > 0; diff--) {
207-
lastRecord =
208-
_.findWhere(this.elems(), {
209-
index: this.recordIterator - 1
210-
}) ||
211-
_.findWhere(this.elems(), {
212-
index: (this.recordIterator - 1).toString()
213-
});
214-
lastRecord.destroy();
215-
--this.recordIterator;
226+
for (elemsCount; elemsCount > dataCount; elemsCount--) {
227+
this.elems()[elemsCount - 1].destroy();
216228
}
217229
}
218230

app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/components/actions-list.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,36 @@
66
-->
77
<div class="action-select-wrap" data-bind="
88
css : {
9-
'_active' : $parents[1].actionsListOpened() === $parent.index
9+
'_active' : $parent.actionsListOpened() === $record().index
1010
},
11-
outerClick: $parents[1].closeList.bind($parents[1], $parent.index)"
11+
outerClick: $parent.closeList.bind($parent, $record().index)"
1212
>
13-
<button class="action-select" data-bind="click: function(){ $parents[1].toggleActionsList($parent.index); }">
13+
<button class="action-select" data-bind="click: function(){ $parent.toggleActionsList($record().index); }">
1414
<span data-bind="i18n: 'Select'"></span>
1515
</button>
16-
<ul class="action-menu _active" data-bind="css: {'_active': $parents[1].actionsListOpened() === $parent.index}">
16+
<ul class="action-menu _active" data-bind="css: {'_active': $parent.actionsListOpened() === $record().index}">
1717
<li>
1818
<a class="action-menu-item" data-bind="
1919
click: function(){
20-
$parents[1].openModalWithGrid($parent.index);
21-
$parents[1].closeList($parent.index);
20+
$parent.openModalWithGrid($record().index);
21+
$parent.closeList($record().index);
2222
}
2323
">Choose a different Product</a>
2424
</li>
2525
<li>
2626
<a class="action-menu-item" data-bind="
2727
text: $data.value() == 1 ? $t('Disable Product') : $t('Enable Product'),
2828
click: function(){
29-
$parents[1].toggleStatusProduct($parent.index);
30-
$parents[1].closeList($parent.index);
29+
$parent.toggleStatusProduct($record().index);
30+
$parent.closeList($record().index);
3131
}
3232
"></a>
3333
</li>
3434
<li>
3535
<a class="action-menu-item" data-bind="
3636
click: function(){
37-
$parents[1].deleteRecord($parent.index, $parent.recordId);
38-
$parents[1].closeList($parent.index);
37+
$parent.closeList($record().index);
38+
$parent.processingDeleteRecord($record().index, $record().recordId);
3939
},
4040
text: $t('Remove Product')
4141
"></a>

app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/variations/steps/summary-grid.html

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,24 @@
1717
<table class="data-grid data-grid-configurable">
1818
<thead>
1919
<tr>
20-
<!-- ko foreach: { data: grid.columns, as: 'column' } -->
21-
<th class="data-grid-th" data-bind="text: column"></th>
22-
<!-- /ko -->
20+
<th repeat="foreach: grid.columns, item: '$column'" class="data-grid-th" data-bind="text: $column"></th>
2321
</tr>
2422
</thead>
2523

2624
<tbody>
27-
<!-- ko foreach: { data: grid, as: 'product' } -->
28-
<tr>
29-
<!-- ko foreach: { data: product, as: 'property' } -->
30-
<!-- ko if: property && property.preview -->
31-
<td class="data-grid-thumbnail-cell">
25+
<tr repeat="foreach: grid, item: '$product'">
26+
<!-- ko fastForEach: { data: $product(), as: 'property' } -->
27+
<td if="property && property.preview" class="data-grid-thumbnail-cell">
3228
<div class="images-uploaded">
3329
<img data-bind="attr: {src: property.preview}"/>
3430
<span data-bind="text: property.images.length"></span>
3531
</div>
3632
</td>
37-
<!-- /ko -->
38-
<!-- ko ifnot: property && property.preview -->
39-
<td>
33+
<td ifnot="property && property.preview">
4034
<span data-bind='text: property'></span>
4135
</td>
4236
<!-- /ko -->
43-
<!-- /ko -->
4437
</tr>
45-
<!-- /ko -->
4638
</tbody>
4739
</table>
4840
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ define([
395395
* @returns {Object} draggable record context
396396
*/
397397
getRecord: function (elem) {
398-
return this.recordsCache()[getContext(elem).$index()];
398+
return this.recordsCache()[getContext(elem).$index];
399399
}
400400

401401
});

0 commit comments

Comments
 (0)