[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.
This commit is contained in:
committed by
Pierre Masereel
parent
9e780ab711
commit
f86fd1c249
@@ -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;
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -1110,7 +1110,7 @@
|
||||
<p class="title"><t t-esc=" widget.options.title || 'Select' " /></p>
|
||||
<div class='selection scrollable-y touch-scrollable'>
|
||||
<t t-foreach="widget.list || []" t-as="item">
|
||||
<div class='selection-item' t-att-data-item-index='item_index'>
|
||||
<div t-attf-class="selection-item {{ widget.is_selected.call(widget, item.item) ? 'selected' : '' }}" t-att-data-item-index='item_index'>
|
||||
<t t-esc='item.label'/>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user