diff --git a/web_notify/static/src/js/web_client.js b/web_notify/static/src/js/web_client.js index ef6b82871..0d8f4ab4d 100644 --- a/web_notify/static/src/js/web_client.js +++ b/web_notify/static/src/js/web_client.js @@ -1,24 +1,22 @@ -odoo.define('web_notify.WebClient', function (require) { +odoo.define("web_notify.WebClient", function(require) { "use strict"; - var WebClient = require('web.WebClient'); - var base_bus = require('bus.Longpolling'); - var session = require('web.session'); - require('bus.BusService'); - + var WebClient = require("web.WebClient"); + var session = require("web.session"); + require("bus.BusService"); WebClient.include({ - show_application: function () { + show_application: function() { var res = this._super(); this.start_polling(); return res; }, - start_polling: function () { - this.channel_success = 'notify_success_' + session.uid; - this.channel_danger = 'notify_danger_' + session.uid; - this.channel_warning = 'notify_warning_' + session.uid; - this.channel_info = 'notify_info_' + session.uid; - this.channel_default = 'notify_default_' + session.uid; + start_polling: function() { + this.channel_success = "notify_success_" + session.uid; + this.channel_danger = "notify_danger_" + session.uid; + this.channel_warning = "notify_warning_" + session.uid; + this.channel_info = "notify_info_" + session.uid; + this.channel_default = "notify_default_" + session.uid; this.all_channels = [ this.channel_success, this.channel_danger, @@ -26,40 +24,35 @@ odoo.define('web_notify.WebClient', function (require) { this.channel_info, this.channel_default, ]; - this.call('bus_service', 'addChannel', this.channel_success); - this.call('bus_service', 'addChannel', this.channel_danger); - this.call('bus_service', 'addChannel', this.channel_warning); - this.call('bus_service', 'addChannel', this.channel_info); - this.call('bus_service', 'addChannel', this.channel_default); - this.call( - 'bus_service', 'on', 'notification', - this, this.bus_notification); - this.call('bus_service', 'startPolling'); + this.call("bus_service", "addChannel", this.channel_success); + this.call("bus_service", "addChannel", this.channel_danger); + this.call("bus_service", "addChannel", this.channel_warning); + this.call("bus_service", "addChannel", this.channel_info); + this.call("bus_service", "addChannel", this.channel_default); + this.call("bus_service", "on", "notification", this, this.bus_notification); + this.call("bus_service", "startPolling"); }, - bus_notification: function (notifications) { + bus_notification: function(notifications) { var self = this; - _.each(notifications, function (notification) { + _.each(notifications, function(notification) { var channel = notification[0]; var message = notification[1]; if ( - self.all_channels != null && + self.all_channels !== null && self.all_channels.indexOf(channel) > -1 ) { self.on_message(message); } }); }, - on_message: function (message) { - return this.call( - 'notification', 'notify', { - type: message.type, - title: message.title, - message: message.message, - sticky: message.sticky, - className: message.className, - } - ); + on_message: function(message) { + return this.call("notification", "notify", { + type: message.type, + title: message.title, + message: message.message, + sticky: message.sticky, + className: message.className, + }); }, }); - }); diff --git a/web_notify/static/src/js/widgets/notification.js b/web_notify/static/src/js/widgets/notification.js index ed797d201..a991fdad8 100644 --- a/web_notify/static/src/js/widgets/notification.js +++ b/web_notify/static/src/js/widgets/notification.js @@ -1,26 +1,26 @@ -odoo.define('web_notify.Notification', function (require) { +odoo.define("web_notify.Notification", function(require) { "use strict"; - var Notification = require('web.Notification'); + var Notification = require("web.Notification"); Notification.include({ icon_mapping: { - 'success': 'fa-thumbs-up', - 'danger': 'fa-exclamation-triangle', - 'warning': 'fa-exclamation', - 'info': 'fa-info', - 'default': 'fa-lightbulb-o', + success: "fa-thumbs-up", + danger: "fa-exclamation-triangle", + warning: "fa-exclamation", + info: "fa-info", + default: "fa-lightbulb-o", }, - init: function () { + init: function() { this._super.apply(this, arguments); // Delete default classes - this.className = this.className.replace(' o_error', ''); + this.className = this.className.replace(" o_error", ""); // Add custom icon and custom class - this.icon = (this.type in this.icon_mapping) ? - this.icon_mapping[this.type] : - this.icon_mapping['default']; - this.className += ' o_' + this.type; + this.icon = + this.type in this.icon_mapping + ? this.icon_mapping[this.type] + : this.icon_mapping.default; + this.className += " o_" + this.type; }, }); - }); diff --git a/web_notify/static/src/scss/webclient.scss b/web_notify/static/src/scss/webclient.scss index 1ce4cb415..82f3c1544 100644 --- a/web_notify/static/src/scss/webclient.scss +++ b/web_notify/static/src/scss/webclient.scss @@ -2,23 +2,23 @@ .o_notification { &.o_success { color: white; - background-color: theme-color('success'); + background-color: theme-color("success"); } &.o_danger { color: white; - background-color: theme-color('danger'); + background-color: theme-color("danger"); } &.o_warning { color: white; - background-color: theme-color('warning'); + background-color: theme-color("warning"); } &.o_info { color: white; - background-color: theme-color('info'); + background-color: theme-color("info"); } &.o_default { color: black; - background-color: theme-color('default'); + background-color: theme-color("default"); } } } diff --git a/web_notify/views/res_users_demo.xml b/web_notify/views/res_users_demo.xml index 7e8c0d97b..65bc72a03 100644 --- a/web_notify/views/res_users_demo.xml +++ b/web_notify/views/res_users_demo.xml @@ -1,44 +1,54 @@ - + res.users.form.simple.view.modif.inherit res.users - + -