reset watcher on changes #1678

This commit is contained in:
Joan Sanchez 2019-09-09 12:35:59 +02:00
parent 1f5a75b285
commit 73f438c300
1 changed files with 21 additions and 11 deletions

View File

@ -189,11 +189,11 @@ class Controller {
onStateChange(value) { onStateChange(value) {
let params = {ticketFk: this.$state.params.id, stateFk: value}; let params = {ticketFk: this.$state.params.id, stateFk: value};
this.$http.post(`/api/TicketTrackings/changeState`, params).then(() => { this.$http.post(`/api/TicketTrackings/changeState`, params).then(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
this.card.reload(); this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).finally(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -248,8 +248,10 @@ class Controller {
const query = `/api/tickets/${this.ticket.id}/transferSales`; const query = `/api/tickets/${this.ticket.id}/transferSales`;
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
if (res.data) this.$scope.watcher.updateOriginalData();
this.goToTicket(res.data.id); this.goToTicket(res.data.id);
}).finally(() => {
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -315,9 +317,11 @@ class Controller {
if (this.editedPrice != this.sale.price) { if (this.editedPrice != this.sale.price) {
this.$http.post(`/api/Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => { this.$http.post(`/api/Sales/${this.edit.id}/updatePrice`, {newPrice: this.editedPrice}).then(res => {
this.sale.price = res.data.price; this.sale.price = res.data.price;
this.$scope.watcher.updateOriginalData();
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).finally(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -389,6 +393,9 @@ class Controller {
if (reservedSale) if (reservedSale)
sale.reserved = reservedSale.reserved; sale.reserved = reservedSale.reserved;
}); });
}).finally(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -453,12 +460,13 @@ class Controller {
const data = {quantity: parseInt(sale.quantity)}; const data = {quantity: parseInt(sale.quantity)};
const query = `/api/Sales/${sale.id}/updateQuantity`; const query = `/api/Sales/${sale.id}/updateQuantity`;
this.$http.post(query, data).then(() => { this.$http.post(query, data).then(() => {
this.$scope.watcher.updateOriginalData();
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).catch(e => { }).catch(e => {
this.$scope.model.refresh(); this.$scope.model.refresh();
throw e; throw e;
}).finally(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -469,11 +477,13 @@ class Controller {
const data = {newConcept: sale.concept}; const data = {newConcept: sale.concept};
const query = `/api/Sales/${sale.id}/updateConcept`; const query = `/api/Sales/${sale.id}/updateConcept`;
this.$http.post(query, data).then(() => { this.$http.post(query, data).then(() => {
this.$scope.watcher.updateOriginalData();
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).catch(e => { }).catch(e => {
this.$scope.model.refresh(); this.$scope.model.refresh();
throw e; throw e;
}).finally(() => {
if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData();
}); });
} }
@ -500,10 +510,10 @@ class Controller {
sale.price = newSale.price; sale.price = newSale.price;
sale.item = newSale.item; sale.item = newSale.item;
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).finally(() => {
if (this.newInstances().length === 0) if (this.newInstances().length === 0)
this.$scope.watcher.updateOriginalData(); this.$scope.watcher.updateOriginalData();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}); });
} }