salix/modules/order/front/descriptor/index.js

71 lines
1.8 KiB
JavaScript

import ngModule from '../module';
class Controller {
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()}
];
}
set order(value) {
this._order = value;
if (!value) return;
if (value.isConfirmed) {
this._quicklinks = {
btnOne: {
icon: 'icon-ticket',
state: `ticket.index({q: '{"orderFk": ${value.id}}'})`,
tooltip: 'Order ticket list'
},
btnTwo: {
icon: 'person',
state: `client.card.summary({id: ${value.clientFk}})`,
tooltip: 'Client card'
}
};
}
}
get order() {
return this._order;
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}
get quicklinks() {
return this._quicklinks;
}
deleteOrder(response) {
if (response === 'accept') {
const params = {id: this.order.id};
this.$http.delete(`Orders/${params.id}`).then(() => {
this.$state.go('order.index');
this.vnApp.showSuccess(this.$translate.instant('Order deleted'));
});
}
}
showDeleteOrderDialog() {
this.$scope.deleteOrderConfirmation.show();
}
}
Controller.$inject = ['$translate', '$scope', 'vnApp', '$http', '$state'];
ngModule.component('vnOrderDescriptor', {
template: require('./index.html'),
bindings: {
order: '<'
},
controller: Controller
});