2019-01-18 12:37:26 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class Controller {
|
2019-02-01 11:11:56 +00:00
|
|
|
constructor($state, $scope, $http, vnApp, $translate) {
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$translate = $translate;
|
2019-01-18 12:37:26 +00:00
|
|
|
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 => {
|
|
|
|
this.ticketStowaways = res.data;
|
|
|
|
this.$scope.dialog.show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteStowaway(response) {
|
|
|
|
if (response === 'ACCEPT') {
|
|
|
|
this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => {
|
2019-02-01 11:11:56 +00:00
|
|
|
this.card.reload();
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
2019-01-18 12:37:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: '<'
|
2019-02-01 11:11:56 +00:00
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^vnTicketCard'
|
2019-01-18 12:37:26 +00:00
|
|
|
}
|
|
|
|
});
|