[IMP] web_switch_context_warning: black, isort, prettier

pull/1980/head
hkapatel 2021-07-13 10:26:44 +05:30
parent 5734621181
commit a81dbdbb03
4 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1 @@
../../../../web_switch_context_warning

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -1,4 +1,4 @@
odoo.define("web_switch_context_warning.widget", function(require) {
odoo.define("web_switch_context_warning.widget", function (require) {
"use strict";
var Widget = require("web.Widget");
@ -13,13 +13,13 @@ odoo.define("web_switch_context_warning.widget", function(require) {
}
var SwitchContextWarningWidget = Widget.extend({
template: "web_switch_context_warning.warningWidget",
init: function() {
init: function () {
this._super();
var self = this;
var w = new SharedWorker(
"/web_switch_context_warning/static/src/js/switch_context_warning_worker.js"
);
w.port.addEventListener("message", function(msg) {
w.port.addEventListener("message", function (msg) {
if (msg.data.type !== "newCtx") {
return;
}
@ -32,13 +32,13 @@ odoo.define("web_switch_context_warning.widget", function(require) {
w.port.start();
w.port.postMessage(this.generateSignature());
},
generateSignature: function() {
generateSignature: function () {
return [session.uid, session.db].join();
},
});
UserMenu.include({
init: function(parent) {
init: function (parent) {
this._super(parent);
var switchContextWarning = new SwitchContextWarningWidget();
switchContextWarning.insertAfter(".o_main_navbar");

View File

@ -6,17 +6,17 @@ var lastCtx = null;
addEventListener(
"connect",
function(ee) {
function (ee) {
"use strict";
var port = ee.ports[0];
con.push(port);
port.onmessage = function(e) {
port.onmessage = function (e) {
var newCtx = e.data;
if (lastCtx && newCtx !== lastCtx) {
con.forEach(function(eport) {
con.forEach(function (eport) {
eport.postMessage({
type: "newCtx",
newCtx: newCtx,