import ngModule from '../module'; class Controller { constructor($state, $scope, $http) { this.$scope = $scope; this.$state = $state; this.$http = $http; } getTicketStowaways() { if (this.ticket.stowaway) { this.ticketStowaways = [this.ticket.stowaway]; this.showDeleteConfirm(0); } else if (this.ticket.ship.length > 1) { let filter = { where: {shipFk: this.ticket.id}, include: { relation: 'ticket', scope: { include: [ {relation: 'agencyMode'}, {relation: 'warehouse'}, {relation: 'state', scope: { fields: ['stateFk'], include: { relation: 'state' } }, }, ] } } }; let json = encodeURIComponent(JSON.stringify(filter)); this.$http.get(`/api/Stowaways?filter=${json}`).then(res => { console.log(res.data); this.ticketStowaways = res.data; this.$scope.dialog.show(); }); } } deleteStowaway(response) { if (response === 'ACCEPT') { this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => { this.card.reload(); }); } } showDeleteConfirm(index) { this.stowawayToDelete = this.ticketStowaways[index]; this.$scope.confirmationDialog.show(); } show() { this.getTicketStowaways(); } hide() { this.$scope.dialog.hide(); } } Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate']; ngModule.component('vnRemoveStowaway', { template: require('./removeStowaway.html'), controller: Controller, bindings: { ticket: '<' }, require: { card: '^vnTicketCard' } });