diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 6764ca1f1..4c7deb8fd 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -161,6 +161,7 @@
"The nif cannot be empty": "El NIF no puede quedar en blanco",
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
"ASSIGN_ZONE_FIRST": "Asigna una zona primero",
+ "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
"You can't upload images on the test environment": "No puedes subir imágenes en el entorno de pruebas",
- "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria"
+ "Sorts whole route": "Reordena ruta entera"
}
\ No newline at end of file
diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js
index bb5b34ca3..eab9f3473 100644
--- a/modules/route/back/methods/route/guessPriority.js
+++ b/modules/route/back/methods/route/guessPriority.js
@@ -1,5 +1,5 @@
module.exports = Self => {
- Self.remoteMethod('guessPriority', {
+ Self.remoteMethodCtx('guessPriority', {
description: 'Changes automatically the priority of the tickets in a route',
accessType: 'READ',
accepts: [{
@@ -19,10 +19,32 @@ module.exports = Self => {
}
});
- Self.guessPriority = async id => {
- let query = `CALL vn.routeGuessPriority(?)`;
+ Self.guessPriority = async(ctx, id) => {
+ const userId = ctx.req.accessToken.userId;
+ const $t = ctx.req.__; // $translate
+ const query = `CALL vn.routeGuessPriority(?)`;
+ const tx = await Self.beginTransaction({});
- let options = [id];
- return await Self.rawSql(query, options);
+ try {
+ let options = {transaction: tx};
+
+ const priority = await Self.rawSql(query, [id], options);
+
+ let logRecord = {
+ originFk: id,
+ userFk: userId,
+ action: 'update',
+ changedModel: 'Route',
+ description: $t('Sorts whole route')
+ };
+
+ await Self.app.models.RouteLog.create(logRecord, options);
+
+ await tx.commit();
+ return priority;
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
};
};
diff --git a/modules/route/back/methods/route/specs/guessPriority.spec.js b/modules/route/back/methods/route/specs/guessPriority.spec.js
index 448501e67..4e70d727e 100644
--- a/modules/route/back/methods/route/specs/guessPriority.spec.js
+++ b/modules/route/back/methods/route/specs/guessPriority.spec.js
@@ -15,9 +15,15 @@ describe('route guessPriority()', () => {
});
it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => {
+ const ctx = {
+ req: {
+ accessToken: {userId: 9},
+ __: () => {}
+ },
+ };
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
- await app.models.Route.guessPriority(targetRouteId);
+ await app.models.Route.guessPriority(ctx, targetRouteId);
let routeTickets = await app.models.Ticket.find({where: {routeFk: targetRouteId}, fields: ['id', 'priority']});
expect(routeTickets.length).toEqual(2);
diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html
index 1f91dd3f1..7e03a3981 100644
--- a/modules/route/front/tickets/index.html
+++ b/modules/route/front/tickets/index.html
@@ -31,13 +31,13 @@
model="model">
- Order
+ Order
Ticket
Client
Packages
- m³
+ m³
Warehouse
- Postcode
+ PC
Street
@@ -50,7 +50,7 @@
ng-model="ticket.checked">
-
+
{{ticket.packages}}
- {{::ticket.volume | number:1}}
+ {{::ticket.volume | number:1}}
{{ticket.warehouse.name}}
- {{ticket.address.postalCode}}
+ {{ticket.address.postalCode}}
{{ticket.address.street}}