Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a js bug where ui_component labels have the wrong sort order. #11846

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's would be nice if you will mark dynamic-rows-tier-price.js as deprecated, because it was created by mistake for fix same issue, but just for tier price functionality.


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));
});
});
});