From f86fd1c249ebf13b816fcc95d7144dca3f360997 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Thu, 16 Mar 2017 13:04:33 -0700 Subject: [PATCH] [IMP] point_of_sale: show currently selected item in selection widget Before this the user was unable to see what value was currently selected in the selection widget (used for selecting users and fiscal positions). This implements support for an optional 'is_selected' function which gets an item from 'list' as a parameter and should return true when the item is currently selected. This also removes the fiscal position name from the fiscal position button because there wasn't much room on the button to fit the name and with this feature that information is redundant. --- addons/point_of_sale/static/src/css/pos.css | 7 +++++-- addons/point_of_sale/static/src/js/gui.js | 1 + addons/point_of_sale/static/src/js/popups.js | 5 +++-- addons/point_of_sale/static/src/js/screens.js | 8 +++++--- addons/point_of_sale/static/src/xml/pos.xml | 2 +- 5 files changed, 15 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 c0e51260ea9..904e5f1b432 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -2285,7 +2285,7 @@ td { width: auto; line-height: 50px; margin-top: -1px; - border-top: solid 3px #6EC89B; + border-top: solid 3px rgba(60,60,60,0.1); } .pos .popup.popup-selection .selection-item { @@ -2295,9 +2295,12 @@ td { text-align: left; padding: 0px 16px; } -.pos .popup.popup-selection .selection-item:nth-child(even) { +.pos .popup.popup-selection .selection-item:nth-child(odd) { background: rgb(247,247,247); } +.pos .popup.popup-selection .selection-item.selected { + background: #6EC89B; +} .pos .popup.popup-number { width: 300px; height: 450px; diff --git a/addons/point_of_sale/static/src/js/gui.js b/addons/point_of_sale/static/src/js/gui.js index 079159aac6f..a6e4a464951 100644 --- a/addons/point_of_sale/static/src/js/gui.js +++ b/addons/point_of_sale/static/src/js/gui.js @@ -248,6 +248,7 @@ var Gui = core.Class.extend({ list: list, confirm: function(user){ def.resolve(user); }, cancel: function(){ def.reject(); }, + is_selected: function(user){ return user === self.pos.get_cashier(); }, }); return def.then(function(user){ diff --git a/addons/point_of_sale/static/src/js/popups.js b/addons/point_of_sale/static/src/js/popups.js index a1ce0315cf8..274c54c61a8 100644 --- a/addons/point_of_sale/static/src/js/popups.js +++ b/addons/point_of_sale/static/src/js/popups.js @@ -155,11 +155,12 @@ gui.define_popup({name:'confirm', widget: ConfirmPopupWidget}); var SelectionPopupWidget = PopupWidget.extend({ template: 'SelectionPopupWidget', show: function(options){ - options = options || {}; var self = this; + options = options || {}; this._super(options); - this.list = options.list || []; + this.list = options.list || []; + this.is_selected = options.is_selected || function (item) { return false; }; this.renderElement(); }, click_item : function(event) { diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index d947f479fbf..ea93a52f1ad 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -2042,6 +2042,9 @@ var set_fiscal_position_button = ActionButtonWidget.extend({ var order = self.pos.get_order(); order.fiscal_position = fiscal_position; order.trigger('change'); + }, + is_selected: function (fiscal_position) { + return fiscal_position === self.pos.get_order().fiscal_position; } }); }, @@ -2056,9 +2059,8 @@ var set_fiscal_position_button = ActionButtonWidget.extend({ name = fiscal_position.display_name; } } - - return name; - } + return name; + }, }); define_action_button({ diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 498b0d4c516..9b3b5032715 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -1110,7 +1110,7 @@

-
+