mirror of https://github.com/OCA/web.git
[IMP] pre-commit run after update
Includes some manual fixes to silent ESLint warnings.pull/2412/head
parent
1830fd2edb
commit
00a9a9f698
|
@ -1,24 +1,22 @@
|
||||||
odoo.define('web_notify.WebClient', function (require) {
|
odoo.define("web_notify.WebClient", function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WebClient = require('web.WebClient');
|
var WebClient = require("web.WebClient");
|
||||||
var base_bus = require('bus.Longpolling');
|
var session = require("web.session");
|
||||||
var session = require('web.session');
|
require("bus.BusService");
|
||||||
require('bus.BusService');
|
|
||||||
|
|
||||||
|
|
||||||
WebClient.include({
|
WebClient.include({
|
||||||
show_application: function () {
|
show_application: function() {
|
||||||
var res = this._super();
|
var res = this._super();
|
||||||
this.start_polling();
|
this.start_polling();
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
start_polling: function () {
|
start_polling: function() {
|
||||||
this.channel_success = 'notify_success_' + session.uid;
|
this.channel_success = "notify_success_" + session.uid;
|
||||||
this.channel_danger = 'notify_danger_' + session.uid;
|
this.channel_danger = "notify_danger_" + session.uid;
|
||||||
this.channel_warning = 'notify_warning_' + session.uid;
|
this.channel_warning = "notify_warning_" + session.uid;
|
||||||
this.channel_info = 'notify_info_' + session.uid;
|
this.channel_info = "notify_info_" + session.uid;
|
||||||
this.channel_default = 'notify_default_' + session.uid;
|
this.channel_default = "notify_default_" + session.uid;
|
||||||
this.all_channels = [
|
this.all_channels = [
|
||||||
this.channel_success,
|
this.channel_success,
|
||||||
this.channel_danger,
|
this.channel_danger,
|
||||||
|
@ -26,40 +24,35 @@ odoo.define('web_notify.WebClient', function (require) {
|
||||||
this.channel_info,
|
this.channel_info,
|
||||||
this.channel_default,
|
this.channel_default,
|
||||||
];
|
];
|
||||||
this.call('bus_service', 'addChannel', this.channel_success);
|
this.call("bus_service", "addChannel", this.channel_success);
|
||||||
this.call('bus_service', 'addChannel', this.channel_danger);
|
this.call("bus_service", "addChannel", this.channel_danger);
|
||||||
this.call('bus_service', 'addChannel', this.channel_warning);
|
this.call("bus_service", "addChannel", this.channel_warning);
|
||||||
this.call('bus_service', 'addChannel', this.channel_info);
|
this.call("bus_service", "addChannel", this.channel_info);
|
||||||
this.call('bus_service', 'addChannel', this.channel_default);
|
this.call("bus_service", "addChannel", this.channel_default);
|
||||||
this.call(
|
this.call("bus_service", "on", "notification", this, this.bus_notification);
|
||||||
'bus_service', 'on', 'notification',
|
this.call("bus_service", "startPolling");
|
||||||
this, this.bus_notification);
|
|
||||||
this.call('bus_service', 'startPolling');
|
|
||||||
},
|
},
|
||||||
bus_notification: function (notifications) {
|
bus_notification: function(notifications) {
|
||||||
var self = this;
|
var self = this;
|
||||||
_.each(notifications, function (notification) {
|
_.each(notifications, function(notification) {
|
||||||
var channel = notification[0];
|
var channel = notification[0];
|
||||||
var message = notification[1];
|
var message = notification[1];
|
||||||
if (
|
if (
|
||||||
self.all_channels != null &&
|
self.all_channels !== null &&
|
||||||
self.all_channels.indexOf(channel) > -1
|
self.all_channels.indexOf(channel) > -1
|
||||||
) {
|
) {
|
||||||
self.on_message(message);
|
self.on_message(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
on_message: function (message) {
|
on_message: function(message) {
|
||||||
return this.call(
|
return this.call("notification", "notify", {
|
||||||
'notification', 'notify', {
|
|
||||||
type: message.type,
|
type: message.type,
|
||||||
title: message.title,
|
title: message.title,
|
||||||
message: message.message,
|
message: message.message,
|
||||||
sticky: message.sticky,
|
sticky: message.sticky,
|
||||||
className: message.className,
|
className: message.className,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
odoo.define('web_notify.Notification', function (require) {
|
odoo.define("web_notify.Notification", function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Notification = require('web.Notification');
|
var Notification = require("web.Notification");
|
||||||
|
|
||||||
Notification.include({
|
Notification.include({
|
||||||
icon_mapping: {
|
icon_mapping: {
|
||||||
'success': 'fa-thumbs-up',
|
success: "fa-thumbs-up",
|
||||||
'danger': 'fa-exclamation-triangle',
|
danger: "fa-exclamation-triangle",
|
||||||
'warning': 'fa-exclamation',
|
warning: "fa-exclamation",
|
||||||
'info': 'fa-info',
|
info: "fa-info",
|
||||||
'default': 'fa-lightbulb-o',
|
default: "fa-lightbulb-o",
|
||||||
},
|
},
|
||||||
init: function () {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
// Delete default classes
|
// Delete default classes
|
||||||
this.className = this.className.replace(' o_error', '');
|
this.className = this.className.replace(" o_error", "");
|
||||||
// Add custom icon and custom class
|
// Add custom icon and custom class
|
||||||
this.icon = (this.type in this.icon_mapping) ?
|
this.icon =
|
||||||
this.icon_mapping[this.type] :
|
this.type in this.icon_mapping
|
||||||
this.icon_mapping['default'];
|
? this.icon_mapping[this.type]
|
||||||
this.className += ' o_' + this.type;
|
: this.icon_mapping.default;
|
||||||
|
this.className += " o_" + this.type;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
.o_notification {
|
.o_notification {
|
||||||
&.o_success {
|
&.o_success {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: theme-color('success');
|
background-color: theme-color("success");
|
||||||
}
|
}
|
||||||
&.o_danger {
|
&.o_danger {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: theme-color('danger');
|
background-color: theme-color("danger");
|
||||||
}
|
}
|
||||||
&.o_warning {
|
&.o_warning {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: theme-color('warning');
|
background-color: theme-color("warning");
|
||||||
}
|
}
|
||||||
&.o_info {
|
&.o_info {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: theme-color('info');
|
background-color: theme-color("info");
|
||||||
}
|
}
|
||||||
&.o_default {
|
&.o_default {
|
||||||
color: black;
|
color: black;
|
||||||
background-color: theme-color('default');
|
background-color: theme-color("default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,54 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- Copyright 2018 Aitor Bouzas <aitor.bouzas@adaptivecity.com>
|
<!-- Copyright 2018 Aitor Bouzas <aitor.bouzas@adaptivecity.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_users_form_simple_modif_inherit" model="ir.ui.view">
|
<record id="view_users_form_simple_modif_inherit" model="ir.ui.view">
|
||||||
<field name="name">res.users.form.simple.view.modif.inherit</field>
|
<field name="name">res.users.form.simple.view.modif.inherit</field>
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
<field name="inherit_id" ref="base.view_users_form"/>
|
<field name="inherit_id" ref="base.view_users_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//notebook/page[1]" position="after">
|
<xpath expr="//notebook/page[1]" position="after">
|
||||||
<page string="Test web notify" name="test_web_notify">
|
<page string="Test web notify" name="test_web_notify">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<button name="notify_success"
|
<button
|
||||||
|
name="notify_success"
|
||||||
type="object"
|
type="object"
|
||||||
string="Test success notification"
|
string="Test success notification"
|
||||||
class="oe_highlight"/>
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button name="notify_danger"
|
<button
|
||||||
|
name="notify_danger"
|
||||||
type="object"
|
type="object"
|
||||||
string="Test danger notification"
|
string="Test danger notification"
|
||||||
class="oe_highlight"/>
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button name="notify_warning"
|
<button
|
||||||
|
name="notify_warning"
|
||||||
type="object"
|
type="object"
|
||||||
string="Test warning notification"
|
string="Test warning notification"
|
||||||
class="oe_highlight"/>
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button name="notify_info"
|
<button
|
||||||
|
name="notify_info"
|
||||||
type="object"
|
type="object"
|
||||||
string="Test info notification"
|
string="Test info notification"
|
||||||
class="oe_highlight"/>
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button name="notify_default"
|
<button
|
||||||
|
name="notify_default"
|
||||||
type="object"
|
type="object"
|
||||||
string="Test default notification"
|
string="Test default notification"
|
||||||
class="oe_highlight"/>
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<template id="assets_backend" name="web_notify assets" inherit_id="web.assets_backend">
|
<template
|
||||||
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/webclient.scss" position="after">
|
id="assets_backend"
|
||||||
<link rel="stylesheet" type="text/scss" href="/web_notify/static/src/scss/webclient.scss"/>
|
name="web_notify assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/scss"
|
||||||
|
href="/web/static/src/scss/webclient.scss"
|
||||||
|
position="after"
|
||||||
|
>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/scss"
|
||||||
|
href="/web_notify/static/src/scss/webclient.scss"
|
||||||
|
/>
|
||||||
</link>
|
</link>
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/web_notify/static/src/js/web_client.js"/>
|
<script
|
||||||
<script type="text/javascript" src="/web_notify/static/src/js/widgets/notification.js"/>
|
type="text/javascript"
|
||||||
|
src="/web_notify/static/src/js/web_client.js"
|
||||||
|
/>
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/web_notify/static/src/js/widgets/notification.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue