[FIX] web: list view: reload only once on sort
Before this rev, the list view was reloaded twice when the user clicked on a column header to sort the records.
This commit is contained in:
@@ -329,10 +329,8 @@ var ListController = BasicController.extend({
|
||||
if (!data.groupedBy) {
|
||||
this.pager.updateState({current_min: 1});
|
||||
}
|
||||
this.model
|
||||
.setSort(data.id, event.data.name)
|
||||
.reload(data.id)
|
||||
.then(this.update.bind(this));
|
||||
this.model.setSort(data.id, event.data.name);
|
||||
this.update();
|
||||
},
|
||||
/**
|
||||
* In a grouped list view, each group can be clicked on to open/close them.
|
||||
|
||||
@@ -543,33 +543,46 @@ QUnit.module('Views', {
|
||||
});
|
||||
|
||||
QUnit.test('can sort records when clicking on header', function (assert) {
|
||||
assert.expect(6);
|
||||
assert.expect(9);
|
||||
|
||||
this.data.foo.fields.foo.sortable = true;
|
||||
|
||||
var nbSearchRead = 0;
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
arch: '<tree><field name="foo"/><field name="bar"/></tree>',
|
||||
mockRPC: function (route) {
|
||||
if (route === '/web/dataset/search_read') {
|
||||
nbSearchRead++;
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(nbSearchRead, 1, "should have done one search_read");
|
||||
assert.ok(list.$('tbody tr:first td:contains(yop)').length,
|
||||
"record 1 should be first");
|
||||
assert.ok(list.$('tbody tr:eq(3) td:contains(blip)').length,
|
||||
"record 3 should be first");
|
||||
|
||||
nbSearchRead = 0;
|
||||
list.$('thead th:contains(Foo)').click();
|
||||
|
||||
assert.strictEqual(nbSearchRead, 1, "should have done one search_read");
|
||||
assert.ok(list.$('tbody tr:first td:contains(blip)').length,
|
||||
"record 3 should be first");
|
||||
assert.ok(list.$('tbody tr:eq(3) td:contains(yop)').length,
|
||||
"record 1 should be first");
|
||||
|
||||
nbSearchRead = 0;
|
||||
list.$('thead th:contains(Foo)').click();
|
||||
assert.strictEqual(nbSearchRead, 1, "should have done one search_read");
|
||||
assert.ok(list.$('tbody tr:first td:contains(yop)').length,
|
||||
"record 3 should be first");
|
||||
assert.ok(list.$('tbody tr:eq(3) td:contains(blip)').length,
|
||||
"record 1 should be first");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user