2018-07-18 12:21:58 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class Controller {
|
2019-08-29 11:16:38 +00:00
|
|
|
constructor($translate, $scope, vnApp, $http, $state) {
|
|
|
|
this.$state = $state;
|
|
|
|
this.$scope = $scope;
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$http = $http;
|
|
|
|
this.$translate = $translate;
|
|
|
|
this.moreOptions = [
|
|
|
|
{name: 'Delete order', callback: () => this.showDeleteOrderDialog()}
|
|
|
|
];
|
2018-07-18 12:21:58 +00:00
|
|
|
}
|
2018-10-03 06:00:19 +00:00
|
|
|
|
2018-12-12 10:43:57 +00:00
|
|
|
set order(value) {
|
|
|
|
this._order = value;
|
|
|
|
|
|
|
|
if (value.isConfirmed) {
|
|
|
|
this._quicklinks = {
|
|
|
|
btnOne: {
|
|
|
|
icon: 'icon-ticket',
|
|
|
|
state: `ticket.index({q: '{"orderFk": ${value.id}}'})`,
|
|
|
|
tooltip: 'Order ticket list'
|
2019-03-05 11:37:43 +00:00
|
|
|
},
|
|
|
|
btnTwo: {
|
|
|
|
icon: 'person',
|
|
|
|
state: `client.card.summary({id: ${value.clientFk}})`,
|
|
|
|
tooltip: 'Client card'
|
2018-12-12 10:43:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get order() {
|
|
|
|
return this._order;
|
|
|
|
}
|
|
|
|
|
2018-10-03 06:00:19 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
2019-08-29 11:16:38 +00:00
|
|
|
|
|
|
|
deleteOrder(response) {
|
2019-10-30 15:57:14 +00:00
|
|
|
if (response === 'accept') {
|
2019-08-29 11:16:38 +00:00
|
|
|
const params = {id: this.order.id};
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.delete(`Orders/${params.id}`).then(() => {
|
2019-08-29 11:16:38 +00:00
|
|
|
this.$state.go('order.index');
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Order deleted'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showDeleteOrderDialog() {
|
|
|
|
this.$scope.deleteOrderConfirmation.show();
|
|
|
|
}
|
2018-07-18 12:21:58 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 11:16:38 +00:00
|
|
|
Controller.$inject = ['$translate', '$scope', 'vnApp', '$http', '$state'];
|
2018-07-18 12:21:58 +00:00
|
|
|
|
|
|
|
ngModule.component('vnOrderDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
order: '<'
|
|
|
|
},
|
|
|
|
controller: Controller
|
|
|
|
});
|