[FIX] web: menu items are now correctly sorted by alphabetical order
Menu items for measures list are now sorted by their 'string' value. We set that string in lowercase because uppercase/lowercase influences string comparison, so we are sure to compare always strings with the same case. This fix is effective for pivot view, cohord view and graph board. Task #1882576
This commit is contained in:
committed by
Adrien Dieudonne
parent
d39847a375
commit
49136a3f03
@@ -88,7 +88,7 @@ var GraphController = AbstractController.extend(GroupByMenuInterfaceMixin,{
|
||||
renderButtons: function ($node) {
|
||||
if ($node) {
|
||||
var context = {
|
||||
measures: _.sortBy(_.pairs(_.omit(this.measures, '__count__')), function (x) { return x[0]; }),
|
||||
measures: _.sortBy(_.pairs(_.omit(this.measures, '__count__')), function (x) { return x[1].string.toLowerCase(); }),
|
||||
};
|
||||
this.$buttons = $(qweb.render('GraphView.buttons', context));
|
||||
this.$measureList = this.$buttons.find('.o_graph_measures_list');
|
||||
|
||||
@@ -102,7 +102,7 @@ var PivotController = AbstractController.extend({
|
||||
*/
|
||||
renderButtons: function ($node) {
|
||||
if ($node) {
|
||||
var context = {measures: _.sortBy(_.pairs(_.omit(this.measures, '__count')), function(x) { return x[0]; })};
|
||||
var context = {measures: _.sortBy(_.pairs(_.omit(this.measures, '__count')), function (x) { return x[1].string.toLowerCase(); })};
|
||||
this.$buttons = $(QWeb.render('PivotView.buttons', context));
|
||||
this.$buttons.click(this._onButtonClick.bind(this));
|
||||
this.$buttons.find('button').tooltip();
|
||||
|
||||
@@ -1204,18 +1204,23 @@ QUnit.module('Views', {
|
||||
assert.expect(2);
|
||||
|
||||
var data = this.data;
|
||||
// It's important to compare capitalized and lowercased words
|
||||
// to be sure the sorting is effective with both of them
|
||||
data.partner.fields.bouh = {string: "bouh", type: "integer"};
|
||||
data.partner.fields.modd = {string: "modd", type: "integer"};
|
||||
data.partner.fields.zip = {string: "Zip", type: "integer"};
|
||||
|
||||
var pivot = createView({
|
||||
View: PivotView,
|
||||
model: "partner",
|
||||
data: data,
|
||||
arch: '<pivot>' +
|
||||
'<field name="zip" type="measure"/>' +
|
||||
'<field name="foo" type="measure"/>' +
|
||||
'<field name="bouh" type="measure"/>' +
|
||||
'<field name="modd" type="measure"/>' +
|
||||
'</pivot>',
|
||||
});
|
||||
|
||||
assert.strictEqual(pivot.$buttons.find('.o_pivot_measures_list .dropdown-item:first').data('field'), 'bouh',
|
||||
"Bouh should be the first measure");
|
||||
assert.strictEqual(pivot.$buttons.find('.o_pivot_measures_list .dropdown-item:last').data('field'), '__count',
|
||||
|
||||
Reference in New Issue
Block a user