Browse Source

💚 pos_keyboard/

pull/155/head
Ivan Yelizariev 5 years ago
committed by Vincent Van Rossem
parent
commit
ebfdf17ad2
  1. 55
      pos_keyboard/static/src/js/pos.js

55
pos_keyboard/static/src/js/pos.js

@ -4,6 +4,7 @@
Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr> Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr>
Copyright 2019 ssaid <https://github.com/ssaid> Copyright 2019 ssaid <https://github.com/ssaid>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
/* eslint-disable complexity */
odoo.define('pos_keyboard.pos', function (require) { odoo.define('pos_keyboard.pos', function (require) {
"use strict"; "use strict";
@ -13,27 +14,6 @@ odoo.define('pos_keyboard.pos', function (require) {
var screens = require('point_of_sale.screens'); var screens = require('point_of_sale.screens');
var PopupWidget = require('point_of_sale.popups'); var PopupWidget = require('point_of_sale.popups');
var _super_posmodel = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
initialize: function (session, attributes) {
var self = this;
this.keypad = new Keypad({'pos': this});
_super_posmodel.initialize.call(this, session, attributes);
this.ready.then(function(){
self.keypad.set_action_callback(function(data){
var current_screen = self.gui.current_screen;
var current_popup = self.gui.current_popup;
if (current_popup) {
current_popup.keypad_action(data);
} else if (current_screen.numpad && current_screen.numpad.keypad_action) {
current_screen.numpad.keypad_action(data);
}
});
});
}
});
gui.Gui.prototype.popup_classes.filter(function(c){ gui.Gui.prototype.popup_classes.filter(function(c){
return c.name === 'password'; return c.name === 'password';
})[0].widget.include({ })[0].widget.include({
@ -128,10 +108,10 @@ odoo.define('pos_keyboard.pos', function (require) {
escape: 'escape', escape: 'escape',
}; };
this.data = { this.data = {
type: undefined,
val: undefined
// type: undefined,
// val: undefined
}; };
this.action_callback = undefined;
delete this.action_callback;
this.active = false; this.active = false;
}, },
@ -151,7 +131,7 @@ odoo.define('pos_keyboard.pos', function (require) {
//remove action callback //remove action callback
reset_action_callback: function(){ reset_action_callback: function(){
this.action_callback = undefined;
delete this.action_callback;
}, },
// starts catching keyboard events and tries to interpret keystrokes, // starts catching keyboard events and tries to interpret keystrokes,
@ -242,8 +222,8 @@ odoo.define('pos_keyboard.pos', function (require) {
self.data.type = type.escape; self.data.type = type.escape;
ok = true; ok = true;
} else { } else {
self.data.type = undefined;
self.data.val = undefined;
delete self.data.type;
delete self.data.val;
ok = false; ok = false;
} }
@ -272,6 +252,27 @@ self.action_callback(self.data);
} }
}); });
var _super_posmodel = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
initialize: function (session, attributes) {
var self = this;
this.keypad = new Keypad({'pos': this});
_super_posmodel.initialize.call(this, session, attributes);
this.ready.then(function(){
self.keypad.set_action_callback(function(data){
var current_screen = self.gui.current_screen;
var current_popup = self.gui.current_popup;
if (current_popup) {
current_popup.keypad_action(data);
} else if (current_screen.numpad && current_screen.numpad.keypad_action) {
current_screen.numpad.keypad_action(data);
}
});
});
}
});
return { return {
Keypad: Keypad Keypad: Keypad
}; };

Loading…
Cancel
Save