From c1bf1c6a5460611c2c1cfdbe736d3b1741c7300b Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 16 Apr 2018 15:06:10 +0530 Subject: [FIX] web: preserve new column order after creation When a user creates a new column in a kanban view, leave the action and comes back, the order is not preserved. With this commit, we force a call to resequence to ensure that the order does not change. --- .../static/src/js/views/kanban/kanban_controller.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 11d17a78fa9..5cc2653d6cf 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -107,6 +107,16 @@ var KanbanController = BasicController.extend({ var groupedByM2o = groupByField && (groupByField.type === 'many2one'); return groupedByM2o; }, + /** + * @param {string[]} ids + * @private + * @returns {Deferred} + */ + _resequenceColumns: function (ids) { + var state = this.model.get(this.handle, {raw: true}); + var model = state.fields[state.groupedBy[0]].relation; + return this.model.resequence(model, ids, this.handle); + }, /** * This method calls the server to ask for a resequence. Note that this * does not rerender the user interface, because in most case, the @@ -156,6 +166,10 @@ var KanbanController = BasicController.extend({ _onAddColumn: function (event) { var self = this; this.model.createGroup(event.data.value, this.handle).then(function () { + var state = self.model.get(self.handle, {raw: true}); + var ids = _.pluck(state.data, 'res_id').filter(_.isNumber); + return self._resequenceColumns(ids); + }).then(function () { return self.update({}, {reload: false}); }).then(function () { self._updateButtons(); @@ -428,9 +442,7 @@ var KanbanController = BasicController.extend({ */ _onResequenceColumn: function (event) { var self = this; - var state = this.model.get(this.handle, {raw: true}); - var model = state.fields[state.groupedBy[0]].relation; - this.model.resequence(model, event.data.ids, this.handle).then(function () { + this._resequenceColumns(event.data.ids).then(function () { self._updateEnv(); }); }, -- cgit v1.2.3 From fcc6e9e3be6c7079c93e4476d0fe340235432aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 24 Apr 2018 10:22:24 +0200 Subject: [FIX] web: correct docstring (was showing incorrect type) This is my mistake, I added the docstring without properly checking the type. --- addons/web/static/src/js/views/kanban/kanban_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 5cc2653d6cf..7d3da850a7e 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -108,7 +108,7 @@ var KanbanController = BasicController.extend({ return groupedByM2o; }, /** - * @param {string[]} ids + * @param {number[]} ids * @private * @returns {Deferred} */ -- cgit v1.2.3