48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
class Controller {
|
|
constructor($state, $, $http, vnApp, $translate) {
|
|
this.vnApp = vnApp;
|
|
this.$translate = $translate;
|
|
this.$ = $;
|
|
this.$state = $state;
|
|
this.$http = $http;
|
|
}
|
|
|
|
getPossibleStowaways() {
|
|
this.$http.get(`/api/Tickets/${this.ticket.id}/getPossibleStowaways`)
|
|
.then(res => {
|
|
this.possibleStowaways = res.data;
|
|
});
|
|
}
|
|
|
|
addStowaway(index) {
|
|
let params = {id: this.possibleStowaways[index].id, shipFk: this.ticket.id};
|
|
this.$http.post(`/api/Stowaways/`, params)
|
|
.then(() => {
|
|
this.cardReload();
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
this.$.dialog.hide();
|
|
});
|
|
}
|
|
|
|
show() {
|
|
this.$.dialog.show();
|
|
}
|
|
|
|
hide() {
|
|
this.$.dialog.hide();
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate'];
|
|
|
|
ngModule.component('vnAddStowaway', {
|
|
template: require('./addStowaway.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
ticket: '<',
|
|
cardReload: '&?'
|
|
}
|
|
});
|