Skip to content
Snippets Groups Projects
Commit d3c18f58 authored by Frédéric van der Essen's avatar Frédéric van der Essen
Browse files

[IMP] point_of_sale: automatically close the point of sale when open in another tab.

parent 5979662e
Branches
Tags
No related merge requests found
......@@ -26,6 +26,7 @@ var Gui = core.Class.extend({
this.current_screen = null;
this.chrome.ready.then(function(){
self.close_other_tabs();
var order = self.pos.get_order();
if (order) {
self.show_saved_screen(order);
......@@ -174,6 +175,36 @@ var Gui = core.Class.extend({
return !!this.current_popup;
},
/* ---- Gui: INTER TAB COMM ---- */
// This sets up automatic pos exit when open in
// another tab.
close_other_tabs: function() {
var self = this;
localStorage['message'] = '';
localStorage['message'] = JSON.stringify({
'message':'close_tabs',
'session': this.pos.pos_session.id,
});
window.addEventListener("storage", function(event) {
var msg = event.data;
if ( event.key === 'message' && event.newValue) {
var msg = JSON.parse(event.newValue);
if ( msg.message === 'close_tabs' &&
msg.session == self.pos.pos_session.id ) {
console.info('POS / Session opened in another window. EXITING POS')
self._close();
}
}
}, false);
},
/* ---- Gui: ACCESS CONTROL ---- */
// A Generic UI that allow to select a user from a list.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment