added card.reload and fixed remove stowaway not showing
This commit is contained in:
parent
48aa29c4a3
commit
d648db504c
|
@ -1,7 +1,9 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($state, $scope, $http) {
|
constructor($state, $scope, $http, vnApp, $translate) {
|
||||||
|
this.vnApp = vnApp;
|
||||||
|
this.$translate = $translate;
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
|
@ -17,9 +19,9 @@ class Controller {
|
||||||
addStowaway(index) {
|
addStowaway(index) {
|
||||||
let params = {id: this.possibleStowaways[index].id, shipFk: this.ticket.id};
|
let params = {id: this.possibleStowaways[index].id, shipFk: this.ticket.id};
|
||||||
this.$http.post(`/api/Stowaways/`, params)
|
this.$http.post(`/api/Stowaways/`, params)
|
||||||
.then(res => {
|
.then(() => {
|
||||||
this.ticket.ship.push = res.data[0];
|
this.card.reload();
|
||||||
this.hide;
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,5 +41,8 @@ ngModule.component('vnAddStowaway', {
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
bindings: {
|
bindings: {
|
||||||
ticket: '<'
|
ticket: '<'
|
||||||
|
},
|
||||||
|
require: {
|
||||||
|
card: '^vnTicketCard'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,8 @@ class Controller {
|
||||||
shouldShowRemoveStowaway() {
|
shouldShowRemoveStowaway() {
|
||||||
if (!this._ticket)
|
if (!this._ticket)
|
||||||
return false;
|
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) {
|
onMoreChange(callback) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($state, $scope, $http) {
|
constructor($state, $scope, $http, vnApp, $translate) {
|
||||||
|
this.vnApp = vnApp;
|
||||||
|
this.$translate = $translate;
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
|
@ -44,15 +46,8 @@ class Controller {
|
||||||
deleteStowaway(response) {
|
deleteStowaway(response) {
|
||||||
if (response === 'ACCEPT') {
|
if (response === 'ACCEPT') {
|
||||||
this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => {
|
this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => {
|
||||||
if (this.ticket.stowaway)
|
this.card.reload();
|
||||||
delete this.ticket.stowaway;
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
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();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,5 +73,8 @@ ngModule.component('vnRemoveStowaway', {
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
bindings: {
|
bindings: {
|
||||||
ticket: '<'
|
ticket: '<'
|
||||||
|
},
|
||||||
|
require: {
|
||||||
|
card: '^vnTicketCard'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue