diff options
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/list/list_controller.js | 20 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 11 |
2 files changed, 26 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index bd0322c92b0..f99ec19dea7 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -396,6 +396,7 @@ var ListController = BasicController.extend({ var nbInvalid = recordIds.length - validRecordIds.length; return new Promise(function (resolve, reject) { + var dialog; var rejectAndDiscard = function () { self.model.discardChanges(recordId); return self._confirmSave(recordId).then(reject); @@ -411,24 +412,33 @@ var ListController = BasicController.extend({ _t("Do you want to set the value on the %d valid selected records? (%d invalid)"), validRecordIds.length, nbInvalid); } - Dialog.confirm(self, message, { + dialog = Dialog.confirm(self, message, { confirm_callback: function () { - self.model.saveRecords(recordId, validRecordIds, fieldName) + return self.model.saveRecords(recordId, validRecordIds, fieldName) .then(function () { self._updateButtons('readonly'); var state = self.model.get(self.handle); - self.renderer.updateState(state, {}); - resolve(Object.keys(changes)); + return self.renderer.updateState(state, {}).then(function () { + resolve(Object.keys(changes)); + }); }) .guardedCatch(rejectAndDiscard); }, cancel_callback: rejectAndDiscard, }); } else { - Dialog.alert(self, _t("No valid record to save"), { + dialog = Dialog.alert(self, _t("No valid record to save"), { confirm_callback: rejectAndDiscard, }); } + dialog.on('closed', self, function () { + // we need to wait for the dialog to be actually closed, but + // the 'closed' event is triggered just before, and it prevents + // from focussing the cell + Promise.resolve().then(function () { + self.renderer.focusCell(recordId, node); + }); + }); }); }, /** diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index cd67feb0b34..b23b7a85e0a 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -277,6 +277,17 @@ ListRenderer.include({ this._selectCell(rowIndex, 0); }, /** + * Gives focus to a specific cell, given its row and its related column. + * + * @param {string} recordId + * @param {Object} column + */ + focusCell: function (recordId, column) { + var $row = this._getRow(recordId); + var cellIndex = this.columns.indexOf(column); + $row.find('.o_data_cell')[cellIndex].focus(); + }, + /** * Returns the recordID associated to the line which is currently in edition * or null if there is no line in edition. * |
