Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
1989232949
|
@ -18,8 +18,9 @@ class Controller {
|
|||
addStowaway(index) {
|
||||
let params = {id: this.possibleStowaways[index].id, shipFk: this.ticket.id};
|
||||
this.$http.post(`/api/Stowaways/`, params)
|
||||
.then(() => {
|
||||
this.card.reload();
|
||||
.then(res => {
|
||||
this.ticket.ship.push = res.data[0];
|
||||
this.hide;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -39,8 +40,5 @@ ngModule.component('vnAddStowaway', {
|
|||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnTicketCard'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,17 +10,38 @@ class Controller {
|
|||
this.$translate = $translate;
|
||||
this.moreOptions = [
|
||||
{callback: this.showAddTurnDialog, name: 'Add turn', show: true},
|
||||
{callback: this.showDeleteTicketDialog, name: 'Delete ticket', show: true}/* ,
|
||||
{callback: this.showDeleteTicketDialog, name: 'Delete ticket', show: true},
|
||||
{callback: this.showAddStowaway, name: 'Add stowaway', show: true},
|
||||
{callback: this.showRemoveStowaway, name: 'Remove stowaway', show: false}
|
||||
*/
|
||||
{callback: this.showRemoveStowaway, name: 'Remove stowaway', show: () => this.shouldShowRemoveStowaway()},
|
||||
/* callback: this.showChangeShipped, name: 'Change shipped hour', show: true} */
|
||||
];
|
||||
}
|
||||
|
||||
// Change shipped hour
|
||||
showChangeShipped() {
|
||||
if (!this.isEditable) {
|
||||
this.vnApp.showError(this.$translate.instant('This ticket can\'t be modified'));
|
||||
return;
|
||||
}
|
||||
this.newShipped = new Date(this.ticket.shipped);
|
||||
this.$scope.changeShippedDialog.show();
|
||||
}
|
||||
|
||||
changeShipped(response) {
|
||||
console.log(response);
|
||||
if (response === 'ACCEPT') {
|
||||
let params = {shipped: this.newShipped};
|
||||
this.$http.patch(`/ticket/api/Tickets/${this.ticket.id}/`, params).then(() => {
|
||||
this.$state.go('ticket.index');
|
||||
this.vnApp.showSuccess(this.$translate.instant('Shipped hour updated'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
shouldShowRemoveStowaway() {
|
||||
if (!this._ticket)
|
||||
return false;
|
||||
return (this._ticket.stowaway || this._ticket.ship.length > 1);
|
||||
return (this._ticket.stowaway || (this._ticket.ship && this._ticket.ship.length > 1));
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
|
@ -81,7 +102,6 @@ class Controller {
|
|||
|
||||
showAddStowaway() {
|
||||
this.$scope.addStowaway.show();
|
||||
console.log(this.$state.getCurrentPath());
|
||||
}
|
||||
|
||||
showRemoveStowaway() {
|
||||
|
@ -110,16 +130,16 @@ class Controller {
|
|||
tooltip: 'Ship'
|
||||
};
|
||||
}
|
||||
/*
|
||||
if (value.ship.length == 1) {
|
||||
|
||||
if (value.ship && value.ship.length == 1) {
|
||||
links.btnThree = {
|
||||
icon: 'icon-polizon',
|
||||
state: `ticket.card.summary({id: ${value.ship[0].id}})`,
|
||||
tooltip: 'Stowaway'
|
||||
};
|
||||
} else if (value.ship.length > 1)
|
||||
} else if (value.ship && value.ship.length > 1)
|
||||
this.shipStowaways = value.ship;
|
||||
*/
|
||||
|
||||
this._quicklinks = links;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,15 @@ class Controller {
|
|||
deleteStowaway(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
this.$http.delete(`/api/Stowaways/${this.stowawayToDelete.id}`).then(res => {
|
||||
this.card.reload();
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +79,5 @@ ngModule.component('vnRemoveStowaway', {
|
|||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnTicketCard'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports = Self => {
|
|||
|
||||
let possibleStowaways = await Self.app.models.Ticket.find({
|
||||
where: {
|
||||
id: {neq: ticketFk},
|
||||
clientFk: ship.clientFk,
|
||||
addressFk: ship.addressFk,
|
||||
agencyModeFk: ship.agencyModeFk,
|
||||
|
|
|
@ -7,9 +7,9 @@ class Controller {
|
|||
this.filter = {
|
||||
include: [
|
||||
{relation: 'warehouse', scope: {fields: ['name']}},
|
||||
// {relation: 'ship'},
|
||||
{relation: 'ship'},
|
||||
{relation: 'agencyMode', scope: {fields: ['name']}},
|
||||
// {relation: 'stowaway'},
|
||||
{relation: 'stowaway'},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
|
|
Loading…
Reference in New Issue