[IMP] point_of_sale: some code simplifications

bzr revid: fva@openerp.com-20120611152929-t7jsnqfeg5y63knl
This commit is contained in:
Frédéric van der Essen
2012-06-11 17:29:29 +02:00
parent 0fcaa4edc7
commit 53d870aea0
2 changed files with 10 additions and 67 deletions
@@ -292,10 +292,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos_widget.set_numpad_visible(this.show_numpad && cashier_mode);
this.pos_widget.set_leftpane_visible(this.show_leftpane);
this.pos_widget.set_cashier_controls_visible(cashier_mode);
this.pos_widget.action_bar.set_total_visible(this.show_total);
this.pos_widget.action_bar.set_help_visible(!cashier_mode, function(){ self.help_button_action(); });
this.pos_widget.action_bar.set_logout_visible(cashier_mode, function(){ self.logout_button_action(); });
this.pos_widget.action_bar.set_close_visible(cashier_mode);
this.pos_widget.action_bar.set_element_visible('total', this.show_total);
this.pos_widget.action_bar.set_element_visible('help-button', !cashier_mode, function(){ self.help_button_action(); });
this.pos_widget.action_bar.set_element_visible('logout-button', cashier_mode, function(){ self.logout_button_action(); });
this.pos_widget.action_bar.set_element_visible('close-button', cashier_mode);
this.pos.barcode_reader.set_action_callback({
'cashier': self.barcode_cashier_action ? function(ean){ self.barcode_cashier_action(ean); } : undefined ,
@@ -337,25 +337,17 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.logout_visibility = true;
this.close_visibility = true;
},
set_element_visible: function(button, visible, action){
if(visible != this.visibility[button]){
this.visibility[button] = visible;
set_element_visible: function(element, visible, action){
if(visible != this.visibility[element]){
this.visibility[element] = visible;
if(visible){
this.$('.'+button).show();
this.$('.'+element).show();
}else{
this.$('.'+button).hide();
this.$('.'+element).hide();
}
}
if(visible && action){
this.$('.'+button).off('click').click(action);
}
},
set_all_elements_invisible: function(){
for(el in this.visibility){
if(this.visibility[el]){
this.visibility[el] = false;
this.$('.'+el).hide();
}
this.$('.'+element).off('click').click(action);
}
},
set_total_value: function(value){
@@ -381,55 +373,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
}
return undefined;
},
set_total_visible: function(visible){
if(visible !== this.total_visibility){
this.total_visibility = visible;
if(visible){
this.$element.find('.total').show();
}else{
this.$element.find('.total').hide();
}
}
},
set_help_visible: function(visible,action){
if(visible !== this.help_visibility){
this.help_visibility = visible;
if(visible){
this.$element.find('.help-button').show();
}else{
this.$element.find('.help-button').hide();
}
}
if(visible && action){
this.$element.find('.help-button').off('click').click(action);
}
},
set_logout_visible: function(visible,action){
if(visible !== this.logout_visibility){
this.logout_visibility = visible;
if(visible){
this.$element.find('.logout-button').show();
}else{
this.$element.find('.logout-button').hide();
}
}
if(visible && action){
this.$element.find('.logout-button').off('click').click(action);
}
},
set_close_visible: function(visible,action){
if(visible !== this.close_visibility){
this.close_visibility = visible;
if(visible){
this.$element.find('.close-button').show();
}else{
this.$element.find('.close-button').hide();
}
}
if(visible && action){
this.$element.find('.close-button').off('click').click(action);
}
},
});
module.ProductCategoriesWidget = module.PosBaseWidget.extend({