Skip to content

Commit 37ea281

Browse files
committed
MAGETWO-63711: Provide functional support for option groups in grid column select
1 parent e3c955c commit 37ea281

File tree

1 file changed

+22
-0
lines changed
  • app/code/Magento/Ui/view/base/web/js/grid/columns

1 file changed

+22
-0
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/select.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,35 @@ define([
3333
return value + '';
3434
});
3535

36+
options = this.flatOptions(options);
37+
3638
options.forEach(function (item) {
3739
if (_.contains(values, item.value + '')) {
3840
label.push(item.label);
3941
}
4042
});
4143

4244
return label.join(', ');
45+
},
46+
47+
/**
48+
* Transformation tree options structure to liner array.
49+
*
50+
* @param {Array} options
51+
* @returns {Array}
52+
*/
53+
flatOptions: function (options) {
54+
var self = this;
55+
56+
return options.reduce(function (options, option) {
57+
if (_.isArray(option.value)) {
58+
options = options.concat(self.flatOptions(option.value));
59+
} else {
60+
options.push(option);
61+
}
62+
63+
return options;
64+
}, []);
4365
}
4466

4567
/*eslint-enable eqeqeq*/

0 commit comments

Comments
 (0)