104 lines
2.8 KiB
JavaScript
104 lines
2.8 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
class Controller {
|
|
constructor($scope, $state, $http, $translate, vnApp, aclService) {
|
|
this.$scope = $scope;
|
|
this.$state = $state;
|
|
this.$http = $http;
|
|
this.$translate = $translate;
|
|
this.vnApp = vnApp;
|
|
this.aclService = aclService;
|
|
this.moreOptions = [
|
|
{callback: this.showPickupOrder, name: 'Show Pickup order'},
|
|
{callback: this.confirmPickupOrder, name: 'Send Pickup order'},
|
|
{callback: this.confirmDeleteClaim, name: 'Delete claim', acl: 'salesAssistant'}
|
|
];
|
|
}
|
|
|
|
onMoreOpen() {
|
|
let options = this.moreOptions.filter(option => {
|
|
const hasAclProperty = Object.hasOwnProperty.call(option, 'acl');
|
|
|
|
return !hasAclProperty || (hasAclProperty && this.aclService.hasAny([option.acl]));
|
|
});
|
|
this.$scope.moreButton.data = options;
|
|
}
|
|
|
|
onMoreChange(callback) {
|
|
callback.call(this);
|
|
}
|
|
|
|
get claim() {
|
|
return this._claim;
|
|
}
|
|
|
|
set claim(value) {
|
|
this._claim = value;
|
|
|
|
if (!value) return;
|
|
|
|
this._quicklinks = {
|
|
btnOne: {
|
|
icon: 'person',
|
|
state: `client.card.summary({id: ${value.clientFk}})`,
|
|
tooltip: 'Client card'
|
|
},
|
|
btnTwo: {
|
|
icon: 'icon-ticket',
|
|
state: `ticket.card.summary({id: ${this.claim.ticketFk}})`,
|
|
tooltip: 'Claimed ticket'
|
|
}
|
|
};
|
|
}
|
|
|
|
set quicklinks(value = {}) {
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
|
}
|
|
|
|
get quicklinks() {
|
|
return this._quicklinks;
|
|
}
|
|
|
|
showPickupOrder() {
|
|
let url = `report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
|
|
window.open(url);
|
|
}
|
|
|
|
confirmPickupOrder() {
|
|
this.$scope.confirmPickupOrder.show();
|
|
}
|
|
|
|
sendPickupOrder(response) {
|
|
if (response === 'accept') {
|
|
this.$http.post(`email/claim-pickup-order`, {claimFk: this.claim.id}).then(
|
|
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
|
);
|
|
}
|
|
}
|
|
|
|
confirmDeleteClaim() {
|
|
this.$scope.confirmDeleteClaim.show();
|
|
}
|
|
|
|
deleteClaim(response) {
|
|
if (response === 'accept') {
|
|
this.$http.delete(`Claims/${this.claim.id}`).then(() => {
|
|
this.vnApp.showSuccess(this.$translate.instant('Claim deleted!'));
|
|
this.$state.go('claim.index');
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService'];
|
|
|
|
ngModule.component('vnClaimDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
claim: '<',
|
|
tags: '<',
|
|
quicklinks: '<'
|
|
}
|
|
});
|