[ADD] Add dialog stack to action manager.
bzr revid: fme@openerp.com-20110412150955-lnwpc3ghix7m31xw
This commit is contained in:
parent
14ca20a978
commit
4eeaca9e6d
|
@ -532,7 +532,9 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
||||||
on_confirmed: function() {
|
on_confirmed: function() {
|
||||||
var attrs = this.node.attrs;
|
var attrs = this.node.attrs;
|
||||||
if (attrs.special) {
|
if (attrs.special) {
|
||||||
return this.log("Should close the popup");
|
this.on_button_object({
|
||||||
|
result : { type: 'ir.actions.act_window_close' }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var type = attrs.type || 'workflow';
|
var type = attrs.type || 'workflow';
|
||||||
var context = _.extend({}, this.view.dataset.context, attrs.context || {});
|
var context = _.extend({}, this.view.dataset.context, attrs.context || {});
|
||||||
|
|
|
@ -9,6 +9,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
||||||
init: function(session, element_id) {
|
init: function(session, element_id) {
|
||||||
this._super(session, element_id);
|
this._super(session, element_id);
|
||||||
this.viewmanager = null;
|
this.viewmanager = null;
|
||||||
|
this.dialog_stack = []
|
||||||
// Temporary linking view_manager to session.
|
// Temporary linking view_manager to session.
|
||||||
// Will use controller_parent to find it when implementation will be done.
|
// Will use controller_parent to find it when implementation will be done.
|
||||||
session.action_manager = this;
|
session.action_manager = this;
|
||||||
|
@ -19,12 +20,35 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
||||||
*/
|
*/
|
||||||
do_action: function(action) {
|
do_action: function(action) {
|
||||||
// instantiate the right controllers by understanding the action
|
// instantiate the right controllers by understanding the action
|
||||||
if(action.type == "ir.actions.act_window") {
|
switch (action.type) {
|
||||||
if (this.viewmanager) {
|
case 'ir.actions.act_window':
|
||||||
this.viewmanager.stop();
|
if (action.target == 'new') {
|
||||||
}
|
var element_id = _.uniqueId("act_window_dialog");
|
||||||
this.viewmanager = new openerp.base.ViewManagerAction(this.session,this.element_id, action, true);
|
var dialog = $('<div id="'+element_id+'"></div>');
|
||||||
this.viewmanager.start();
|
dialog.dialog({
|
||||||
|
title: action.name,
|
||||||
|
modal: true,
|
||||||
|
width: '50%',
|
||||||
|
height: 'auto'
|
||||||
|
});
|
||||||
|
var viewmanager = new openerp.base.ViewManagerAction(this.session ,element_id, action, false);
|
||||||
|
viewmanager.start();
|
||||||
|
this.dialog_stack.push(viewmanager);
|
||||||
|
} else if (action.target == "current") {
|
||||||
|
if (this.viewmanager) {
|
||||||
|
this.viewmanager.stop();
|
||||||
|
}
|
||||||
|
this.viewmanager = new openerp.base.ViewManagerAction(this.session,this.element_id, action, true);
|
||||||
|
this.viewmanager.start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ir.actions.act_window_close':
|
||||||
|
var dialog = this.dialog_stack.pop();
|
||||||
|
dialog.$element.dialog('destroy');
|
||||||
|
dialog.stop();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log(_.sprintf("Action manager can't handle action of type %s", action.type), action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue