2018-08-30 06:50:03 +00:00
|
|
|
import ngModule from '../module';
|
2019-01-18 12:36:13 +00:00
|
|
|
import './style.scss';
|
2018-08-30 06:50:03 +00:00
|
|
|
|
|
|
|
class Controller {
|
2018-11-08 14:20:42 +00:00
|
|
|
constructor($state, $scope, $http, vnApp, $translate) {
|
2018-08-30 06:50:03 +00:00
|
|
|
this.$scope = $scope;
|
2018-09-04 09:49:00 +00:00
|
|
|
this.$state = $state;
|
2018-11-08 14:20:42 +00:00
|
|
|
this.$http = $http;
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$translate = $translate;
|
|
|
|
this.moreOptions = [
|
2019-01-18 12:36:13 +00:00
|
|
|
{callback: this.showAddTurnDialog, name: 'Add turn', show: true},
|
2019-01-20 15:47:04 +00:00
|
|
|
{callback: this.showDeleteTicketDialog, name: 'Delete ticket', show: true}/* ,
|
2019-01-18 12:36:13 +00:00
|
|
|
{callback: this.showAddStowaway, name: 'Add stowaway', show: true},
|
2019-01-20 15:47:04 +00:00
|
|
|
{callback: this.showRemoveStowaway, name: 'Remove stowaway', show: false}
|
|
|
|
*/
|
2018-11-08 14:20:42 +00:00
|
|
|
];
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 12:36:13 +00:00
|
|
|
shouldShowRemoveStowaway() {
|
|
|
|
if (!this._ticket)
|
|
|
|
return false;
|
|
|
|
return (this._ticket.stowaway || this._ticket.ship.length > 1);
|
|
|
|
}
|
|
|
|
|
2018-11-08 14:20:42 +00:00
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:36:13 +00:00
|
|
|
goToTicket(ticketID) {
|
|
|
|
this.$state.go('ticket.card.sale', {id: ticketID});
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoreOpen() {
|
|
|
|
let options = this.moreOptions.filter(o => {
|
|
|
|
return o.show === true || typeof o.show === 'function' && o.show();
|
|
|
|
});
|
|
|
|
this.$scope.moreButton.data = options;
|
|
|
|
}
|
|
|
|
|
2018-11-08 14:20:42 +00:00
|
|
|
get isEditable() {
|
|
|
|
try {
|
|
|
|
return !this.ticket.tracking.state.alertLevel;
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add Turn
|
|
|
|
showAddTurnDialog() {
|
|
|
|
this.$scope.addTurn.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
addTurn(day) {
|
|
|
|
let params = {ticketFk: this.ticket.id, weekDay: day};
|
|
|
|
this.$http.patch(`/ticket/api/TicketWeeklies`, params).then(() => {
|
|
|
|
this.$scope.addTurn.hide();
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete Ticket
|
|
|
|
showDeleteTicketDialog() {
|
|
|
|
if (!this.isEditable) {
|
|
|
|
this.vnApp.showError(this.$translate.instant('This ticket cant be deleted'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$scope.deleteConfirmation.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteTicket(response) {
|
|
|
|
if (response === 'ACCEPT') {
|
|
|
|
let params = {id: this.ticket.id};
|
|
|
|
this.$http.post(`/ticket/api/Tickets/deleted`, params).then(() => {
|
|
|
|
this.$state.go('ticket.index');
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Ticket deleted'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-18 12:36:13 +00:00
|
|
|
showAddStowaway() {
|
|
|
|
this.$scope.addStowaway.show();
|
|
|
|
console.log(this.$state.getCurrentPath());
|
|
|
|
}
|
|
|
|
|
|
|
|
showRemoveStowaway() {
|
|
|
|
this.$scope.removeStowaway.show();
|
|
|
|
}
|
|
|
|
|
2018-09-04 09:49:00 +00:00
|
|
|
get ticket() {
|
|
|
|
return this._ticket;
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 09:49:00 +00:00
|
|
|
set ticket(value) {
|
|
|
|
this._ticket = value;
|
|
|
|
|
|
|
|
if (!value) return;
|
|
|
|
|
2019-01-18 12:36:13 +00:00
|
|
|
let links = {
|
2018-09-04 09:49:00 +00:00
|
|
|
btnOne: {
|
|
|
|
icon: 'person',
|
|
|
|
state: `client.card.summary({id: ${value.clientFk}})`,
|
|
|
|
tooltip: 'Client card'
|
2019-01-18 12:36:13 +00:00
|
|
|
}};
|
|
|
|
if (value.stowaway) {
|
|
|
|
links.btnTwo = {
|
|
|
|
icon: 'icon-polizon',
|
|
|
|
state: `ticket.card.summary({id: ${value.stowaway.shipFk}})`,
|
|
|
|
tooltip: 'Ship'
|
|
|
|
};
|
|
|
|
}
|
2019-01-20 15:47:04 +00:00
|
|
|
/*
|
2019-01-18 12:36:13 +00:00
|
|
|
if (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)
|
|
|
|
this.shipStowaways = value.ship;
|
2019-01-20 15:47:04 +00:00
|
|
|
*/
|
2019-01-18 12:36:13 +00:00
|
|
|
this._quicklinks = links;
|
2018-09-04 09:49:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set quicklinks(value = {}) {
|
|
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2018-11-08 14:20:42 +00:00
|
|
|
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate'];
|
2018-08-30 06:50:03 +00:00
|
|
|
|
|
|
|
ngModule.component('vnTicketDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
|
|
|
},
|
|
|
|
controller: Controller
|
|
|
|
});
|