mirror of https://github.com/OCA/web.git
Use new classes for the interactive notifications
parent
b333cdc7b1
commit
bf7fda1980
|
@ -8,7 +8,8 @@ odoo.define('web_notify.notification', function (require) {
|
|||
Notification = base_notification.Notification,
|
||||
Warning = base_notification.Warning;
|
||||
|
||||
Notification.include({
|
||||
var InteractiveNotification = Notification.extend({
|
||||
template: 'InteractiveNotification',
|
||||
events: _.extend(
|
||||
{},
|
||||
Notification.prototype.events,
|
||||
|
@ -23,7 +24,7 @@ odoo.define('web_notify.notification', function (require) {
|
|||
}
|
||||
),
|
||||
init: function(parent, title, text, sticky, options) {
|
||||
this._super.apply(this, arguments);
|
||||
this._super.apply(this, [parent, title, text, sticky]);
|
||||
this.options = options || {};
|
||||
},
|
||||
reload_active_view: function() {
|
||||
|
@ -35,14 +36,23 @@ odoo.define('web_notify.notification', function (require) {
|
|||
}
|
||||
});
|
||||
|
||||
var InteractiveWarning = InteractiveNotification.extend({
|
||||
template: 'InteractiveWarning',
|
||||
});
|
||||
|
||||
base_notification.NotificationManager.include({
|
||||
notify: function(title, text, sticky, options) {
|
||||
return this.display(new Notification(this, title, text, sticky, options));
|
||||
},
|
||||
warn: function(title, text, sticky, options) {
|
||||
return this.display(new Warning(this, title, text, sticky, options));
|
||||
interactive_notify(title, text, sticky, options) {
|
||||
return this.display(new InteractiveNotification(this, title, text, sticky, options));
|
||||
},
|
||||
interactive_warn(title, text, sticky, options) {
|
||||
return this.display(new InteractiveWarning(this, title, text, sticky, options));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return {
|
||||
InteractiveNotification: InteractiveNotification,
|
||||
InteractiveWarning: InteractiveWarning
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -8,11 +8,17 @@ var core = require('web.core'),
|
|||
|
||||
|
||||
Widget.include({
|
||||
do_notify: function(title, message, sticky, options) {
|
||||
this.trigger_up('notification', {title: title, message: message, sticky: sticky, options: options});
|
||||
do_interactive_notify: function(title, message, sticky, options) {
|
||||
this.trigger_up(
|
||||
'interactive_notification',
|
||||
{title: title, message: message,
|
||||
sticky: sticky, options: options});
|
||||
},
|
||||
do_warn: function(title, message, sticky, options) {
|
||||
this.trigger_up('warning', {title: title, message: message, sticky: sticky, options: options});
|
||||
do_interactive_warn: function(title, message, sticky, options) {
|
||||
this.trigger_up(
|
||||
'interactive_warning',
|
||||
{title: title, message: message,
|
||||
sticky: sticky, options: options});
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -22,14 +28,20 @@ WebClient.include({
|
|||
{},
|
||||
WebClient.prototype.custom_events,
|
||||
{reload_active_view: 'reload_active_view',
|
||||
notification: function (e) {
|
||||
interactive_notification: function (e) {
|
||||
if(this.notification_manager) {
|
||||
this.notification_manager.notify(e.data.title, e.data.message, e.data.sticky, e.data.options);
|
||||
this.notification_manager.interactive_notify(
|
||||
e.data.title, e.data.message,
|
||||
e.data.sticky, e.data.options
|
||||
);
|
||||
}
|
||||
},
|
||||
warning: function (e) {
|
||||
interactive_warning: function (e) {
|
||||
if(this.notification_manager) {
|
||||
this.notification_manager.warn(e.data.title, e.data.message, e.data.sticky, e.data.options);
|
||||
this.notification_manager.interactive_warn(
|
||||
e.data.title, e.data.message,
|
||||
e.data.sticky, e.data.options
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,12 +91,16 @@ WebClient.include({
|
|||
},
|
||||
on_message_warning: function(message){
|
||||
if(this.notification_manager) {
|
||||
this.notification_manager.do_warn(message.title, message.message, message.sticky, message);
|
||||
this.notification_manager.do_interactive_warn(
|
||||
message.title, message.message, message.sticky, message
|
||||
);
|
||||
}
|
||||
},
|
||||
on_message_info: function(message){
|
||||
if(this.notification_manager) {
|
||||
this.notification_manager.do_notify(message.title, message.message, message.sticky, message);
|
||||
this.notification_manager.do_interactive_notify(
|
||||
message.title, message.message, message.sticky, message
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
</div>
|
||||
</t>
|
||||
|
||||
<t t-extend="Notification">
|
||||
<t t-name="InteractiveNotification" t-extend="Notification">
|
||||
<t t-jquery=".o_notification_content" t-operation="after">
|
||||
<t t-call="Notification.reload"/>
|
||||
<t t-call="Notification.do_action"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-extend="Warning">
|
||||
<t t-name="InteractiveWarning" t-extend="Warning">
|
||||
<t t-jquery=".o_notification_content" t-operation="after">
|
||||
<t t-call="Notification.reload"/>
|
||||
<t t-call="Notification.do_action"/>
|
||||
|
|
Loading…
Reference in New Issue