#951 ticket.descriptor añadir polizon
This commit is contained in:
parent
e9bc3f00a1
commit
345acc1353
|
@ -8,6 +8,8 @@ import './card';
|
|||
import './descriptor';
|
||||
import './descriptor-popover';
|
||||
import './ticket-descriptor';
|
||||
import './ticket-descriptor/addStowaway';
|
||||
import './ticket-descriptor/removeStowaway';
|
||||
import './ticket-descriptor-popover';
|
||||
import './data';
|
||||
import './tags';
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<vn-dialog
|
||||
vn-id="dialog"
|
||||
class="modalForm"
|
||||
on-open="$ctrl.getPossibleStowaways()">
|
||||
<tpl-body>
|
||||
<vn-horizontal pad-medium class="header">
|
||||
<h5><span translate>Stowaways to add</span></h5>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal pad-medium>
|
||||
<vn-table>
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th number>Ticket id</vn-th>
|
||||
<vn-th number>Shipped</vn-th>
|
||||
<vn-th number>Agency</vn-th>
|
||||
<vn-th number>Warehouse</vn-th>
|
||||
<vn-th number>State</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="ticket in $ctrl.possibleStowaways" class="clickable" ng-click="$ctrl.addStowaway($index)">
|
||||
<vn-td number>{{ticket.id}}</vn-td>
|
||||
<vn-td number>{{ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td number>{{ticket.agencyMode.name}}</vn-td>
|
||||
<vn-td number>{{ticket.warehouse.name}}</vn-td>
|
||||
<vn-td number>{{ticket.state.state.name}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
<vn-empty-rows ng-if="$ctrl.possibleStowaways.length === 0" translate>
|
||||
No results
|
||||
</vn-empty-rows>
|
||||
</vn-table>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
|
@ -0,0 +1,46 @@
|
|||
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 => {
|
||||
console.log(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(() => {
|
||||
this.card.reload();
|
||||
});
|
||||
}
|
||||
|
||||
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: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnTicketCard'
|
||||
}
|
||||
});
|
|
@ -91,6 +91,17 @@
|
|||
icon="{{::$ctrl.quicklinks.btnThree.icon}}">
|
||||
</vn-icon>
|
||||
</a>
|
||||
<vn-button-menu
|
||||
ng-if="$ctrl.ticket.ship.length > 1"
|
||||
vn-id="stowaways-button"
|
||||
icon="icon-polizon"
|
||||
show-filter="false"
|
||||
show-field="id"
|
||||
value-field="id"
|
||||
vn-tooltip="Ship stowaways"
|
||||
data="$ctrl.ticket.ship"
|
||||
on-change="$ctrl.goToTicket(value)">
|
||||
</vn-button-menu>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-dialog class="dialog-summary"
|
||||
|
@ -138,4 +149,6 @@
|
|||
on-response="$ctrl.deleteTicket(response)"
|
||||
question="You are going to delete this ticket"
|
||||
message="Continue anyway?">
|
||||
</vn-confirm>
|
||||
</vn-confirm>
|
||||
<vn-add-stowaway vn-id="addStowaway" ticket="$ctrl.ticket"></vn-add-stowaway>
|
||||
<vn-remove-stowaway vn-id="removeStowaway" ticket="$ctrl.ticket"></vn-remove-stowaway>
|
|
@ -1,4 +1,5 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope, $http, vnApp, $translate) {
|
||||
|
@ -8,15 +9,34 @@ class Controller {
|
|||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.moreOptions = [
|
||||
{callback: this.showAddTurnDialog, name: 'Add turn'},
|
||||
{callback: this.showDeleteTicketDialog, name: 'Delete ticket'}
|
||||
{callback: this.showAddTurnDialog, name: 'Add turn', 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: () => this.shouldShowRemoveStowaway()}
|
||||
];
|
||||
}
|
||||
|
||||
shouldShowRemoveStowaway() {
|
||||
if (!this._ticket)
|
||||
return false;
|
||||
return (this._ticket.stowaway || this._ticket.ship.length > 1);
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
callback.call(this);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
get isEditable() {
|
||||
try {
|
||||
return !this.ticket.tracking.state.alertLevel;
|
||||
|
@ -58,6 +78,15 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
showAddStowaway() {
|
||||
this.$scope.addStowaway.show();
|
||||
console.log(this.$state.getCurrentPath());
|
||||
}
|
||||
|
||||
showRemoveStowaway() {
|
||||
this.$scope.removeStowaway.show();
|
||||
}
|
||||
|
||||
get ticket() {
|
||||
return this._ticket;
|
||||
}
|
||||
|
@ -67,13 +96,31 @@ class Controller {
|
|||
|
||||
if (!value) return;
|
||||
|
||||
this._quicklinks = {
|
||||
let links = {
|
||||
btnOne: {
|
||||
icon: 'person',
|
||||
state: `client.card.summary({id: ${value.clientFk}})`,
|
||||
tooltip: 'Client card'
|
||||
}
|
||||
};
|
||||
}};
|
||||
if (value.stowaway) {
|
||||
links.btnTwo = {
|
||||
icon: 'icon-polizon',
|
||||
state: `ticket.card.summary({id: ${value.stowaway.shipFk}})`,
|
||||
tooltip: 'Ship'
|
||||
};
|
||||
}
|
||||
console.log(value.ship);
|
||||
|
||||
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;
|
||||
|
||||
this._quicklinks = links;
|
||||
}
|
||||
|
||||
set quicklinks(value = {}) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getPossibleStowaways', {
|
||||
description: 'Returns mana of a salesperson of a ticket',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'ticket id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getPossibleStowaways`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getPossibleStowaways = async ticketFk => {
|
||||
let ship = await Self.app.models.Ticket.findById(ticketFk);
|
||||
let lowestDate = new Date(ship.shipped.getTime());
|
||||
lowestDate.setHours(0, 0, -1, 0);
|
||||
|
||||
let highestDate = new Date(ship.shipped.getTime());
|
||||
highestDate.setHours(23, 59, 59);
|
||||
|
||||
|
||||
let possibleStowaways = await Self.app.models.Ticket.find({
|
||||
where: {
|
||||
clientFk: ship.clientFk,
|
||||
addressFk: ship.addressFk,
|
||||
agencyModeFk: ship.agencyModeFk,
|
||||
warehouse: {neq: ship.warehouseFk},
|
||||
shipped: {
|
||||
between: [lowestDate.toJSON(), highestDate.toJSON()]
|
||||
}
|
||||
},
|
||||
include: [
|
||||
{relation: 'agencyMode'},
|
||||
{relation: 'warehouse'},
|
||||
{relation: 'state',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
relation: 'state',
|
||||
fields: ['id', 'name'],
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
return possibleStowaways;
|
||||
};
|
||||
};
|
|
@ -32,6 +32,9 @@
|
|||
"State":{
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Stowaway": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Ticket": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -16,4 +16,5 @@ module.exports = Self => {
|
|||
require('../methods/ticket/getShipped')(Self);
|
||||
require('../methods/ticket/getLanded')(Self);
|
||||
require('../methods/ticket/filter')(Self);
|
||||
require('../methods/ticket/getPossibleStowaways')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue