routes without vehicle or vehicles without drop off now throw
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-05-05 13:36:54 +02:00
parent deeb306b1a
commit 245243aa14
4 changed files with 39 additions and 29 deletions

View File

@ -1,12 +1,12 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('getDeliveryPoint', { Self.remoteMethod('getDeliveryPoint', {
description: 'get the deliveryPoint address ', description: 'get the deliveryPoint address',
accessType: 'WRITE', accessType: 'WRITE',
accepts: { accepts: {
arg: 'vehicleId', arg: 'vehicleId',
type: 'number', type: 'number',
required: true,
description: 'vehicle id asigned in the route', description: 'vehicle id asigned in the route',
required: true,
http: {source: 'path'} http: {source: 'path'}
}, },
returns: { returns: {
@ -21,8 +21,9 @@ module.exports = Self => {
Self.getDeliveryPoint = async vehicleId => { Self.getDeliveryPoint = async vehicleId => {
let vehicle = await Self.app.models.Vehicle.findById(vehicleId); let vehicle = await Self.app.models.Vehicle.findById(vehicleId);
let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk); if (!vehicle.deliveryPointFk) return;
let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk);
return deliveryPoint.ubication; return deliveryPoint.ubication;
}; };

View File

@ -5,9 +5,10 @@
data="$ctrl.tickets" data="$ctrl.tickets"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-data-viewer model="model"> <vn-data-viewer
model="model">
<form name="form"> <form name="form">
<vn-card class="vn-pa-md"> <vn-card class="vn-pa-lg">
<vn-tool-bar> <vn-tool-bar>
<vn-button <vn-button
icon="icon-wand" icon="icon-wand"
@ -22,7 +23,7 @@
</vn-button> </vn-button>
</vn-tool-bar> </vn-tool-bar>
</vn-card> </vn-card>
<vn-card class="vn-mt-md"> <vn-card class="vn-mt-lg">
<vn-table model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)"> <vn-table model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
<vn-thead> <vn-thead>
<vn-tr> <vn-tr>
@ -31,14 +32,14 @@
model="model"> model="model">
</vn-multi-check> </vn-multi-check>
</vn-th> </vn-th>
<vn-th class="order-field">Order</vn-th> <vn-th>Order</vn-th>
<vn-th number>Ticket</vn-th> <vn-th expand>Street</vn-th>
<vn-th>City</vn-th>
<vn-th translate-attr="{title: 'Postcode'}" shrink>PC</vn-th>
<vn-th expand>Client</vn-th> <vn-th expand>Client</vn-th>
<vn-th shrink>Packages</vn-th> <vn-th shrink>Packages</vn-th>
<vn-th shrink></vn-th> <vn-th shrink></vn-th>
<vn-th>Warehouse</vn-th> <vn-th number>Ticket</vn-th>
<vn-th translate-attr="{title: 'Postcode'}" shrink>PC</vn-th>
<vn-th expand>Street</vn-th>
<vn-th shrink></vn-th> <vn-th shrink></vn-th>
<vn-th shrink></vn-th> <vn-th shrink></vn-th>
</vn-tr> </vn-tr>
@ -50,21 +51,18 @@
ng-model="ticket.checked"> ng-model="ticket.checked">
</vn-check> </vn-check>
</vn-td> </vn-td>
<vn-td class="order-field"> <vn-td>
<vn-input-number <vn-input-number
on-change="$ctrl.setPriority(ticket.id, ticket.priority)" on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
ng-model="ticket.priority" ng-model="ticket.priority"
rule="Ticket" rule="Ticket"
class="dense"> class="dense"
display-controls=true>
</vn-input-number> </vn-input-number>
</vn-td> </vn-td>
<vn-td number> <vn-td expand title="{{ticket.address.street}}">{{ticket.address.street}}</vn-td>
<span <vn-td expand>{{ticket.address.city}}</vn-td>
ng-click="ticketDescriptor.show($event, ticket.id)" <vn-td shrink>{{ticket.address.postalCode}}</vn-td>
class="link">
{{ticket.id}}
</span>
</vn-td>
<vn-td expand> <vn-td expand>
<span <span
ng-click="clientDescriptor.show($event, ticket.clientFk)" ng-click="clientDescriptor.show($event, ticket.clientFk)"
@ -74,9 +72,13 @@
</vn-td> </vn-td>
<vn-td shrink>{{ticket.packages}}</vn-td> <vn-td shrink>{{ticket.packages}}</vn-td>
<vn-td shrink>{{::ticket.volume | number:1}}</vn-td> <vn-td shrink>{{::ticket.volume | number:1}}</vn-td>
<vn-td expand>{{ticket.warehouse.name}}</vn-td> <vn-td number>
<vn-td shrink>{{ticket.address.postalCode}}</vn-td> <span
<vn-td expand title="{{ticket.address.street}}">{{ticket.address.street}}</vn-td> ng-click="ticketDescriptor.show($event, ticket.id)"
class="link">
{{ticket.id}}
</span>
</vn-td>
<vn-td shrink> <vn-td shrink>
<vn-icon <vn-icon
ng-if="ticket.notes.length" ng-if="ticket.notes.length"

View File

@ -1,6 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section'; import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
import UserError from 'core/lib/user-error';
class Controller extends Section { class Controller extends Section {
get route() { get route() {
@ -49,14 +50,18 @@ class Controller extends Section {
} }
goToBuscaman() { goToBuscaman() {
if (!this.route.vehicleFk)
throw new UserError(`The route doesn't have a vehicle`);
let query = `Routes/${this.route.vehicleFk}/getDeliveryPoint`; let query = `Routes/${this.route.vehicleFk}/getDeliveryPoint`;
let deliveryPointAddress;
let addresses;
this.$http.get(query).then(response => { this.$http.get(query).then(response => {
deliveryPointAddress = response.data; if (!response.data)
}).then(() => { throw new UserError(`The route's vehicle doesn't have a delivery point`);
addresses = deliveryPointAddress;
return response.data;
}).then(address => {
let addresses;
if (address) addresses = address;
let lines = this.getSelectedItems(this.tickets); let lines = this.getSelectedItems(this.tickets);
let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=';

View File

@ -9,3 +9,5 @@ Tickets to add: Tickets a añadir
Ticket not found: No se ha encontrado el ticket Ticket not found: No se ha encontrado el ticket
The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta
PC: CP PC: CP
The route's vehicle doesn't have a delivery point: El vehículo de la ruta no tiene un punto de entrega
The route doesn't have a vehicle: La ruta no tiene un vehículo