[REF] refactor action popup

bzr revid: chs@openerp.com-20120726161638-zt8x0kfpxvst998r
This commit is contained in:
Christophe Simonis 2012-07-26 18:16:38 +02:00
parent 515372d8dc
commit 9128e37231
1 changed files with 44 additions and 24 deletions

View File

@ -214,21 +214,30 @@ instance.web.ActionManager = instance.web.Widget.extend({
this.dialog_stop(); this.dialog_stop();
this.clear_breadcrumbs(); this.clear_breadcrumbs();
}, },
ir_actions_act_window: function (action, on_close) {
var self = this; do_ir_actions_common: function(action, on_close) {
if (_(['base.module.upgrade', 'base.setup.installer']) var self = this, klass, widget, add_breadcrumb;
.contains(action.res_model)) { if (action.type === 'ir.actions.client') {
var old_close = on_close; var ClientWidget = instance.web.client_actions.get_object(action.tag);
on_close = function () { widget = new ClientWidget(this, action.params);
instance.webclient.do_reload().then(old_close); 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 (action.target === 'new') {
if (this.dialog === null) { if (this.dialog === null) {
// These buttons will be overwrited by <footer> if any // These buttons will be overwrited by <footer> if any
this.dialog = new instance.web.Dialog(this, { this.dialog = new instance.web.Dialog(this, {
buttons: { "Close": function() { $(this).dialog("close"); }}, buttons: { "Close": function() { $(this).dialog("close"); }},
dialogClass: 'oe_act_window' dialogClass: klass
}); });
if(on_close) if(on_close)
this.dialog.on_close.add(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_widget.destroy();
} }
this.dialog.dialog_title = action.name; 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_widget.appendTo(this.dialog.$element);
this.dialog.open(); this.dialog.open();
} else { } else {
@ -247,11 +256,34 @@ instance.web.ActionManager = instance.web.Widget.extend({
}); });
} }
this.inner_action = action; this.inner_action = action;
var inner_widget = this.inner_widget = new instance.web.ViewManagerAction(this, action); this.inner_widget = widget;
inner_widget.add_breadcrumb(); add_breadcrumb();
this.inner_widget.appendTo(this.$element); 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) { ir_actions_act_window_close: function (action, on_closed) {
if (!this.dialog && on_closed) { if (!this.dialog && on_closed) {
on_closed(); on_closed();
@ -267,18 +299,6 @@ instance.web.ActionManager = instance.web.Widget.extend({
self.do_action(action, on_closed) 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) { ir_actions_report_xml: function(action, on_closed) {
var self = this; var self = this;
instance.web.blockUI(); instance.web.blockUI();