use field name on user profile > form validation errors dialog

This commit is contained in:
mchouliara 2024-09-24 16:54:14 +03:00
parent 2dc5c7525b
commit f0a4388828
1 changed files with 16 additions and 2 deletions

View File

@ -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'],
])
}