From 1353e44bb369ed8bd061fdb4e769ff052abb3202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 16 Jan 2014 18:28:46 +0100 Subject: [PATCH] [IMP] point_of_sale: less confusing synchronisation indicator bzr revid: fva@openerp.com-20140116172846-7lyz50jr69crbxsn --- addons/point_of_sale/static/src/css/pos.css | 14 +++++------ .../point_of_sale/static/src/img/gtk-no.png | Bin 751 -> 0 bytes .../point_of_sale/static/src/img/gtk-yes.png | Bin 830 -> 0 bytes addons/point_of_sale/static/src/js/models.js | 20 ++++++++++++--- addons/point_of_sale/static/src/js/widgets.js | 23 ++++++++++++++---- addons/point_of_sale/static/src/xml/pos.xml | 19 ++++++++------- 6 files changed, 51 insertions(+), 25 deletions(-) delete mode 100644 addons/point_of_sale/static/src/img/gtk-no.png delete mode 100644 addons/point_of_sale/static/src/img/gtk-yes.png diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index a44f14ceb6a..8980a01b4f8 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -373,17 +373,17 @@ td { .pos .oe_pos_synch-notification.oe_inactive{ cursor: default; } -.pos .oe_pos_synch-notification .oe_status_red{ +.pos .oe_pos_synch-notification .oe_status{ display:inline-block; cursor:pointer; width:16px; height:16px; - background: url("../img/gtk-no.png") no-repeat ; + color: white; } - -.pos .oe_pos_synch-notification .oe_status_green{ - display:inline-block; - width:16px; height:16px; - background: url("../img/gtk-yes.png") no-repeat; +.pos .oe_pos_synch-notification .oe_red{ + color: rgb(197, 52, 0); +} +.pos .oe_pos_synch-notification .oe_green{ + color: rgb(94, 185, 55); } /* ********* Contains everything below the bar ********* */ diff --git a/addons/point_of_sale/static/src/img/gtk-no.png b/addons/point_of_sale/static/src/img/gtk-no.png deleted file mode 100644 index 047ddcd9289d5d07ad0cc4d2128738f744038bbc..0000000000000000000000000000000000000000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=T>nZ3?>jvjXO`nA$NN@~`WHG# zk2R3S46xlWEs#TQ=ovHIVo70#X0~?36s+Z^HE`kBM*~jG#o)xO5se>~!}CUuL(jB0 z^w1P6XxGe=^ZVCcTgJkzRpObQUE1$;ld-b*4VPw&X!^qW%=`BSG`u#Vb|O~ZaY_3< z#U^&F+QuT-AEk)3vZVF9#H+cdqrTdF`k*v!kUi5z5C_K$as}VZX^Z-nSR!86TUZu% zR2+d5Dv_fOQ?evWuF#ZfQv|Y)M|{ffjQl}lH${9&DOU`ew+d~FWg$6^vy?3=ffK$| z#WcnZY;9bYuql4Cuswd0P#l{fY|*b_8^a=*k!O~1mi&@_0vhppf`ieE;{X5v07*qo IM6N<$g6mO}LI3~& diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index a626b20b77e..961ebffbda3 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -53,11 +53,20 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal // these dynamic attributes can be watched for change by other models or widgets this.set({ - 'nbr_pending_operations': 0, + 'synch': { state:'connected', pending:0 }, 'orders': new module.OrderCollection(), 'selectedOrder': null, }); + this.bind('change:synch',function(pos,synch){ + clearTimeout(self.synch_timeout); + self.synch_timeout = setTimeout(function(){ + if(synch.state !== 'disconnected' && synch.pending > 0){ + self.set('synch',{state:'disconnected', pending:synch.pending}); + } + },3000); + }); + this.get('orders').bind('remove', function(order,_unused_,options){ self.on_removed_order(order,options.index,options.reason); }); @@ -296,7 +305,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal var order_id = this.db.add_order(order.export_as_JSON()); var pushed = new $.Deferred(); - this.set('nbr_pending_operations',self.db.get_orders().length); + this.set('synch',{state:'connecting', pending:self.db.get_orders().length}); this.flush_mutex.exec(function(){ var flushed = self._flush_all_orders(); @@ -329,7 +338,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal var order_id = this.db.add_order(order.export_as_JSON()); - this.set('nbr_pending_operations',self.db.get_orders().length); + this.set('synch',{state:'connecting', pending:self.db.get_orders().length}); this.flush_mutex.exec(function(){ var done = new $.Deferred(); // holds the mutex @@ -396,6 +405,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal options = options || {}; timeout = typeof options.timeout === 'number' ? options.timeout : 7500; + this.set('synch',{state:'connecting', pending: this.get('synch').pending}); + var order = this.db.get_order(order_id); order.to_invoice = options.to_invoice || false; @@ -417,7 +428,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal rpc.done(function(){ self.db.remove_order(order_id); - self.set('nbr_pending_operations',self.db.get_orders().length); + var pending = self.db.get_orders().length; + self.set('synch',{state: pending ? 'connecting' : 'connected', pending:pending}); }); return rpc; diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 9118ba15ea6..9e671d5039b 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -832,19 +832,32 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa renderElement: function() { var self = this; this._super(); + + var pending = this.pos.get('nbr_pending_orders'); + this.set_status(pending ? 'disconnected' : 'connected',pending); + this.$el.click(function(){ self.pos.flush(); }); }, + set_status: function(state,pending){ + var self = this; + this.$('.js_connected, .js_connecting, .js_disconnected, .js_pending').addClass('oe_hidden'); + this.$('.js_pending').html(pending || ''); + if(state === 'connected'){ + this.$('.js_connected').removeClass('oe_hidden'); + }else if(state === 'disconnected'){ + this.$('.js_disconnected, .js_pending').removeClass('oe_hidden'); + }else if(state === 'connecting'){ + this.$('.js_connecting, .js_pending').removeClass('oe_hidden'); + } + }, start: function(){ var self = this; - this.pos.bind('change:nbr_pending_operations', function(){ - self.renderElement(); + this.pos.bind('change:synch', function(pos,synch){ + self.set_status(synch.state, synch.pending); }); }, - get_nbr_pending: function(){ - return this.pos.get('nbr_pending_operations'); - }, }); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index a6b53a8fdbe..e268e62cb33 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -101,17 +101,18 @@ - -
- -
+
+ 0 +
+
- - -
-
+
+
- +
+ +
+