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

66 lines
1.7 KiB
JavaScript

import ngModule from '../module';
import Component from 'core/lib/component';
class Controller extends Component {
constructor($element, $) {
super($element, $);
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();
}
}
ngModule.component('vnOrderDescriptor', {
template: require('./index.html'),
bindings: {
order: '<'
},
controller: Controller
});