added card.reload and fixed remove stowaway not showing

This commit is contained in:
Gerard 2019-02-01 12:11:56 +01:00
parent 48aa29c4a3
commit d648db504c
3 changed files with 19 additions and 15 deletions

View File

@ -1,7 +1,9 @@
import ngModule from '../module';
class Controller {
constructor($state, $scope, $http) {
constructor($state, $scope, $http, vnApp, $translate) {
this.vnApp = vnApp;
this.$translate = $translate;
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
@ -17,9 +19,9 @@ class Controller {
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;
.then(() => {
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
@ -39,5 +41,8 @@ ngModule.component('vnAddStowaway', {
controller: Controller,
bindings: {
ticket: '<'
},
require: {
card: '^vnTicketCard'
}
});

View File

@ -40,7 +40,8 @@ class Controller {
shouldShowRemoveStowaway() {
if (!this._ticket)
return false;
return (this._ticket.stowaway || (this._ticket.ship && this._ticket.ship.length > 1));
return (this._ticket.stowaway || (this._ticket.ship && this._ticket.ship.length > 0));
}
onMoreChange(callback) {

View File

@ -1,7 +1,9 @@
import ngModule from '../module';
class Controller {
constructor($state, $scope, $http) {
constructor($state, $scope, $http, vnApp, $translate) {
this.vnApp = vnApp;
this.$translate = $translate;
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
@ -44,15 +46,8 @@ class Controller {
deleteStowaway(response) {
if (response === 'ACCEPT') {
this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => {
if (this.ticket.stowaway)
delete this.ticket.stowaway;
else {
for (let i = 0; i < this.ticket.ship.length; i++) {
if (this.ticket.ship[i].id === this.stowawayToDelete.id)
delete this.ticket.ship[i];
}
}
this.hide();
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
}
@ -78,5 +73,8 @@ ngModule.component('vnRemoveStowaway', {
controller: Controller,
bindings: {
ticket: '<'
},
require: {
card: '^vnTicketCard'
}
});