113 lines
3.1 KiB
JavaScript
113 lines
3.1 KiB
JavaScript
import ngModule from '../module';
|
|
import Component from 'core/lib/component';
|
|
|
|
class Controller extends Component {
|
|
constructor($element, $, $httpParamSerializer) {
|
|
super($element, $);
|
|
this.$httpParamSerializer = $httpParamSerializer;
|
|
|
|
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.$.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() {
|
|
const params = {
|
|
clientId: this.claim.clientFk,
|
|
claimId: this.claim.id,
|
|
authorization: this.vnToken.token
|
|
};
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
let url = `api/report/claim-pickup-order?${serializedParams}`;
|
|
window.open(url);
|
|
}
|
|
|
|
confirmPickupOrder() {
|
|
this.$.confirmPickupOrder.show();
|
|
}
|
|
|
|
sendPickupOrder(response) {
|
|
if (response === 'accept') {
|
|
const params = {
|
|
recipient: this.claim.client.email,
|
|
clientId: this.claim.clientFk,
|
|
claimId: this.claim.id
|
|
};
|
|
this.$http.get(`email/claim-pickup-order`, {params}).then(
|
|
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
|
);
|
|
}
|
|
}
|
|
|
|
confirmDeleteClaim() {
|
|
this.$.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 = ['$element', '$scope', '$httpParamSerializer'];
|
|
|
|
ngModule.component('vnClaimDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
claim: '<',
|
|
tags: '<',
|
|
quicklinks: '<'
|
|
}
|
|
});
|