From 463e56b631b2eefbc6776ce802d6d080605fb719 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 21 Nov 2022 11:41:17 +0100 Subject: [PATCH] corrections --- db/changes/10503-november/00-ticket_canMerge.sql | 5 +++++ ...anbePostposed.sql => 00-ticket_canbePostponed.sql} | 1 + loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- modules/ticket/back/methods/ticket/merge.js | 11 +++++------ modules/ticket/back/models/ticket-future.json | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) rename db/changes/10503-november/{00-ticket_canbePostposed.sql => 00-ticket_canbePostponed.sql} (99%) diff --git a/db/changes/10503-november/00-ticket_canMerge.sql b/db/changes/10503-november/00-ticket_canMerge.sql index cb0e5cfe8..843237b64 100644 --- a/db/changes/10503-november/00-ticket_canMerge.sql +++ b/db/changes/10503-november/00-ticket_canMerge.sql @@ -7,3 +7,8 @@ BEGIN CALL vn.ticket_canbePostponed(vDated,TIMESTAMPADD(DAY, vScopeDays, vDated),vLitersMax,vLinesMax,vWarehouseFk); END $$ DELIMITER ; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) +VALUES + ('Ticket', 'getTicketsFuture', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'merge', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10503-november/00-ticket_canbePostposed.sql b/db/changes/10503-november/00-ticket_canbePostponed.sql similarity index 99% rename from db/changes/10503-november/00-ticket_canbePostposed.sql rename to db/changes/10503-november/00-ticket_canbePostponed.sql index 905d267a4..c691fa4bd 100644 --- a/db/changes/10503-november/00-ticket_canbePostposed.sql +++ b/db/changes/10503-november/00-ticket_canbePostponed.sql @@ -76,3 +76,4 @@ BEGIN HAVING liters <= IFNULL(vLitersMax, 9999) AND `lines` <= IFNULL(vLinesMax, 9999) AND ticketFuture; END$$ DELIMITER ; + diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 0f625a23d..07a6d7a64 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -136,5 +136,5 @@ "Not enough privileges to edit a client": "Not enough privileges to edit a client", "You don't have grant privilege": "You don't have grant privilege", "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", - "MOVE_TICKET_CONFIRMATION": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) merged with [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})" + "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) merged with [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 965bc97c1..18d2218c9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -238,5 +238,5 @@ "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", "You don't have grant privilege": "No tienes privilegios para dar privilegios", "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "MOVE_TICKET_CONFIRMATION": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) fusionado con [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})" + "Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) fusionado con [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})" } diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 0f1fa38bf..04f8d83af 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -22,7 +22,7 @@ module.exports = Self => { } }); - Self.merge = async (ctx, tickets, options) => { + Self.merge = async(ctx, tickets, options) => { const httpRequest = ctx.req; const $t = httpRequest.__; const origin = httpRequest.headers.origin; @@ -42,7 +42,7 @@ module.exports = Self => { for (let ticket of tickets) { const fullPath = `${origin}/#!/ticket/${ticket.id}/summary`; const fullPathFuture = `${origin}/#!/ticket/${ticket.ticketFuture}/summary`; - const message = $t('MOVE_TICKET_CONFIRMATION', { + const message = $t('Ticket merged', { originDated: dateUtil.toString(new Date(ticket.originETD)), futureDated: dateUtil.toString(new Date(ticket.destETD)), id: ticket.id, @@ -51,13 +51,12 @@ module.exports = Self => { fullPathFuture }); if (!ticket.id || !ticket.ticketFuture) continue; - await models.Sale.updateAll({ ticketFk: ticket.id }, { ticketFk: ticket.ticketFuture }, myOptions); + await models.Sale.updateAll({ticketFk: ticket.id}, {ticketFk: ticket.ticketFuture}, myOptions); await models.Ticket.setDeleted(ctx, ticket.id, myOptions); await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); - }; - if (tx) { - await tx.commit(); } + if (tx) + await tx.commit(); } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/back/models/ticket-future.json b/modules/ticket/back/models/ticket-future.json index 2a1b45def..00277ab8a 100644 --- a/modules/ticket/back/models/ticket-future.json +++ b/modules/ticket/back/models/ticket-future.json @@ -5,7 +5,7 @@ { "accessType": "READ", "principalType": "ROLE", - "principalId": "$authenticated", + "principalId": "employee", "permission": "ALLOW" } ]