From e5e97a047f4b993f2ce6d637ac1941406d017419 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 29 Nov 2023 15:03:09 +0100 Subject: [PATCH] refs #5878 perf: front validations --- front/core/components/watcher/locale/es.yml | 4 +++- front/core/components/watcher/watcher.js | 6 ++++-- loopback/locale/es.json | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/front/core/components/watcher/locale/es.yml b/front/core/components/watcher/locale/es.yml index 5d25752b4..37113b871 100644 --- a/front/core/components/watcher/locale/es.yml +++ b/front/core/components/watcher/locale/es.yml @@ -1,4 +1,6 @@ Are you sure exit without saving?: ¿Seguro que quieres salir sin guardar? Unsaved changes will be lost: Los cambios que no hayas guardado se perderán No changes to save: No hay cambios que guardar -Some fields are invalid: Algunos campos no son válidos \ No newline at end of file +Field are invalid: El campo {{tag}} no es válido +Some fields are invalid: Algunos campos no son válidos + diff --git a/front/core/components/watcher/watcher.js b/front/core/components/watcher/watcher.js index 8b52be69c..5e3069e02 100644 --- a/front/core/components/watcher/watcher.js +++ b/front/core/components/watcher/watcher.js @@ -317,8 +317,10 @@ export default class Watcher extends Component { * Checks if the form is valid. */ isInvalid() { - if (this.form && this.form.$invalid) - throw new UserError('Some fields are invalid'); + if (this.form && this.form.$invalid) { + const tag = Object.values(this.form.$error)[0][0].$$attr.label; + throw new UserError(this.$t('Field are invalid', {tag: this.$t(tag)})); + } } /** diff --git a/loopback/locale/es.json b/loopback/locale/es.json index cf5998e9d..8a5f4db9f 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -335,6 +335,7 @@ "Model is not valid": "El campo \" {{key}}\" no es válido", "Property is not defined in this model": "La propiedad que ha modificado no existe", "postCode": "Código postal", + "postcode": "Código postal", "fi": "NIF/CIF", "nif": "NIF/CIF", "Account": "Cuenta", @@ -350,7 +351,5 @@ "sageWithholdingFk" : "Sage con tenencia", "Cannot past travels with entries": "No se pueden pasar envíos con entradas", "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}", - "Field are invalid": "El campo {{tag}} no es válido", - "postcode": "Código postal" + "Field are invalid": "El campo {{tag}} no es válido" } -