Skip to content

Commit

Permalink
⏫ Forwardport of #11846 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/11846.patch (created by @deiserh) based on commit(s):
  1. 0f948ac
  2. 6f70d06
  3. 8f52242
  4. c464951
  • Loading branch information
magento-engcom-team committed Jan 24, 2018
1 parent 8e77e2f commit ed833c4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ define([
], function (_, DynamicRows) {
'use strict';

/**
* @deprecated Parent method contains labels sorting.
* @see Magento_Ui/js/dynamic-rows/dynamic-rows
*/
return DynamicRows.extend({

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ define([
* Init header elements
*/
initHeader: function () {
var data;
var labels = [],
data;

if (!this.labels().length) {
_.each(this.childTemplate.children, function (cell) {
Expand All @@ -547,8 +548,9 @@ define([
sortOrder: cell.config.sortOrder
});

this.labels.push(data);
labels.push(data);
}, this);
this.labels(_.sortBy(labels, 'sortOrder'));
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,43 @@ define([
model.deleteRecord(1, 1);
expect(model.recordData()).toEqual([]);
});

it('"initHeader" sortOrder', function () {
var labels = [{
name: 'Name 1',
config: {
label: 'Label 1',
validation: false,
columnsHeaderClasses: '',
sortOrder: 10
}
}, {
name: 'Name 2',
config: {
label: 'Label 2',
validation: false,
columnsHeaderClasses: '',
sortOrder: 5
}
}],
result = [{
label: 'Label 2',
name: 'Name 2',
required: false,
columnsHeaderClasses: '',
sortOrder: 5
}, {
label: 'Label 1',
name: 'Name 1',
required: false,
columnsHeaderClasses: '',
sortOrder: 10
}];

model.childTemplate = {
children: labels
};
expect(JSON.stringify(model.labels())).toEqual(JSON.stringify(result));
});
});
});

0 comments on commit ed833c4

Please sign in to comment.