diff options
| author | Christophe Simonis <chs@openerp.com> | 2012-07-26 18:16:38 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2012-07-26 18:16:38 +0200 |
| commit | 9128e37231194592b6468ffa7922bbb39b5d7a33 (patch) | |
| tree | a855ba9f9b2ed7f27ac9024409dd29db00ea19cb /addons/web/static/src | |
| parent | 515372d8dc4429f72ce06f5f840b3b59224a9c77 (diff) | |
[REF] refactor action popup
bzr revid: chs@openerp.com-20120726161638-zt8x0kfpxvst998r
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views.js | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 6b4bc44df64..10f44a54f11 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -214,21 +214,30 @@ instance.web.ActionManager = instance.web.Widget.extend({ this.dialog_stop(); this.clear_breadcrumbs(); }, - ir_actions_act_window: function (action, on_close) { - var self = this; - if (_(['base.module.upgrade', 'base.setup.installer']) - .contains(action.res_model)) { - var old_close = on_close; - on_close = function () { - instance.webclient.do_reload().then(old_close); - }; + + do_ir_actions_common: function(action, on_close) { + var self = this, klass, widget, add_breadcrumb; + if (action.type === 'ir.actions.client') { + var ClientWidget = instance.web.client_actions.get_object(action.tag); + widget = new ClientWidget(this, action.params); + klass = 'oe_act_client'; + add_breadcrumb = function() { + self.push_breadcrumb({ + widget: widget, + title: action.name + }); + } + } else { + widget = new instance.web.ViewManagerAction(this, action); + klass = 'oe_act_window'; + add_breadcrumb = widget.add_breadcrumb } if (action.target === 'new') { if (this.dialog === null) { // These buttons will be overwrited by <footer> if any this.dialog = new instance.web.Dialog(this, { buttons: { "Close": function() { $(this).dialog("close"); }}, - dialogClass: 'oe_act_window' + dialogClass: klass }); if(on_close) this.dialog.on_close.add(on_close); @@ -236,7 +245,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ this.dialog_widget.destroy(); } this.dialog.dialog_title = action.name; - this.dialog_widget = new instance.web.ViewManagerAction(this, action); + this.dialog_widget = widget; this.dialog_widget.appendTo(this.dialog.$element); this.dialog.open(); } else { @@ -247,11 +256,34 @@ instance.web.ActionManager = instance.web.Widget.extend({ }); } this.inner_action = action; - var inner_widget = this.inner_widget = new instance.web.ViewManagerAction(this, action); - inner_widget.add_breadcrumb(); + this.inner_widget = widget; + add_breadcrumb(); this.inner_widget.appendTo(this.$element); } }, + + ir_actions_act_window: function (action, on_close) { + var self = this; + if (_(['base.module.upgrade', 'base.setup.installer']) + .contains(action.res_model)) { + var old_close = on_close; + on_close = function () { + instance.webclient.do_reload().then(old_close); + }; + } + if (action.target !== 'new') { + if(action.menu_id) { + this.dialog_stop(); + return this.getParent().do_action(action, function () { + instance.webclient.menu.open_menu(action.menu_id); + }); + } + } + return this.do_ir_actions_common(action, on_close); + }, + ir_actions_client: function (action, on_close) { + return this.do_ir_actions_common(action, on_close); + }, ir_actions_act_window_close: function (action, on_closed) { if (!this.dialog && on_closed) { on_closed(); @@ -267,18 +299,6 @@ instance.web.ActionManager = instance.web.Widget.extend({ self.do_action(action, on_closed) }); }, - ir_actions_client: function (action) { - this.dialog_stop(); - var ClientWidget = instance.web.client_actions.get_object(action.tag); - this.inner_widget = new ClientWidget(this, action.params); - this.push_breadcrumb({ - widget: this.inner_widget, - title: action.name - }); - this.inner_action = action; - this.do_push_state({}); - this.inner_widget.appendTo(this.$element); - }, ir_actions_report_xml: function(action, on_closed) { var self = this; instance.web.blockUI(); |
