From 88633f37412af112c173d2548c8c99f942000564 Mon Sep 17 00:00:00 2001 From: gerard Date: Mon, 9 Jul 2018 15:06:36 +0200 Subject: [PATCH] fixed bug were VAT was not disponible and refactor of popover --- client/core/src/components/popover/popover.js | 9 ---- client/ticket/src/sale/index.js | 45 ++++++++----------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/client/core/src/components/popover/popover.js b/client/core/src/components/popover/popover.js index 197f7773a..2a8760e6a 100644 --- a/client/core/src/components/popover/popover.js +++ b/client/core/src/components/popover/popover.js @@ -75,15 +75,6 @@ export default class Popover extends Component { this.document.addEventListener('keydown', this.docKeyDownHandler); this.document.addEventListener('focusin', this.docFocusInHandler); - let firstFocusable = this.element.querySelector('input, textarea'); - if (firstFocusable) { - firstFocusable.addEventListener('focus', () => { - firstFocusable.select(); - }); - setTimeout(() => { - firstFocusable.focus(); - }, 200); - } this.deregisterCallback = this.$transitions.onStart({}, () => this.hide()); this.relocate(); diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js index e46f472ff..e18abd4a2 100644 --- a/client/ticket/src/sale/index.js +++ b/client/ticket/src/sale/index.js @@ -51,10 +51,8 @@ class Controller { getVAT() { this.$http.get(`/ticket/api/Tickets/${this.ticket.id}/getVAT`).then(res => { - if (res.data) { - this.VAT = res.data; - this.total = this.subTotal + this.VAT; - } + this.VAT = res.data || 0; + this.total = this.subTotal + this.VAT; }); } @@ -205,6 +203,19 @@ class Controller { this.$state.go("ticket.card.sale", {id: ticketID}); } + // Focus First Input + focusFirstInput(e) { + let firstFocusable = e.querySelector('input, textarea'); + if (firstFocusable) { + firstFocusable.addEventListener('focus', () => { + firstFocusable.select(); + }); + setTimeout(() => { + firstFocusable.focus(); + }, 200); + } + } + // Slesperson Mana getManaSalespersonMana() { this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => { @@ -233,6 +244,7 @@ class Controller { }; this.$.editPricePopover.parent = event.target; this.$.editPricePopover.show(); + this.focusFirstInput(this.$.editPricePopover.$element[0]); } updatePrice() { @@ -256,11 +268,13 @@ class Controller { }]; this.$.editPopover.parent = event.target; this.$.editPopover.show(); + this.focusFirstInput(this.$.editPopover.$element[0]); } - async showEditDialog() { + showEditDialog() { this.edit = this.getCheckedLines(); this.$.editDialog.show(); + this.focusFirstInput(this.$.editDialog.$element[0]); } hideEditDialog() { @@ -282,27 +296,6 @@ class Controller { }); } - /* updateLine() { - if (this.edit.quantity != this.sale.quantity) { - this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => { - this.sale.quantity = this.edit.quantity; - }); - } - - if (this.edit.price != this.sale.price) { - this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.edit.price}).then(() => { - this.sale.price = this.edit.price; - }); - } - - if (this.edit.discount != this.sale.discount) { - this.$http.post(`/ticket/api/Sales/updateDiscount`, {id: this.edit.id, discount: this.edit.discount}).then(() => { - this.sale.discount = this.edit.discount; - }); - } - this.$.edit.hide(); - }*/ - /** * Unmark sale as reserved */