From 245243aa147aa8a52cb2804ad04051a98208754c Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 5 May 2021 13:36:54 +0200 Subject: [PATCH] routes without vehicle or vehicles without drop off now throw --- .../back/methods/route/getDeliveryPoint.js | 7 ++-- modules/route/front/tickets/index.html | 42 ++++++++++--------- modules/route/front/tickets/index.js | 15 ++++--- modules/route/front/tickets/locale/es.yml | 4 +- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/modules/route/back/methods/route/getDeliveryPoint.js b/modules/route/back/methods/route/getDeliveryPoint.js index 59b22904f..e5a50805a 100644 --- a/modules/route/back/methods/route/getDeliveryPoint.js +++ b/modules/route/back/methods/route/getDeliveryPoint.js @@ -1,12 +1,12 @@ module.exports = Self => { Self.remoteMethod('getDeliveryPoint', { - description: 'get the deliveryPoint address ', + description: 'get the deliveryPoint address', accessType: 'WRITE', accepts: { arg: 'vehicleId', type: 'number', - required: true, description: 'vehicle id asigned in the route', + required: true, http: {source: 'path'} }, returns: { @@ -21,8 +21,9 @@ module.exports = Self => { Self.getDeliveryPoint = async 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; }; diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 92a112747..3c4bb439b 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -5,9 +5,10 @@ data="$ctrl.tickets" auto-load="true"> - +
- + - + @@ -31,14 +32,14 @@ model="model"> - Order - Ticket + Order + Street + City + PC Client Packages - Warehouse - PC - Street + Ticket @@ -50,21 +51,18 @@ ng-model="ticket.checked"> - + + class="dense" + display-controls=true> - - - {{ticket.id}} - - + {{ticket.address.street}} + {{ticket.address.city}} + {{ticket.address.postalCode}} {{ticket.packages}} {{::ticket.volume | number:1}} - {{ticket.warehouse.name}} - {{ticket.address.postalCode}} - {{ticket.address.street}} + + + {{ticket.id}} + + { - deliveryPointAddress = response.data; - }).then(() => { - addresses = deliveryPointAddress; + if (!response.data) + throw new UserError(`The route's vehicle doesn't have a delivery point`); + + return response.data; + }).then(address => { + let addresses; + if (address) addresses = address; let lines = this.getSelectedItems(this.tickets); let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml index 042f5227b..e1abd31b4 100644 --- a/modules/route/front/tickets/locale/es.yml +++ b/modules/route/front/tickets/locale/es.yml @@ -8,4 +8,6 @@ Add ticket: Añadir ticket Tickets to add: Tickets a añadir 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 -PC: CP \ No newline at end of file +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 \ No newline at end of file