barcode_error_action: function(code){
this.pos_widget.screen_selector.show_popup('error-barcode',code.code);
},
- // shows an action bar on the screen. The actionbar is automatically shown when you add a button
- // with add_action_button()
- show_action_bar: function(){
- this.pos_widget.action_bar.show();
- },
-
- // hides the action bar. The actionbar is automatically hidden when it is empty
- hide_action_bar: function(){
- this.pos_widget.action_bar.hide();
- },
-
- // adds a new button to the action bar. The button definition takes three parameters, all optional :
- // - label: the text below the button
- // - icon: a small icon that will be shown
- // - click: a callback that will be executed when the button is clicked.
- // the method returns a reference to the button widget, and automatically show the actionbar.
- add_action_button: function(button_def){
- this.show_action_bar();
- return this.pos_widget.action_bar.add_new_button(button_def);
- },
// this method shows the screen and sets up all the widget related to this screen. Extend this method
// if you want to alter the behavior of the screen.
this.$el.removeClass('oe_hidden');
}
- if(this.pos_widget.action_bar.get_button_count() > 0){
- this.show_action_bar();
- }else{
- this.hide_action_bar();
- }
-
var self = this;
this.pos_widget.set_numpad_visible(this.show_numpad);
if(this.pos.barcode_reader){
this.pos.barcode_reader.reset_action_callbacks();
}
- this.pos_widget.action_bar.destroy_buttons();
},
// this methods hides the screen. It's not a good place to put your cleanup stuff as it is called on the
},
});
- module.ActionButtonWidget = instance.web.Widget.extend({
- template:'ActionButtonWidget',
- icon_template:'ActionButtonWidgetWithIcon',
- init: function(parent, options){
- this._super(parent, options);
- this.label = options.label || 'button';
- this.rightalign = options.rightalign || false;
- this.click_action = options.click;
- this.disabled = options.disabled || false;
- if(options.icon){
- this.icon = options.icon;
- this.template = this.icon_template;
- }
- },
- set_disabled: function(disabled){
- if(this.disabled != disabled){
- this.disabled = !!disabled;
- this.renderElement();
- }
- },
- renderElement: function(){
- this._super();
- if(this.click_action && !this.disabled){
- this.$el.click(_.bind(this.click_action, this));
- }
- },
- });
-
- module.ActionBarWidget = instance.web.Widget.extend({
- template:'ActionBarWidget',
- init: function(parent, options){
- this._super(parent,options);
- this.button_list = [];
- this.buttons = {};
- this.visibility = {};
- },
- set_element_visible: function(element, visible, action){
- if(visible != this.visibility[element]){
- this.visibility[element] = !!visible;
- if(visible){
- this.$('.'+element).removeClass('oe_hidden');
- }else{
- this.$('.'+element).addClass('oe_hidden');
- }
- }
- if(visible && action){
- this.action[element] = action;
- this.$('.'+element).off('click').click(action);
- }
- },
- set_button_disabled: function(name, disabled){
- var b = this.buttons[name];
- if(b){
- b.set_disabled(disabled);
- }
- },
- destroy_buttons:function(){
- for(var i = 0; i < this.button_list.length; i++){
- this.button_list[i].destroy();
- }
- this.button_list = [];
- this.buttons = {};
- return this;
- },
- get_button_count: function(){
- return this.button_list.length;
- },
- add_new_button: function(button_options){
- var button = new module.ActionButtonWidget(this,button_options);
- this.button_list.push(button);
- if(button_options.name){
- this.buttons[button_options.name] = button;
- }
- button.appendTo(this.$('.pos-actionbar-button-list'));
- return button;
- },
- show:function(){
- this.$el.removeClass('oe_hidden');
- },
- hide:function(){
- this.$el.addClass('oe_hidden');
- },
- });
-
module.ProductCategoriesWidget = module.PosBaseWidget.extend({
template: 'ProductCategoriesWidget',
init: function(parent, options){
// - a header, containing the list of orders
// - a leftpane, containing the list of bought products (orderlines)
// - a rightpane, containing the screens (see pos_screens.js)
- // - an actionbar on the bottom, containing various action buttons
// - popups
// - an onscreen keyboard
// a screen_selector which controls the switching between screens and the showing/closing of popups
this.username = new module.UsernameWidget(this,{});
this.username.replace(this.$('.placeholder-UsernameWidget'));
- this.action_bar = new module.ActionBarWidget(this);
- this.action_bar.replace(this.$(".placeholder-RightActionBar"));
-
this.actionpad = new module.ActionpadWidget(this, {});
this.actionpad.replace(this.$('.placeholder-ActionpadWidget'));
</div>
</div>
- <div class='subwindow collapsed'>
- <div class='subwindow-container'>
- <div class='subwindow-container-fix'>
- <div class='placeholder-LeftActionBar'></div>
- </div>
- </div>
- </div>
</div>
</div>
</div>
</div>
</div>
-
- <div class='subwindow collapsed'>
- <div class='subwindow-container'>
- <div class='subwindow-container-fix'>
- <div class='placeholder-RightActionBar'></div>
- </div>
- </div>
- </div>
</div>
</div>
</div>
</t>
- <t t-name="ActionBarWidget">
- <div class="pos-actionbar">
- <ul class="pos-actionbar-button-list">
- </ul>
- </div>
- </t>
-
- <t t-name="ActionButtonWidget">
- <li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '') + (widget.disabled ? 'disabled ' : '')">
- <div class='label'>
- <t t-esc="widget.label" />
- </div>
- </li>
- </t>
-
- <t t-name="ActionButtonWidgetWithIcon">
- <li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '') + (widget.disabled ? 'disabled ' : '')">
- <div class='icon'>
- <img t-att-src="widget.icon" />
- <div class='iconlabel'><t t-esc="widget.label" /></div>
- </div>
- </li>
- </t>
-
<!-- Onscreen Keyboard :
http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/ -->
<t t-name="OnscreenKeyboardFull">