From df2b9d79eaa9537dd7df5d17c0e8113791fac6b3 Mon Sep 17 00:00:00 2001 From: IliesAllali Date: Thu, 12 Nov 2026 13:52:26 +0100 Subject: [PATCH] =?UTF-8?q?Noms=20de=20famille=20en=20capitales,=20r=C3=A9?= =?UTF-8?q?glage=20de=20l'arbre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Par convention, les généalogistes écrivent le nom en capitales pour le distinguer du prénom (« Bertrand GAUTHIER »). Paramètres de l'arbre > Affichage gagne une case « Les noms de famille en capitales », éteinte par défaut. Le réglage est celui de l'arbre : il est enregistré dans tree_settings (migration additive, false par défaut) et part avec le graphe, donc la famille qui ouvre le lien le voit comme les gestionnaires l'ont choisi. Seul l'affichage change : surnameLabel() met le nom en capitales partout où il s'affiche (arbre, fiche, recherche, onglets de familles, listes, propositions) et les champs Nom et Nom de naissance s'affichent en capitales pendant la saisie, mais le nom reste enregistré tel qu'il a été tapé. On peut éteindre le réglage sans rien perdre, et l'export GEDCOM ne change pas. Co-Authored-By: Claude Opus 5.5 --- .../migration.sql | 4 +++ backend/prisma/schema.prisma | 2 ++ backend/src/routes/graph.ts | 8 ++++- backend/src/routes/trees.ts | 3 ++ backend/test/api-routes.test.ts | 13 ++++++++ backend/test/api-security.integration.test.ts | 16 +++++++++ frontend/src/App.jsx | 30 ++++++++++------- frontend/src/api/treeApi.js | 1 + frontend/src/components/AccountPanel.jsx | 5 +-- frontend/src/components/AddPersonPanel.jsx | 12 ++++--- frontend/src/components/AdminPanel.jsx | 33 +++++++++++++++++++ frontend/src/components/ContributionPanel.jsx | 7 ++-- frontend/src/components/FamilyOnboarding.jsx | 3 +- frontend/src/components/Galaxy.jsx | 7 ++-- frontend/src/components/ImmichFacePanel.jsx | 5 +-- frontend/src/components/MediaManagerPanel.jsx | 3 +- frontend/src/components/MediaViewer.jsx | 4 +-- frontend/src/components/PersonCard.jsx | 16 ++++----- frontend/src/components/PhotoStartPanel.jsx | 3 +- frontend/src/components/ProposalCard.jsx | 6 ++-- .../src/components/SearchSourcesPanel.jsx | 4 +-- frontend/src/components/galaxy/renderers.js | 4 +-- .../search/SearchResultsDropdown.jsx | 4 +-- frontend/src/hooks/useTreeAccess.js | 6 ++++ frontend/src/i18n/en/arbre.js | 2 ++ frontend/src/styles/pz.css | 2 ++ frontend/src/utils/lifeTimeline.js | 4 +-- frontend/src/utils/personName.js | 22 +++++++++++-- frontend/src/utils/personName.test.js | 27 +++++++++++++-- 29 files changed, 202 insertions(+), 54 deletions(-) create mode 100644 backend/prisma/migrations/20261112_001_noms_en_capitales/migration.sql diff --git a/backend/prisma/migrations/20261112_001_noms_en_capitales/migration.sql b/backend/prisma/migrations/20261112_001_noms_en_capitales/migration.sql new file mode 100644 index 0000000..4484f53 --- /dev/null +++ b/backend/prisma/migrations/20261112_001_noms_en_capitales/migration.sql @@ -0,0 +1,4 @@ +-- Noms de famille affichés en capitales (« Bertrand GAUTHIER »), réglage de l'arbre choisi par ses gestionnaires. +-- Migration additive : une colonne à false par défaut, les arbres existants ne changent pas. +-- AlterTable +ALTER TABLE "tree_settings" ADD COLUMN "surnameUppercase" BOOLEAN NOT NULL DEFAULT false; diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index df2ab67..64b65d3 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -262,6 +262,8 @@ model TreeSettings { memberContributionPolicy ContributionPolicy @default(pending) visitorPolicy VisitorPolicy @default(read_only) contributorPolicy ContributionPolicy @default(pending) + // Noms de famille affichés en capitales pour tous ceux qui ouvrent l'arbre ; ils restent enregistrés tels que tapés + surnameUppercase Boolean @default(false) updatedAt DateTime @updatedAt tree Tree @relation(fields: [treeId], references: [id], onDelete: Cascade) diff --git a/backend/src/routes/graph.ts b/backend/src/routes/graph.ts index 2cfdded..a370a2f 100644 --- a/backend/src/routes/graph.ts +++ b/backend/src/routes/graph.ts @@ -119,7 +119,7 @@ export const graphRoutes: FastifyPluginAsync = async (app) => { // Journal des visites (onglet Visites des administrateurs), sans attendre void recordTreeVisit(app, request, treeId, visitKind, actor.kind === 'user' ? actor.userId : null) - const [persons, unions, links, medias, annotations, mediaPeople] = await Promise.all([ + const [persons, unions, links, medias, annotations, mediaPeople, settings] = await Promise.all([ app.prisma.person.findMany({ where: { treeId, @@ -161,6 +161,10 @@ export const graphRoutes: FastifyPluginAsync = async (app) => { select: { mediaId: true, personId: true, x: true, y: true }, orderBy: [{ createdAt: 'asc' }, { id: 'asc' }], }), + app.prisma.treeSettings.findUnique({ + where: { treeId }, + select: { surnameUppercase: true }, + }), ]) const graph = buildGraphPayload(treeId, persons, unions, links, medias, annotations, mediaPeople) @@ -169,6 +173,8 @@ export const graphRoutes: FastifyPluginAsync = async (app) => { treeId, rootPersonId, graph, + // Réglages d'affichage choisis par les gestionnaires, les mêmes pour tous ceux qui ouvrent l'arbre + display: { surnameUppercase: Boolean(settings?.surnameUppercase) }, // Pour l'adresse des images ( n'envoie pas la session) : lecture des médias de cet arbre seulement mediaToken: signMediaToken(app, treeId, actor), }) diff --git a/backend/src/routes/trees.ts b/backend/src/routes/trees.ts index fb06ac8..fd342f1 100644 --- a/backend/src/routes/trees.ts +++ b/backend/src/routes/trees.ts @@ -74,6 +74,7 @@ const patchTreeSettingsSchema = z .object({ memberContributionPolicy: z.enum(['direct', 'pending']).optional(), contributorPolicy: z.enum(['direct', 'pending']).optional(), + surnameUppercase: z.boolean().optional(), }) .refine((value) => Object.keys(value).length > 0, { message: 'at_least_one_setting_required', @@ -1177,10 +1178,12 @@ export const treeRoutes: FastifyPluginAsync = async (app) => { memberContributionPolicy: payload.data.memberContributionPolicy ?? 'pending', visitorPolicy: 'read_only', contributorPolicy: payload.data.contributorPolicy ?? 'pending', + surnameUppercase: payload.data.surnameUppercase ?? false, }, update: { memberContributionPolicy: payload.data.memberContributionPolicy, contributorPolicy: payload.data.contributorPolicy, + surnameUppercase: payload.data.surnameUppercase, }, }) diff --git a/backend/test/api-routes.test.ts b/backend/test/api-routes.test.ts index b7cde91..67b0254 100644 --- a/backend/test/api-routes.test.ts +++ b/backend/test/api-routes.test.ts @@ -414,6 +414,19 @@ describe('Graph routes', () => { expect(body.graph.persons[0].firstName).toBe('Alice') expect(body.graph.unions).toHaveLength(0) expect(body.graph.filiations).toHaveLength(0) + expect(body.display).toEqual({ surnameUppercase: false }) + await app.close() + }) + + it('envoie le réglage des noms en capitales avec le graphe, à tous ceux qui l ouvrent', async () => { + const app = createApp() + const token = await createUserToken(app) + prismaMock.treeSettings.findUnique.mockResolvedValue({ surnameUppercase: true }) + + const response = await app.inject({ method: 'GET', url: '/trees/tree-1/graph', headers: { authorization: `Bearer ${token}` } }) + + expect(response.statusCode).toBe(200) + expect(response.json().display).toEqual({ surnameUppercase: true }) await app.close() }) diff --git a/backend/test/api-security.integration.test.ts b/backend/test/api-security.integration.test.ts index 91dc2e8..f576015 100644 --- a/backend/test/api-security.integration.test.ts +++ b/backend/test/api-security.integration.test.ts @@ -1598,6 +1598,22 @@ describe('API security and authz', () => { await app.close() }) + it('enregistre les noms de famille en capitales, et refuse une valeur qui n est pas un booléen', async () => { + const app = createApp() + const token = await createUserToken(app) + const patch = (payload: object) => app.inject({ method: 'PATCH', url: '/trees/tree-1/settings', headers: { authorization: `Bearer ${token}` }, payload }) + + expect((await patch({ surnameUppercase: true })).statusCode).toBe(200) + expect(prismaMock.treeSettings.upsert).toHaveBeenCalledWith( + expect.objectContaining({ + create: expect.objectContaining({ surnameUppercase: true, contributorPolicy: 'pending' }), + update: expect.objectContaining({ surnameUppercase: true, contributorPolicy: undefined }), + }), + ) + expect((await patch({ surnameUppercase: 'oui' })).statusCode).toBe(400) + await app.close() + }) + // Audit 1.0 (30/09/2026) it('no longer accepts an account session in a media address', async () => { const app = createApp() diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 49c03ae..364673a 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -4,7 +4,7 @@ import Galaxy from './components/Galaxy' import PersonCard from './components/PersonCard.jsx' import { FamilyWelcome, SouvenirPicker } from './components/FamilyOnboarding.jsx' import { HELP_URL } from './utils/siteLinks.js' -import { firstNameLabel } from './utils/personName.js' +import { firstNameLabel, setSurnameUppercase, surnameLabel } from './utils/personName.js' import { useUndoable } from './hooks/useUndoable.js' import { hasSeenFamilyWelcome, markFamilyWelcomeSeen } from './utils/familyWelcome' import MediaViewer from './components/MediaViewer' @@ -452,13 +452,13 @@ function buildContribChangesList(draft = {}) { for (const entry of addedPersonEntries) { const d = entry && typeof entry === 'object' ? entry : (draft.modifiedPersons?.[String(entry)] || {}) - const name = `${d.firstName || ''} ${d.lastName || ''}`.trim() || t('Nouvelle personne') + const name = `${d.firstName || ''} ${surnameLabel(d.lastName)}`.trim() || t('Nouvelle personne') items.push({ entityType: 'person', action: 'create', label: name }) } for (const [id, d] of Object.entries(draft.modifiedPersons || {})) { if (addedPersonIds.includes(String(id))) continue - const name = `${d.firstName || ''} ${d.lastName || ''}`.trim() || t('Personne') + const name = `${d.firstName || ''} ${surnameLabel(d.lastName)}`.trim() || t('Personne') items.push({ entityType: 'person', action: 'update', label: name }) } @@ -639,7 +639,10 @@ function App() { message: '', }) - const buildEmptyTreeContext = useCallback((overrides = {}) => ({ + const buildEmptyTreeContext = useCallback((overrides = {}) => { + // Sans arbre ouvert, les noms s'affichent tels qu'ils ont été tapés + setSurnameUppercase(false) + return { treeId: '', treeName: '', treeDescription: '', @@ -649,8 +652,10 @@ function App() { accessMode: '', rootPersonId: null, accessToken: '', + surnameUppercase: false, ...overrides, - }), []) + } + }, []) // Déterminer le rôle et permissions de l'utilisateur const userRole = useUserRole({ @@ -721,7 +726,7 @@ function App() { const accountDisplayName = useMemo(() => { if (linkedSelfPerson) { - const fullName = `${linkedSelfPerson.firstName || ''} ${linkedSelfPerson.lastName || ''}`.trim() + const fullName = `${linkedSelfPerson.firstName || ''} ${surnameLabel(linkedSelfPerson.lastName)}`.trim() if (fullName) { return fullName } @@ -1176,7 +1181,7 @@ function App() { const [first = '', ...rest] = String(query).trim().split(/\s+/) const inheritsName = type === 'child' || type === 'sibling' const lastName = rest.join(' ') || (inheritsName ? person.lastName || '' : '') - const personName = [person.firstName, person.lastName].filter(Boolean).join(' ') + const personName = [person.firstName, surnameLabel(person.lastName)].filter(Boolean).join(' ') if (!(await leaveSelectedPerson())) return await chooseSelectedPerson(null) setAddPersonPrefill({ nonce: Date.now(), firstName: first, lastName, relation: { type, personId: person.id, personName } }) @@ -1234,7 +1239,7 @@ function App() { const links = getSiblingParentLinks(rel.personId, filiations, unions) if (links.length === 0) { const sibling = persons.find((person) => String(person.id) === String(rel.personId)) - const siblingName = [sibling?.firstName, sibling?.lastName].filter(Boolean).join(' ') + const siblingName = [sibling?.firstName, surnameLabel(sibling?.lastName)].filter(Boolean).join(' ') setAddPersonError(siblingName ? t("Ajoutez d'abord un parent à {name} pour pouvoir lui rattacher un frère ou une sœur.", { name: siblingName }) : t("Ajoutez d'abord un parent à cette personne pour pouvoir lui rattacher un frère ou une sœur.")) @@ -1372,7 +1377,7 @@ function App() { // fois avec le bouton « Envoyer » de la barre (Patch, 25/10). Avant, la fenêtre d'envoi s'ouvrait d'office, // seule façon de montrer qu'un ajout invisible comptait. setAddPersonPanelVisible(false) - setDraftNotice(t("{name} est sur l'arbre, en brouillon. Envoyez quand vous avez fini.", { name: [formData.firstName, formData.lastName].filter(Boolean).join(' ') || t('Nouvelle personne') })) + setDraftNotice(t("{name} est sur l'arbre, en brouillon. Envoyez quand vous avez fini.", { name: [formData.firstName, surnameLabel(formData.lastName)].filter(Boolean).join(' ') || t('Nouvelle personne') })) return { proposed: true, id: isDemoMode ? null : `ghost:brouillon:${ref}`, demoPerson: isDemoMode ? persons[persons.length - 1] : null } } @@ -1461,7 +1466,7 @@ function App() { const addedIds = added.map((result) => result.demoPerson?.id ?? result.id).filter((id) => id != null) if (added[0].proposed) { const names = joinFirstNames(firstNames.slice(0, added.length), t('et')) - setDraftNotice(t("{names} sont sur l'arbre, en brouillon. Envoyez quand vous avez fini.", { names: [names, formData.lastName].filter(Boolean).join(' ') })) + setDraftNotice(t("{names} sont sur l'arbre, en brouillon. Envoyez quand vous avez fini.", { names: [names, surnameLabel(formData.lastName)].filter(Boolean).join(' ') })) } // Sur téléphone, une fiche ouverte couvrirait la fratrie : pas de fiche, la caméra les cadre tous if (window.matchMedia?.('(max-width: 768px)').matches) { @@ -3541,7 +3546,7 @@ function App() { userEmail={accountEmail} userAvatarPhoto={accountAvatarPhoto} userAvatarCrop={linkedSelfPerson?.avatarCrop ?? null} - linkedPersonName={linkedSelfPerson ? `${linkedSelfPerson.firstName || ''} ${linkedSelfPerson.lastName || ''}`.trim() : ''} + linkedPersonName={linkedSelfPerson ? `${linkedSelfPerson.firstName || ''} ${surnameLabel(linkedSelfPerson.lastName)}`.trim() : ''} activeTreeName={activeAccountTreeName} annotationTools={editMode.isActive ? { activeTool: annot.activeTool, @@ -3572,6 +3577,7 @@ function App() { onReorderSiblings={handleReorderSiblings} familyTabs={familyTabs} fullNames={fullNames} + surnameUppercase={tree.treeContext.surnameUppercase} annotationViewRef={annotationViewRef} onAnnotationsAnchored={persistAnnotationAnchors} selfPersonId={linkedSelfPersonId || null} @@ -3754,6 +3760,8 @@ function App() { onFamilyTabsChange={setFamilyTabs} fullNames={fullNames} onFullNamesChange={setFullNames} + surnameUppercase={tree.treeContext.surnameUppercase} + onSurnameUppercaseChange={(on) => { setSurnameUppercase(on); tree.setTreeContext((current) => ({ ...current, surnameUppercase: on })) }} />