[FIX] web: KanbanModel: don't allow nested groups

Nested groups is only for list views. In kanban, only the first
grouping level is taken into account.
This commit is contained in:
Aaron Bohy
2017-04-11 19:44:38 +02:00
parent 378d6813ff
commit 322b850ab6
2 changed files with 49 additions and 0 deletions
@@ -167,6 +167,25 @@ var KanbanModel = BasicModel.extend({
return parentID;
});
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* Ensures that there is no nested groups in Kanban (only the first grouping
* level is taken into account).
*
* @override
* @private
* @param {Object} list valid resource object
*/
_readGroup: function (list) {
if (list.groupedBy.length > 1) {
list.groupedBy = [list.groupedBy[0]];
}
return this._super.apply(this, arguments);
},
});
return KanbanModel;
@@ -155,6 +155,36 @@ QUnit.module('Views', {
});
});
QUnit.test('kanban model does not allow nested groups', function (assert) {
assert.expect(2);
var model = createModel({
Model: KanbanModel,
data: this.data,
mockRPC: function (route, args) {
if (args.method === 'read_group') {
assert.deepEqual(args.kwargs.groupby, ['product_id'],
"the second level of groupBy should have been removed");
}
return this._super.apply(this, arguments);
},
});
var params = _.extend(this.params, {
groupedBy: ['product_id', 'qux'],
fieldNames: ['foo'],
});
model.load(params).then(function (resultID) {
var state = model.get(resultID);
assert.deepEqual(state.groupedBy, ['product_id'],
"the second level of groupBy should have been removed");
model.destroy();
});
});
});
});