diff options
| author | Yannick Tivisse <yti@odoo.com> | 2019-07-24 11:23:14 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2019-07-26 08:47:03 +0000 |
| commit | 43c5a7d74fec25031e09bd97cc1c7d0960c895d6 (patch) | |
| tree | 42ca4096a4bc88f20b41d0825038cd011fcd8243 /addons/web/static/src | |
| parent | 0c07495391695cb5ea6019543d690e789338906c (diff) | |
[IMP] web: Implement confirm attr on kanban views
Purpose
=======
On a form view, it's possible to add a confirm attribute to open a
popup when clicking on a button.
This mechanism is not implemented on kanban views, and would imply to
create a specific wizard just for that in the referral application.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/kanban/kanban_controller.js | 31 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/kanban/kanban_record.js | 4 |
2 files changed, 25 insertions, 10 deletions
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 a6816b08b39..03d84bc5c8c 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -10,6 +10,7 @@ odoo.define('web.KanbanController', function (require) { var BasicController = require('web.BasicController'); var Context = require('web.Context'); var core = require('web.core'); +var Dialog = require('web.Dialog'); var Domain = require('web.Domain'); var view_dialogs = require('web.view_dialogs'); var viewUtils = require('web.viewUtils'); @@ -265,9 +266,11 @@ var KanbanController = BasicController.extend({ * @param {OdooEvent} ev */ _onButtonClicked: function (ev) { + var self = this; ev.stopPropagation(); var attrs = ev.data.attrs; var record = ev.data.record; + var def = Promise.resolve(); if (attrs.context) { attrs.context = new Context(attrs.context) .set_eval_context({ @@ -276,15 +279,25 @@ var KanbanController = BasicController.extend({ active_model: record.model, }); } - this.trigger_up('execute_action', { - action_data: attrs, - env: { - context: record.getContext(), - currentID: record.res_id, - model: record.model, - resIDs: record.res_ids, - }, - on_closed: this._reloadAfterButtonClick.bind(this, ev.target, ev.data), + if (attrs.confirm) { + def = new Promise(function (resolve, reject) { + Dialog.confirm(this, attrs.confirm, { + confirm_callback: resolve, + cancel_callback: reject, + }).on("closed", null, reject); + }); + } + def.then(function () { + self.trigger_up('execute_action', { + action_data: attrs, + env: { + context: record.getContext(), + currentID: record.res_id, + model: record.model, + resIDs: record.res_ids, + }, + on_closed: self._reloadAfterButtonClick.bind(self, ev.target, ev.data), + }); }); }, /** diff --git a/addons/web/static/src/js/views/kanban/kanban_record.js b/addons/web/static/src/js/views/kanban/kanban_record.js index 4dff9d74fe3..0ff5667c2a6 100644 --- a/addons/web/static/src/js/views/kanban/kanban_record.js +++ b/addons/web/static/src/js/views/kanban/kanban_record.js @@ -665,8 +665,10 @@ var KanbanRecord = Widget.extend({ break; case 'action': case 'object': + var attrs = $action.data(); + attrs.confirm = $action.attr('confirm'); this.trigger_up('button_clicked', { - attrs: $action.data(), + attrs: attrs, record: this.state, }); break; |
