[IMP] Notification Widget is now a singleton

bzr revid: chs@openerp.com-20111013150317-kzy2h7bz407kiugz
This commit is contained in:
Christophe Simonis 2011-10-13 17:03:17 +02:00
parent 00b269d1c0
commit de5c2f58e8
2 changed files with 15 additions and 34 deletions

View File

@ -8,6 +8,11 @@ openerp.web.Notification = openerp.web.Widget.extend(/** @lends openerp.web.Not
template: 'Notification',
identifier_prefix: 'notification-',
init: function() {
this._super.apply(this, arguments);
openerp.notification = this;
},
start: function() {
this._super.apply(this, arguments);
this.$element.notify({
@ -29,35 +34,21 @@ openerp.web.Notification = openerp.web.Widget.extend(/** @lends openerp.web.Not
expires: false,
});
},
do_notify: function() { this.notify.apply(this, arguments); },
do_warn: function() {this.warn.apply(this, arguments); },
});
openerp.web.NotifiableWidget = openerp.web.Widget.extend({
init: function(/*arguments*/) {
this._super.apply(this, arguments);
this.notification = new openerp.web.Notification(this);
openerp.web.Widget.include({
do_notify: function() {
var n = openerp.notification;
n.notify.apply(n, arguments);
},
start: function() {
this._super.apply(this, arguments);
this.notification.prependTo(this.$element);
do_warn: function() {
var n = openerp.notification;
n.warn.apply(n, arguments);
},
stop: function() {
this.notification.stop();
return this._super.apply(this, arguments);
},
do_notify: function() { this.notification.notify.apply(this.notification, arguments); },
do_warn: function() { this.notification.warn.apply(this.notification, arguments); },
});
openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# */{
dialog_title: "",
identifier_prefix: 'dialog',
@ -945,7 +936,7 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
}
});
openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.web.WebClient */{
openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClient */{
/**
* @constructs openerp.web.WebClient
* @extends openerp.web.Widget
@ -963,6 +954,7 @@ openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.w
}
this.$element.html(QWeb.render("Interface", params));
this.notification = new openerp.web.Notification();
this.session = new openerp.web.Session();
this.loading = new openerp.web.Loading(this,"oe_loading");
this.crashmanager = new openerp.web.CrashManager(this);
@ -988,6 +980,7 @@ openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.w
},
start: function() {
this._super.apply(this, arguments);
this.notification.prependTo(this.$element);
this.header.appendTo($("#oe_header"));
this.session.start();
this.login.appendTo($('#oe_login'));

View File

@ -949,18 +949,6 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg
}
return false;
},
do_notify: function() {
if (this.widget_parent) {
return this.widget_parent.do_notify.apply(this,arguments);
}
return false;
},
do_warn: function() {
if (this.widget_parent) {
return this.widget_parent.do_warn.apply(this,arguments);
}
return false;
},
rpc: function(url, data, success, error) {
var def = $.Deferred().then(success, error);
var self = this;