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

80 lines
2.0 KiB
JavaScript
Raw Normal View History

2018-08-24 11:16:11 +00:00
import ngModule from '../module';
class Controller {
2019-01-25 14:08:11 +00:00
constructor($scope, $state, $http, $translate, vnApp) {
this.$scope = $scope;
2018-08-24 11:16:11 +00:00
this.$state = $state;
2019-01-25 14:08:11 +00:00
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
this.moreOptions = [
2019-02-12 06:42:19 +00:00
{callback: this.showPickupOrder, name: 'Show Pickup order'},
{callback: this.confirmPickupOrder, name: 'Send Pickup order'}
2019-01-25 14:08:11 +00:00
];
2018-10-03 06:00:19 +00:00
}
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'
2019-01-30 07:44:15 +00:00
},
btnTwo: {
icon: 'icon-ticket',
state: `ticket.card.summary({id: ${this.claim.ticketFk}})`,
tooltip: 'Claimed ticket'
2018-10-03 06:00:19 +00:00
}
};
2018-08-24 11:16:11 +00:00
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}
get quicklinks() {
return this._quicklinks;
}
2019-01-25 14:08:11 +00:00
onMoreChange(callback) {
callback.call(this);
}
2019-02-12 06:42:19 +00:00
showPickupOrder() {
let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
window.open(url);
2019-01-25 14:08:11 +00:00
}
2019-02-12 06:42:19 +00:00
confirmPickupOrder() {
this.$scope.confirmPickupOrder.show();
}
sendPickupOrder(response) {
if (response === 'ACCEPT') {
2019-01-28 11:28:22 +00:00
this.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then(
2019-01-25 14:08:11 +00:00
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);
}
}
2018-08-24 11:16:11 +00:00
}
2019-01-25 14:08:11 +00:00
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp'];
2018-08-24 11:16:11 +00:00
ngModule.component('vnClaimDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
claim: '<',
tags: '<',
quicklinks: '<'
}
});