forked from Techsystech/web
[IMP] web_switch_context_warning: black, isort, prettier
parent
5734621181
commit
a81dbdbb03
|
@ -0,0 +1 @@
|
|||
../../../../web_switch_context_warning
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue