feat: refs #8387 crudModel #3355

Merged
robert merged 16 commits from 8387-itemTagCrudModel into dev 2025-01-27 11:38:09 +00:00
3 changed files with 13 additions and 13 deletions
Showing only changes of commit 93c9ef6f4c - Show all commits

View File

@ -251,5 +251,6 @@
"Holidays to past days not available": "Holidays to past days not available", "Holidays to past days not available": "Holidays to past days not available",
"Price cannot be blank": "Price cannot be blank", "Price cannot be blank": "Price cannot be blank",
"There are tickets to be invoiced": "There are tickets to be invoiced", "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"
} }

View File

@ -398,5 +398,6 @@
"Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "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", "All tickets have a route order": "Todos los tickets tienen orden de ruta",
"Price cannot be blank": "Price cannot be blank", "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"
} }

View File

@ -19,17 +19,15 @@ module.exports = Self => {
if (ctx.isNewInstance) { if (ctx.isNewInstance) {
tagFk = ctx.instance.tagFk; tagFk = ctx.instance.tagFk;
value = ctx.instance.value; 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 models = Self.app.models;
const validTag = await models.Tag.findOne({where: {name: 'Longitud(cm)'}}); const validTag = await models.Tag.findOne({where: {name: 'Longitud(m)'}});
robert marked this conversation as resolved
Review

&& de value deberia ir a este nivel no?

&& de value deberia ir a este nivel no?
Review

validTag.validationRegex comprueba si la columna validationRegex de la tabla tag tiene una expresión regular, y en caso de tener, se comprueba si el valor cumple la expresión regular

validTag.validationRegex comprueba si la columna validationRegex de la tabla tag tiene una expresión regular, y en caso de tener, se comprueba si el valor cumple la expresión regular
if (tagFk === validTag.id || (currentData && currentData === validTag.id)) { if (tagFk === validTag.id) {
if ( if ((value && !validValue.test(value)))
(value && !validValue.test(value)) ||
(newData && !validValue.test(newData))
)
throw new UserError('The value must be a number or a range of numbers'); throw new UserError('The value must be a number or a range of numbers');
} }
}); });