salix/modules/item/front/ticket-descriptor/addStowaway.js

44 lines
1.0 KiB
JavaScript

import ngModule from '../module';
class Controller {
constructor($state, $scope, $http) {
this.$scope = $scope;
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(res => {
this.ticket.ship.push = res.data[0];
this.hide;
});
}
show() {
this.$scope.dialog.show();
}
hide() {
this.$scope.dialog.hide();
}
}
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnAddStowaway', {
template: require('./addStowaway.html'),
controller: Controller,
bindings: {
ticket: '<'
}
});