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

46 lines
1.1 KiB
JavaScript

import ngModule from '../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
get claim() {
return this.entity;
}
set claim(value) {
this.entity = value;
}
showPickupOrder() {
this.vnReport.show(`Claims/${this.claim.id}/claim-pickup-pdf`, {
recipientId: this.claim.clientFk
});
}
sendPickupOrder() {
if (!this.claim.client.email) {
this.vnApp.showError(this.$t('The client does not have an email'));
return;
}
return this.vnEmail.send(`Claims/${this.claim.id}/claim-pickup-email`, {
recipient: this.claim.client.email,
recipientId: this.claim.clientFk
});
}
deleteClaim() {
return this.$http.delete(`Claims/${this.claim.id}`)
.then(() => {
this.vnApp.showSuccess(this.$t('Claim deleted!'));
this.$state.go('claim.index');
});
}
}
ngModule.vnComponent('vnClaimDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
claim: '<'
}
});