From 1a96fe1402a7c1bb3ef26b424ba60e1b21b65a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 25 Nov 2013 18:27:26 +0100 Subject: [PATCH] [WIP] point_of_sale: mobile ui optimisations bzr revid: fva@openerp.com-20131125172726-xp81rn938rtfwlbs --- addons/point_of_sale/static/src/css/pos.css | 5 ++++ addons/point_of_sale/static/src/js/screens.js | 12 ++++++-- addons/point_of_sale/static/src/js/widgets.js | 30 ++++++++++++++++--- addons/point_of_sale/static/src/xml/pos.xml | 2 +- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index d5fcd663fc3..8e1fcb8c28e 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -3,6 +3,10 @@ src: url(../fonts/Inconsolata.otf); } +.oe_hidden{ + display: none !important; +} + .pos { padding: 0; margin: 0; @@ -416,6 +420,7 @@ overflow: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; + -webkit-transform: translate3d(0,0,0); } .pos .product-list-container { diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index a133587fcca..4c5f2245e0d 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -970,7 +970,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa var currentOrder = this.pos.get('selectedOrder'); - if(currentOrder.getPaidTotal() + 0.000001 < currentOrder.getTotalTaxIncluded()){ + if(!this.isPaymentPaid()){ return; } @@ -1066,6 +1066,12 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.currentPaymentLines.remove([lineWidget.payment_line]); lineWidget.destroy(); }, + isPaymentPaid: function(){ + var currentOrder = this.pos.get('selectedOrder'); + return (currentOrder.getTotalTaxIncluded < 0.000001 + && currentOrder.getPaidTotal() + 0.000001 < currentOrder.getTotalTaxIncluded()); + + }, updatePaymentSummary: function() { var currentOrder = this.pos.get('selectedOrder'); var paidTotal = currentOrder.getPaidTotal(); @@ -1082,8 +1088,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } if(this.pos_widget.action_bar){ - this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0.000001); - this.pos_widget.action_bar.set_button_disabled('invoice', remaining > 0.000001); + this.pos_widget.action_bar.set_button_disabled('validation', this.isPaymentPaid()); + this.pos_widget.action_bar.set_button_disabled('invoice', this.isPaymentPaid()); } }, set_numpad_state: function(numpadState) { diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 6c65528f402..6a222cd1ca4 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -213,13 +213,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa var scroller = this.$('.order-scroller')[0]; var scrollbottom = true; var scrollTop = 0; - if(scroller){ + /*if(scroller){ var overflow_bottom = scroller.scrollHeight - scroller.clientHeight; scrollTop = scroller.scrollTop; if( !goto_bottom && scrollTop < 0.9 * overflow_bottom){ scrollbottom = false; } - } + }*/ this._super(); // freeing subwidgets @@ -245,11 +245,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa scroller = this.$('.order-scroller')[0]; if(scroller){ + //scroller.scrollTop = 1000000; + /* if(scrollbottom){ scroller.scrollTop = scroller.scrollHeight - scroller.clientHeight; }else{ scroller.scrollTop = scrollTop; - } + }*/ } }, update_summary: function(){ @@ -835,6 +837,12 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa self.pos.delete_current_order(); }); + $('body').on('keyup',function(event){ + if(event.which === 13){ + self.set_fullscreen(); + } + }); + //when a new order is created, add an order button widget self.pos.get('orders').bind('add', function(new_order){ var new_order_button = new module.OrderButtonWidget(null, { @@ -858,6 +866,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa self.pos.barcode_reader.connect(); + if(!$('#oe-fullscreenwidget-viewport').length){ + $('head').append(''); + $('head').append(''); + } + + $('.oe_leftbar').addClass('oe_hidden'); + instance.webclient.set_content_full_screen(true); if (!self.pos.get('pos_session')) { @@ -1050,7 +1065,11 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa } } }, - + set_fullscreen: function(){ + if(this.el.webkitRequestFullscreen){ + this.el.webkitRequestFullscreen(); + } + }, //shows or hide the leftpane (contains the list of orderlines, the numpad, the paypad, etc.) set_leftpane_visible: function(visible){ if(visible !== this.leftpane_visible){ @@ -1105,6 +1124,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa destroy: function() { this.pos.destroy(); instance.webclient.set_content_full_screen(false); + $('.oe_leftbar').removeClass('oe_hidden'); + $('#oe-pos-viewport').remove(); + $('#oe-pos-apple-mobile').remove(); this._super(); } }); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 6686015df5c..42e5b7ef44d 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -580,7 +580,7 @@ - +