From 57b48602fb7afa5d0539e8d0caa8d1e10c3910e5 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 2 Sep 2014 17:32:37 +0200 Subject: [FIX] web: chain close action on wizard confirm If a wizard has several steps, or laucnh a second wizard, the view from where has been loaded the initial wizard is finally reloaded --- addons/web/static/src/js/views.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 78accfd4da4..b59e86b2192 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -373,6 +373,10 @@ instance.web.ActionManager = instance.web.Widget.extend({ } var widget = executor.widget(); if (executor.action.target === 'new') { + var pre_dialog = this.dialog; + if (pre_dialog){ + pre_dialog.off('closing', null, pre_dialog.on_close); + } if (this.dialog_widget && !this.dialog_widget.isDestroyed()) { this.dialog_widget.destroy(); } @@ -380,7 +384,13 @@ instance.web.ActionManager = instance.web.Widget.extend({ this.dialog = new instance.web.Dialog(this, { dialogClass: executor.klass, }); - this.dialog.on("closing", null, options.on_close); + this.dialog.on_close = function(){ + options.on_close.apply(null, arguments); + if (pre_dialog && pre_dialog.on_close){ + pre_dialog.on_close(); + } + }; + this.dialog.on("closing", null, this.dialog.on_close); this.dialog.dialog_title = executor.action.name; if (widget instanceof instance.web.ViewManager) { _.extend(widget.flags, { -- cgit v1.2.3 From c0d838ddb34dd5062f663dee9a5d96e7863e1332 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 2 Sep 2014 19:42:24 +0200 Subject: [IMP] web: extra comments to explain commit 57b4860 Added some cryptic comments so we remember a bit why we have a complicated dance with on_close. Basically we do not want to reload the original form view until the last popup is closed, in the case where several wizard (steps) are opened one after the other. --- addons/web/static/src/js/views.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index b59e86b2192..1fac5794679 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -375,18 +375,29 @@ instance.web.ActionManager = instance.web.Widget.extend({ if (executor.action.target === 'new') { var pre_dialog = this.dialog; if (pre_dialog){ + // prevent previous dialog to consider itself closed, + // right now, as we're opening a new one (prevents + // reload of original form view) pre_dialog.off('closing', null, pre_dialog.on_close); } if (this.dialog_widget && !this.dialog_widget.isDestroyed()) { this.dialog_widget.destroy(); } + // explicitly passing a closing action to dialog_stop() prevents + // it from reloading the original form view this.dialog_stop(executor.action); this.dialog = new instance.web.Dialog(this, { dialogClass: executor.klass, }); + + // chain on_close triggers with previous dialog, if any this.dialog.on_close = function(){ options.on_close.apply(null, arguments); if (pre_dialog && pre_dialog.on_close){ + // no parameter passed to on_close as this will + // only be called when the last dialog is truly + // closing, and *should* trigger a reload of the + // underlying form view (see comments above) pre_dialog.on_close(); } }; @@ -404,6 +415,9 @@ instance.web.ActionManager = instance.web.Widget.extend({ this.dialog.open(); return initialized; } else { + // explicitly passing a closing action to dialog_stop() prevents + // it from reloading the original form view - we're opening a + // completely new action anyway this.dialog_stop(executor.action); this.inner_action = executor.action; this.inner_widget = widget; -- cgit v1.2.3