Skip to content
Snippets Groups Projects
Commit 4094f755 authored by Mathieu Duckerts-Antoine's avatar Mathieu Duckerts-Antoine Committed by Adrien Dieudonne
Browse files

[FIX] web: groups of filters ordered correctly

In the filters menus, the order of groups of filters comming
from the search view arch was not always preserved in the filters menu.
This commit fixes that situation.
parent 8db9865c
Branches
Tags
No related merge requests found
......@@ -54,6 +54,7 @@ var GroupByMenuInterfaceMixin = {
defaultOptionId: groupby ? groupby.interval : false,
});
});
groupbys = _.sortBy(groupbys, 'description');
var groupByMenu = new GroupByMenu(this, groupbys, groupableFields, {headerStyle: 'primary'});
groupByMenu.insertAfter($node.find('div:first'));
},
......
......@@ -46,7 +46,7 @@ var DropdownMenu = Widget.extend({
el: {class: 'btn-group o_dropdown', attrs: {}},
mainButton: {class: 'o_dropdown_toggler_btn btn btn-sm btn-default dropdown-toggle'},
};
this.items = _.sortBy(items, 'groupId');
this.items = items;
_.each(this.items, this._prepareItem.bind(this));
},
......
......@@ -10,17 +10,17 @@ QUnit.module('Search View', {
partner: {
fields: {
date_field: {string: "Date", type: "date", store: true, sortable: true},
Birthday: {string: "Birthday", type: "date", store: true, sortable: true},
foo: {string: "Foo", type: "char"},
birthday: {string: "Birthday", type: "date", store: true, sortable: true},
foo: {string: "Foo", type: "char", store: true, sortable: true},
bar: {string: "Bar", type: "many2one", relation: 'partner'},
float_field: {string: "Float", type: "float"},
},
records: [
{id: 1, display_name: "First record", foo: "yop", bar: 2, date_field: "2017-01-25", Birthday: "1983-07-15", float_field: 1},
{id: 2, display_name: "Second record", foo: "blip", bar: 1, date_field: "2017-01-24", Birthday: "1982-06-04",float_field: 2},
{id: 3, display_name: "Third record", foo: "gnap", bar: 1, date_field: "2017-01-13", Birthday: "1985-09-13",float_field: 1.618},
{id: 4, display_name: "Fourth record", foo: "plop", bar: 2, date_field: "2017-02-25", Birthday: "1983-05-05",float_field: -1},
{id: 5, display_name: "Fifth record", foo: "zoup", bar: 2, date_field: "2016-01-25", Birthday: "1800-01-01",float_field: 13},
{id: 1, display_name: "First record", foo: "yop", bar: 2, date_field: "2017-01-25", birthday: "1983-07-15", float_field: 1},
{id: 2, display_name: "Second record", foo: "blip", bar: 1, date_field: "2017-01-24", birthday: "1982-06-04",float_field: 2},
{id: 3, display_name: "Third record", foo: "gnap", bar: 1, date_field: "2017-01-13", birthday: "1985-09-13",float_field: 1.618},
{id: 4, display_name: "Fourth record", foo: "plop", bar: 2, date_field: "2017-02-25", birthday: "1983-05-05",float_field: -1},
{id: 5, display_name: "Fifth record", foo: "zoup", bar: 2, date_field: "2016-01-25", birthday: "1800-01-01",float_field: 13},
],
},
pony: {
......@@ -69,7 +69,14 @@ QUnit.module('Search View', {
type: 'ir.actions.act_window',
views: [[2, 'list']],
search_view_id: [4, 'search'],
}
}, {
id: 6,
name: 'Partners Action 6',
res_model: 'partner',
type: 'ir.actions.act_window',
views: [[2, 'list']],
search_view_id: [5, 'search'],
},
];
this.archs = {
......@@ -105,6 +112,29 @@ QUnit.module('Search View', {
'<field name="date_field" string="Date"/>' +
'<filter string="Date" name="coolName" context="{\'group_by\': \'date_field:day\'}"/>' +
'</search>',
'partner,5,search': '<search>'+
'<filter string="1" name="coolName1" date="date_field"/>' +
'<separator/>' +
'<filter string="2" name="coolName2" date="birthday"/>' +
'<separator/>' +
'<filter string="3" name="coolName3" domain="[]"/>' +
'<separator/>' +
'<filter string="4" name="coolName4" domain="[]"/>' +
'<separator/>' +
'<filter string="5" name="coolName5" domain="[]"/>' +
'<separator/>' +
'<filter string="6" name="coolName6" domain="[]"/>' +
'<separator/>' +
'<filter string="7" name="coolName7" domain="[]"/>' +
'<separator/>' +
'<filter string="8" name="coolName8" domain="[]"/>' +
'<separator/>' +
'<filter string="9" name="coolName9" domain="[]"/>' +
'<separator/>' +
'<filter string="10" name="coolName10" domain="[]"/>' +
'<separator/>' +
'<filter string="11" name="coolName11" domain="[]"/>' +
'</search>',
};
},
}, function () {
......@@ -295,5 +325,23 @@ QUnit.module('Search View', {
'no facet should be in the search view');
actionManager.destroy();
});
QUnit.test('arch order of groups of filters preserved', function (assert) {
assert.expect(12);
var actionManager = createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
});
actionManager.doAction(6);
$('span.fa-filter').click();
assert.strictEqual($('.o_filters_menu .o_menu_item').length, 11);
for (var i = 0; i < 11; i++) {
assert.strictEqual($('.o_filters_menu .o_menu_item').eq(i).text().trim(), (i+1).toString());
}
actionManager.destroy();
});
});
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment