#1558 ticket.sales mark/unmark as reserved
This commit is contained in:
parent
2ce442a022
commit
d27402d4e6
|
@ -1,5 +1,6 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
import {throws} from 'assert';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($scope, $state, $http, vnApp, $translate) {
|
constructor($scope, $state, $http, vnApp, $translate) {
|
||||||
|
@ -9,7 +10,6 @@ class Controller {
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$stateParams = $state.params;
|
this.$stateParams = $state.params;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.deletable = false;
|
|
||||||
this.edit = {};
|
this.edit = {};
|
||||||
this.moreOptions = [
|
this.moreOptions = [
|
||||||
{callback: this.markAsReserved, name: 'Mark as reserved'},
|
{callback: this.markAsReserved, name: 'Mark as reserved'},
|
||||||
|
@ -336,11 +336,22 @@ class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
setReserved(reserved) {
|
setReserved(reserved) {
|
||||||
let sales = this.getCheckedLines();
|
let selectedSales = this.getCheckedLines();
|
||||||
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
|
let params = {sales: selectedSales, ticketFk: this.ticket.id, reserved: reserved};
|
||||||
|
|
||||||
this.$http.post(`/api/Sales/reserve`, params).then(() => {
|
let reservedSales = new Map();
|
||||||
this.$scope.model.refresh();
|
this.$http.post(`/api/Sales/reserve`, params).then(res => {
|
||||||
|
let isReserved = res.config.data.reserved;
|
||||||
|
|
||||||
|
res.config.data.sales.forEach(sale => {
|
||||||
|
reservedSales.set(sale.id, {reserved: isReserved});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sales.forEach(sale => {
|
||||||
|
const reservedSale = reservedSales.get(sale.id);
|
||||||
|
if (reservedSale)
|
||||||
|
sale.reserved = reservedSale.reserved;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue