From ebfdf17ad22ed6fbfd40b891c381a28e792fad6a Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 10 Feb 2020 08:07:12 +0000 Subject: [PATCH] :green_heart: pos_keyboard/ --- pos_keyboard/static/src/js/pos.js | 55 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/pos_keyboard/static/src/js/pos.js b/pos_keyboard/static/src/js/pos.js index d6b2b91..b7b1821 100644 --- a/pos_keyboard/static/src/js/pos.js +++ b/pos_keyboard/static/src/js/pos.js @@ -4,6 +4,7 @@ Copyright 2019 Kolushov Alexandr Copyright 2019 ssaid License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */ +/* eslint-disable complexity */ odoo.define('pos_keyboard.pos', function (require) { "use strict"; @@ -13,27 +14,6 @@ odoo.define('pos_keyboard.pos', function (require) { var screens = require('point_of_sale.screens'); 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){ return c.name === 'password'; })[0].widget.include({ @@ -128,10 +108,10 @@ odoo.define('pos_keyboard.pos', function (require) { escape: 'escape', }; this.data = { - type: undefined, - val: undefined + // type: undefined, + // val: undefined }; - this.action_callback = undefined; + delete this.action_callback; this.active = false; }, @@ -151,7 +131,7 @@ odoo.define('pos_keyboard.pos', function (require) { //remove action callback reset_action_callback: function(){ - this.action_callback = undefined; + delete this.action_callback; }, // 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; ok = true; } else { - self.data.type = undefined; - self.data.val = undefined; + delete self.data.type; + delete self.data.val; 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 { Keypad: Keypad };