Normalize name and surname

This commit is contained in:
Charles 2026-03-03 14:12:24 +01:00
parent d5e1ad057e
commit a93b94ba7b
2 changed files with 8 additions and 1 deletions

View File

@ -7,7 +7,8 @@ import {
eyeIconLink, eyeIconLink,
sendEmailIcon, sendEmailIcon,
TABULATOR_FR_LANG, TABULATOR_FR_LANG,
trashIconForm trashIconForm,
capitalizeFirstLetter
} from "../js/global.js"; } from "../js/global.js";
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import base_controller from "./base_controller.js"; import base_controller from "./base_controller.js";
@ -1032,6 +1033,7 @@ export default class extends base_controller {
const formData = new FormData(form); const formData = new FormData(form);
const ucSurname = formData.get('surname').toUpperCase(); const ucSurname = formData.get('surname').toUpperCase();
formData.set('surname', ucSurname); formData.set('surname', ucSurname);
formData.set('name', capitalizeFirstLetter(formData.get('name'))); // Capitalize first letter of name
try { try {
const response = await fetch('/user/new/ajax', { // Adjust path if prefix is different const response = await fetch('/user/new/ajax', { // Adjust path if prefix is different
@ -1101,6 +1103,7 @@ export default class extends base_controller {
// Force Uppercase on Surname as requested // Force Uppercase on Surname as requested
formData.set('surname', formData.get('surname').toUpperCase()); formData.set('surname', formData.get('surname').toUpperCase());
formData.set('name', capitalizeFirstLetter(formData.get('name'))); // Capitalize first letter of name
try { try {
const response = await fetch(`/user/edit/${this.currentUserId}/ajax`, { const response = await fetch(`/user/edit/${this.currentUserId}/ajax`, {

View File

@ -80,3 +80,7 @@ export function sendEmailIcon(userId, orgId) {
<svg xmlns="http://www.w3.org/2000/svg" width="35px" height="35px" viewBox="0 0 24 24"><path fill="currentColor" d="M18.175 17H15q-.425 0-.712-.288T14 16t.288-.712T15 15h3.175l-.9-.9Q17 13.825 17 13.413t.3-.713q.275-.275.7-.275t.7.275l2.6 2.6q.125.125.2.312t.075.388t-.075.387t-.2.313l-2.6 2.6q-.275.275-.687.288T17.3 19.3q-.275-.275-.275-.7t.275-.7zM4 17q-.825 0-1.412-.587T2 15V5q0-.825.588-1.412T4 3h13q.825 0 1.413.588T19 5v4.075q0 .4-.3.7t-.7.3q-.425 0-.712-.288T17 9.076V6.4L10.4 11L4 6.425V15h7.075q.425 0 .713.288t.287.712t-.287.713t-.713.287zM5.45 5l4.95 3.55L15.5 5zM4 15V5z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="35px" height="35px" viewBox="0 0 24 24"><path fill="currentColor" d="M18.175 17H15q-.425 0-.712-.288T14 16t.288-.712T15 15h3.175l-.9-.9Q17 13.825 17 13.413t.3-.713q.275-.275.7-.275t.7.275l2.6 2.6q.125.125.2.312t.075.388t-.075.387t-.2.313l-2.6 2.6q-.275.275-.687.288T17.3 19.3q-.275-.275-.275-.7t.275-.7zM4 17q-.825 0-1.412-.587T2 15V5q0-.825.588-1.412T4 3h13q.825 0 1.413.588T19 5v4.075q0 .4-.3.7t-.7.3q-.425 0-.712-.288T17 9.076V6.4L10.4 11L4 6.425V15h7.075q.425 0 .713.288t.287.712t-.287.713t-.713.287zM5.45 5l4.95 3.55L15.5 5zM4 15V5z"/></svg>
</a>` </a>`
} }
export function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}