From f0a43888289dd75bd395543c105f7225a8137152 Mon Sep 17 00:00:00 2001 From: mchouliara Date: Tue, 24 Sep 2024 16:54:14 +0300 Subject: [PATCH] use field name on user profile > form validation errors dialog --- .../ui/user-profile/user-profile.component.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/ui/user-profile/user-profile.component.ts b/frontend/src/app/ui/user-profile/user-profile.component.ts index 2d68d6c36..08ecfba33 100644 --- a/frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/frontend/src/app/ui/user-profile/user-profile.component.ts @@ -317,9 +317,13 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes } Object.keys(errors).forEach(keyError => { if (typeof errors[keyError] === 'boolean') { - this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError); + this.errorMessages.push( + numbering + ' ' + this.language.instant(this.formLabelMap.get(key)?? '') + ' ' + (keyError === 'required'? this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED') : keyError) + ); } else { - this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); + this.errorMessages.push( + numbering + ' ' + this.language.instant(this.formLabelMap.get(key)?? '') + ': ' + keyError + ': ' + JSON.stringify(errors[keyError]) + ); } }); } else { @@ -374,4 +378,14 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes return culture.displayName + ' [' + culture.name + ']'; } + formLabelMap = new Map([ + ['name', 'USER-PROFILE.SETTINGS.NAME'], + ['avatarUrl', 'ALT-TEXT.USER-AVATAR'], + ['timezone', 'USER-PROFILE.SETTINGS.TIMEZONE'], + ['culture', 'USER-PROFILE.SETTINGS.CULTURE'], + ['language', 'USER-PROFILE.SETTINGS.LANGUAGE'], + ['roleOrganization', 'USER-PROFILE.SETTINGS.ROLE'], + ['organization', 'USER-PROFILE.SETTINGS.ORGANIZATION'], + ]) + }