From d4e278363009abaa45090212dc3e50a2f0430086 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:39:07 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20corregidas=20traducciones,=20elimin?= =?UTF-8?q?ado=20destroyAll=20y=20a=C3=B1adida=20transacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/es.json | 2 +- .../back/methods/expedition/deleteExpeditions.js | 10 +++++++--- .../ticket/back/methods/expedition/moveExpeditions.js | 4 ++-- .../methods/expedition/specs/deleteExpeditions.spec.js | 2 +- modules/ticket/front/expedition/index.html | 2 +- modules/ticket/front/expedition/locale/es.yml | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bd9de41c29..2d9bae1d83 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -236,5 +236,5 @@ "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route not exists": "Esta ruta no existe" + "This route does not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 5b9d0daaa3..2419d3a5e8 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -33,9 +33,13 @@ module.exports = Self => { } try { - const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionIds} - }, myOptions); + const promises = []; + for (let expeditionId of expeditionIds) { + const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions); + promises.push(deletedExpedition); + } + + const deletedExpeditions = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index d0f8aa8939..cef35ab867 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -70,12 +70,12 @@ module.exports = Self => { try { if (args.routeId) { const route = await models.Route.findById(args.routeId, null, myOptions); - if (!route) throw new UserError('This route not exists'); + if (!route) throw new UserError('This route does not exists'); } const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; for (let expeditionsId of args.expeditionIds) { - const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js index 0a47c78da1..14bdf7aea6 100644 --- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -10,7 +10,7 @@ describe('ticket deleteExpeditions()', () => { const expeditionIds = [12, 13]; const result = await models.Expedition.deleteExpeditions(expeditionIds, options); - expect(result.count).toEqual(2); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 0ebe388c12..ec6dc7ee2b 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -159,7 +159,7 @@ diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 68812f9850..278dcc8f2a 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -3,4 +3,4 @@ Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta New ticket with route: Nuevo ticket con ruta -Id route: Id ruta \ No newline at end of file +Route id: Id ruta \ No newline at end of file