import ngModule from '../module'; class Controller { constructor($scope, $state, $http, $translate, vnApp) { this.$scope = $scope; this.$state = $state; this.$http = $http; this.$translate = $translate; this.vnApp = vnApp; this.moreOptions = [ {callback: this.showConfirmDialog, name: 'Pickup order'} ]; } 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; } onMoreChange(callback) { callback.call(this); } showConfirmDialog() { this.$scope.confirmDialog.show(); } returnDialog(response) { if (response === 'CANCEL') { let url = `/api/report/rpt-claim-pickup-order?claimFk=${this.claim.id}`; window.open(url); } else if (response === 'ACCEPT') { this.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then( () => this.vnApp.showMessage(this.$translate.instant('Notification sent!')) ); } } } Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; ngModule.component('vnClaimDescriptor', { template: require('./index.html'), controller: Controller, bindings: { claim: '<', tags: '<', quicklinks: '<' } });