[FIX] incompatibility between static home and ActionManager
convert static home to a client action, fix ActionManager's handling of client actions to play correctly with the Widget lifecycle (and clean any client action displayed in case it's switching to an inner act_window) bzr revid: xmo@openerp.com-20110819143947-29dzerce0d42fhel
This commit is contained in:
parent
2cefb02439
commit
eaf0914e2a
|
@ -30,11 +30,15 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
this.dialog = null;
|
||||
}
|
||||
},
|
||||
inner_stop: function () {
|
||||
content_stop: function () {
|
||||
if (this.inner_viewmanager) {
|
||||
this.inner_viewmanager.stop();
|
||||
this.inner_viewmanager = null;
|
||||
}
|
||||
if (this.client_widget) {
|
||||
this.client_widget.stop();
|
||||
this.client_widget = null;
|
||||
}
|
||||
},
|
||||
url_update: function(action) {
|
||||
// this.url = {
|
||||
|
@ -89,7 +93,7 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
this.dialog.open();
|
||||
} else {
|
||||
this.dialog_stop();
|
||||
this.inner_stop();
|
||||
this.content_stop();
|
||||
this.inner_viewmanager = new openerp.base.ViewManagerAction(this, action);
|
||||
this.inner_viewmanager.appendTo(this.$element);
|
||||
this.url_update(action);
|
||||
|
@ -114,8 +118,9 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
});
|
||||
},
|
||||
ir_actions_client: function (action) {
|
||||
this.client_widget = openerp.base.client_actions.get_object(action.tag);
|
||||
new this.client_widget(this, this.element_id, action.params).start();
|
||||
this.content_stop();
|
||||
var ClientWidget = openerp.base.client_actions.get_object(action.tag);
|
||||
(this.client_widget = new ClientWidget(this, action.params)).appendTo(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -345,14 +345,11 @@ openerp.base_dashboard.ConfigOverview = openerp.base.View.extend({
|
|||
openerp.base.client_actions.add(
|
||||
'board.home.applications', 'openerp.base_dashboard.ApplicationTiles');
|
||||
openerp.base_dashboard.ApplicationTiles = openerp.base.View.extend({
|
||||
init: function (parent, element_id) {
|
||||
this._super(parent, element_id);
|
||||
this.dataset = new openerp.base.DataSetSearch(
|
||||
this, 'ir.ui.menu', null, [['parent_id', '=', false]]);
|
||||
},
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.dataset.read_slice( ['name', 'web_icon_data', 'web_icon_hover_data'], {}, function (applications) {
|
||||
return new openerp.base.DataSetSearch(
|
||||
this, 'ir.ui.menu', null, [['parent_id', '=', false]])
|
||||
.read_slice( ['name', 'web_icon_data', 'web_icon_hover_data'], {}, function (applications) {
|
||||
// Create a matrix of 3*x applications
|
||||
var rows = [];
|
||||
while (applications.length) {
|
||||
|
@ -367,22 +364,18 @@ openerp.base_dashboard.ApplicationTiles = openerp.base.View.extend({
|
|||
$this.closest('.openerp')
|
||||
.find('.menu a[data-menu=' + $this.data('menuid') + ']')
|
||||
.click();});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
openerp.base.client_actions.add(
|
||||
'board.home.widgets', 'openerp.base_dashboard.Widgets');
|
||||
openerp.base_dashboard.Widgets = openerp.base.View.extend({
|
||||
init: function (parent, element_id) {
|
||||
this._super(parent, element_id);
|
||||
this.user_widgets = new openerp.base.DataSetSearch(
|
||||
start: function () {
|
||||
return new openerp.base.DataSetSearch(
|
||||
this, 'res.widget.user', null,
|
||||
['|', ['user_id', '=', false],
|
||||
['user_id', '=', parseInt(this.session.uid, 10)]]);
|
||||
this.widgets = new openerp.base.DataSetSearch(this, 'res.widget');
|
||||
},
|
||||
start: function () {
|
||||
this.user_widgets.read_slice(['widget_id', 'user_id'], {}, this.on_widgets_list_loaded);
|
||||
['user_id', '=', parseInt(this.session.uid, 10)]])
|
||||
.read_slice(['widget_id', 'user_id'], {}, this.on_widgets_list_loaded);
|
||||
},
|
||||
on_widgets_list_loaded: function (user_widgets) {
|
||||
var self = this;
|
||||
|
@ -394,18 +387,19 @@ openerp.base_dashboard.Widgets = openerp.base.View.extend({
|
|||
user_widget_id: widget['id']
|
||||
};
|
||||
});
|
||||
this.widgets.read_ids(_(user_widgets).pluck('widget_id'), ['title'], function (widgets) {
|
||||
_(widgets).each(function (widget) {
|
||||
_.extend(widget, widget_user[widget['id']]);
|
||||
new openerp.base.DataSetSearch(this, 'res.widget')
|
||||
.read_ids(_(user_widgets).pluck('widget_id'), ['title'], function (widgets) {
|
||||
_(widgets).each(function (widget) {
|
||||
_.extend(widget, widget_user[widget['id']]);
|
||||
});
|
||||
var url = _.sprintf(
|
||||
'/base_dashboard/widgets/content?session_id=%s&widget_id=',
|
||||
self.session.session_id);
|
||||
self.$element.html(QWeb.render('HomeWidgets', {
|
||||
widgets: widgets,
|
||||
url: url
|
||||
}));
|
||||
});
|
||||
var url = _.sprintf(
|
||||
'/base_dashboard/widgets/content?session_id=%s&widget_id=',
|
||||
self.session.session_id);
|
||||
self.$element.html(QWeb.render('HomeWidgets', {
|
||||
widgets: widgets,
|
||||
url: url
|
||||
}));
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -63,22 +63,38 @@ openerp.base_default_home = function (openerp) {
|
|||
if (!_(installed_modules).isEmpty()) {
|
||||
return old_home.call(self);
|
||||
}
|
||||
self.$element.find('.oe-application').html(
|
||||
QWeb.render('StaticHome', {
|
||||
url: window.location.protocol + '//' + window.location.host + window.location.pathname,
|
||||
session: self.session,
|
||||
rows: openerp.base_default_home.applications
|
||||
})).delegate('.oe-static-home-tile-text button', 'click', function () {
|
||||
self.install_module($(this).val());
|
||||
self.action_manager.do_action({
|
||||
type: 'ir.actions.client',
|
||||
tag: 'home.default'
|
||||
})
|
||||
|
||||
}, function (err, event) {
|
||||
event.preventDefault();
|
||||
return old_home.call(self);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.client_actions.add(
|
||||
'home.default', 'openerp.base_default_home.DefaultHome');
|
||||
openerp.base_default_home.DefaultHome = openerp.base.View.extend({
|
||||
template: 'StaticHome',
|
||||
start: function () {
|
||||
var r = this._super();
|
||||
this.$element.delegate('.oe-static-home-tile-text button', 'click', function () {
|
||||
self.install_module($(this).val());
|
||||
});
|
||||
return r;
|
||||
},
|
||||
render: function () {
|
||||
return this._super({
|
||||
url: window.location.protocol + '//' + window.location.host + window.location.pathname,
|
||||
session: this.session,
|
||||
rows: openerp.base_default_home.applications
|
||||
})
|
||||
},
|
||||
install_module: function (module_name) {
|
||||
var Modules = new openerp.base.DataSetSearch( this, 'ir.module.module', null, [['name', '=', module_name], ['state', '=', 'uninstalled']]);
|
||||
var Modules = new openerp.base.DataSetSearch(
|
||||
this, 'ir.module.module', null, [['name', '=', module_name], ['state', '=', 'uninstalled']]);
|
||||
var Upgrade = new openerp.base.DataSet(this, 'base.module.upgrade');
|
||||
|
||||
$.blockUI({
|
||||
|
|
Loading…
Reference in New Issue