From 93c9ef6f4cbb3e4b2d752019e4b374fefe09eb23 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 15 Jan 2025 10:25:21 +0100 Subject: [PATCH] feat: refs #8387 changes --- loopback/locale/en.json | 7 ++++--- loopback/locale/es.json | 5 +++-- modules/item/back/models/item-tag.js | 14 ++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 8d5eab4bc..4fe11c2b6 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -211,7 +211,7 @@ "Name should be uppercase": "Name should be uppercase", "You cannot update these fields": "You cannot update these fields", "CountryFK cannot be empty": "Country cannot be empty", - "No tickets to invoice": "There are no tickets to invoice that meet the invoicing requirements", + "No tickets to invoice": "There are no tickets to invoice that meet the invoicing requirements", "You are not allowed to modify the alias": "You are not allowed to modify the alias", "You already have the mailAlias": "You already have the mailAlias", "This machine is already in use.": "This machine is already in use.", @@ -251,5 +251,6 @@ "Holidays to past days not available": "Holidays to past days not available", "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "There are tickets to be invoiced", - "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent" -} + "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent", + "The value must be a number or a range of numbers": "The value must be a number or a range of numbers" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5558c0964..9a24f84ba 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -398,5 +398,6 @@ "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "All tickets have a route order": "Todos los tickets tienen orden de ruta", "Price cannot be blank": "Price cannot be blank", - "There are tickets to be invoiced": "La zona tiene tickets por facturar" -} + "There are tickets to be invoiced": "La zona tiene tickets por facturar", + "The value must be a number or a range of numbers": "The value must be a number or a range of numbers" +} \ No newline at end of file diff --git a/modules/item/back/models/item-tag.js b/modules/item/back/models/item-tag.js index 338ef64cf..4c1ef4d4a 100644 --- a/modules/item/back/models/item-tag.js +++ b/modules/item/back/models/item-tag.js @@ -19,17 +19,15 @@ module.exports = Self => { if (ctx.isNewInstance) { tagFk = ctx.instance.tagFk; value = ctx.instance.value; + } else { + tagFk = ctx.currentInstance.tagFk; + value = ctx.data.value; } - const newData = ctx.data.value || null; - const currentData = ctx.currentInstance.value || null; const models = Self.app.models; - const validTag = await models.Tag.findOne({where: {name: 'Longitud(cm)'}}); + const validTag = await models.Tag.findOne({where: {name: 'Longitud(m)'}}); - if (tagFk === validTag.id || (currentData && currentData === validTag.id)) { - if ( - (value && !validValue.test(value)) || - (newData && !validValue.test(newData)) - ) + if (tagFk === validTag.id) { + if ((value && !validValue.test(value))) throw new UserError('The value must be a number or a range of numbers'); } });