Browse Source

[IMP] web_switch_company_warning

add user and db in change detection
pull/289/head
hparfr 8 years ago
parent
commit
402f45b61e
  1. 10
      web_switch_company_warning/README.rst
  2. 8
      web_switch_company_warning/static/src/js/switch_company_warning.js
  3. 2
      web_switch_company_warning/static/src/xml/switch_company_warning.xml

10
web_switch_company_warning/README.rst

@ -7,17 +7,21 @@ Web Switch Company Warning
===========================
Shows a warning if current company has been switched in another tab or window.
Shows a warning if current (company|user|db) has been changed within another tab or window.
Known issues / Roadmap
======================
Known issues
============
* If the browser don't implement Sharded Worker (http://www.w3.org/TR/workers/#sharedworker), the warning message will not be displayed (there is no polyfill).
* Switching company in a separate browser or in private browsing mode will not be detected by this module. It's a limitation of Shared Wworker(limit to browser session, server:port...)
Updates
=======
* Jan 2016 : [IMP] add user and db in change detection
* Sep 2015 : First version
Bug Tracker
===========

8
web_switch_company_warning/static/src/js/switch_company_warning.js

@ -25,7 +25,7 @@ openerp.web_switch_company_warning = function (instance) {
if (msg.data.type !== 'newCtx')
return;
if(msg.data.newCtx != self.session.company_id) {
if(msg.data.newCtx != signature(self.session)) {
self.$el.show();
} else {
self.$el.hide();
@ -33,7 +33,11 @@ openerp.web_switch_company_warning = function (instance) {
});
w.port.start();
w.port.postMessage(this.session.company_id);
w.port.postMessage(signature(this.session));
function signature(session) {
return [session.db, session.uid, session.company_id].join();
}
}
});

2
web_switch_company_warning/static/src/xml/switch_company_warning.xml

@ -2,7 +2,7 @@
<template>
<t t-name="web_switch_company_warning.warningWidget">
<div class="container-fluid bg-warning" style="text-align: center; display:none;">
<h3>You switched to a different company with another tab or window</h3>
<h3>You switched to a different company or user with another tab or window</h3>
<p><button onclick="location.reload(true);" class="btn">Reload</button> to refresh your session</p>
</div>
</t>
Loading…
Cancel
Save