diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index d354c9eef..5c11e955e 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -68,6 +68,7 @@ export default class MultiCheck extends FormInput { this.checkAll = value; this.toggle(); + this.emit('change', value); } /** diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 2f27ef758..646b2df93 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -52,8 +52,8 @@ - + @@ -69,7 +69,7 @@ - diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index f99be5cf4..48a22a9f5 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -142,15 +142,17 @@ class Controller extends Section { return indexList; } + resetChanges() { + if (this.newInstances().length === 0) + this.$.watcher.updateOriginalData(); + } + changeState(value) { - let params = {ticketFk: this.$params.id, code: value}; - this.$http.post('TicketTrackings/changeState', params).then(() => { + const params = {ticketFk: this.$params.id, code: value}; + return this.$http.post('TicketTrackings/changeState', params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); this.card.reload(); - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } removeSales() { @@ -159,7 +161,7 @@ class Controller extends Section { this.$http.post(`Sales/removes`, params).then(() => { this.removeSelectedSales(); this.vnApp.showSuccess(this.$t('Data saved!')); - }); + }).finally(() => this.resetChanges()); } removeSelectedSales() { @@ -169,9 +171,6 @@ class Controller extends Section { this.sales.splice(index, 1); }); - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - this.refreshTotal(); } @@ -251,10 +250,7 @@ class Controller extends Section { sale.price = res.data.price; this.edit = null; this.vnApp.showSuccess(this.$t('Data saved!')); - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } this.$.editPricePopover.hide(); @@ -318,9 +314,7 @@ class Controller extends Section { sale.discount = this.edit.discount; this.edit = null; - }).catch(e => { - this.vnApp.showError(e.message); - }); + }).finally(() => this.resetChanges()); } getNewPrice() { @@ -381,10 +375,7 @@ class Controller extends Section { if (reservedSale) sale.reserved = reservedSale.reserved; }); - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } newOrderFromTicket() { @@ -444,16 +435,12 @@ class Controller extends Section { */ updateQuantity(sale) { const data = {quantity: sale.quantity}; - const query = `Sales/${sale.id}/updateQuantity`; - this.$http.post(query, data).then(() => { + this.$http.post(`Sales/${sale.id}/updateQuantity`, data).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }).catch(e => { this.$.model.refresh(); throw e; - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } /* @@ -461,16 +448,12 @@ class Controller extends Section { */ changeConcept(sale) { const data = {newConcept: sale.concept}; - const query = `Sales/${sale.id}/updateConcept`; - this.$http.post(query, data).then(() => { + this.$http.post(`Sales/${sale.id}/updateConcept`, data).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }).catch(e => { this.$.model.refresh(); throw e; - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } /* @@ -496,10 +479,7 @@ class Controller extends Section { sale.item = newSale.item; this.vnApp.showSuccess(this.$t('Data saved!')); - }).finally(() => { - if (this.newInstances().length === 0) - this.$.watcher.updateOriginalData(); - }); + }).finally(() => this.resetChanges()); } isTicketEditable() {