mirror of
https://github.com/IliesAllali/parenthese.git
synced 2026-11-16 16:33:28 +00:00
Merge pull request #233 from IliesAllali/feat/noms-en-capitales
Noms de famille en capitales, réglage de l'arbre
This commit is contained in:
29 files changed
+202
-54
No files matched your search
@@ -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;
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 (<img src> n'envoie pas la session) : lecture des médias de cet arbre seulement
|
||||
mediaToken: signMediaToken(app, treeId, actor),
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
+19
-11
@@ -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 })) }}
|
||||
/>
|
||||
<PhotoStartPanel
|
||||
visible={photoStart.visible}
|
||||
|
||||
@@ -49,6 +49,7 @@ export async function fetchTreeGraph(treeId, token) {
|
||||
rootPersonId: data?.rootPersonId || null,
|
||||
graph: data?.graph || { persons: [], unions: [], filiations: [], medias: [] },
|
||||
mediaToken: data?.mediaToken || '',
|
||||
surnameUppercase: Boolean(data?.display?.surnameUppercase),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import './AccountScreens.css'
|
||||
@@ -35,7 +36,7 @@ const AccountPanel = ({
|
||||
}
|
||||
|
||||
const displayName = linkedPerson
|
||||
? `${linkedPerson.firstName || ''} ${linkedPerson.lastName || ''}`.trim()
|
||||
? `${linkedPerson.firstName || ''} ${surnameLabel(linkedPerson.lastName)}`.trim()
|
||||
: userDisplayName || (userEmail ? t('Mon compte') : t('Qui êtes-vous dans cet arbre ?'))
|
||||
|
||||
return (
|
||||
@@ -90,7 +91,7 @@ const AccountPanel = ({
|
||||
<span className="ap-item-avatar" aria-hidden="true">
|
||||
{person.photo ? <PortraitThumb src={person.photo} crop={person.avatarCrop} /> : initialOf(person.firstName)}
|
||||
</span>
|
||||
<span className="ap-item-name">{person.firstName} <em>{person.lastName || ''}</em></span>
|
||||
<span className="ap-item-name">{person.firstName} <em>{surnameLabel(person.lastName)}</em></span>
|
||||
{isSelected && <span className="pz-tag pz-tag--accent">{t("C'est moi")}</span>}
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { UserPlus, X, Search, ChevronDown } from 'lucide-react'
|
||||
import './AddPersonPanel.css'
|
||||
import PzBusy from './PzBusy.jsx'
|
||||
import { t } from '../i18n/index.js'
|
||||
import { firstNameLabel } from '../utils/personName.js'
|
||||
import { firstNameLabel, isSurnameUppercase, surnameLabel } from '../utils/personName.js'
|
||||
import { SEX_CHOICES } from '../utils/personSex.js'
|
||||
import { initialOf } from '../utils/initial.js'
|
||||
import { findLikelyDuplicates } from '../utils/duplicates.js'
|
||||
@@ -147,7 +147,7 @@ function AddPersonPanel({ visible, persons = [], loading = false, error = '', on
|
||||
|
||||
setRelations((prev) => [
|
||||
...prev,
|
||||
{ personId: person.id, personName: `${firstNameLabel(person)} ${person.lastName || ''}`.trim(), type: selectedRelationType },
|
||||
{ personId: person.id, personName: `${firstNameLabel(person)} ${surnameLabel(person.lastName)}`.trim(), type: selectedRelationType },
|
||||
])
|
||||
setRelationSearch('')
|
||||
setRelationDropdownOpen(false)
|
||||
@@ -255,6 +255,7 @@ function AddPersonPanel({ visible, persons = [], loading = false, error = '', on
|
||||
<input
|
||||
id="ap-lastName"
|
||||
type="text"
|
||||
className={isSurnameUppercase() ? 'pz-caps' : undefined}
|
||||
value={lastName}
|
||||
onChange={(e) => {
|
||||
setLastName(e.target.value)
|
||||
@@ -274,8 +275,8 @@ function AddPersonPanel({ visible, persons = [], loading = false, error = '', on
|
||||
{duplicates.map((p) => (
|
||||
<p key={p.id} className="apn-duplicate-line">
|
||||
<span>{p.birthYear
|
||||
? t('{name} ({year}) est déjà dans l’arbre.', { name: `${firstNameLabel(p)} ${p.lastName || ''}`.trim(), year: p.birthYear })
|
||||
: t('{name} est déjà dans l’arbre.', { name: `${firstNameLabel(p)} ${p.lastName || ''}`.trim() })}</span>
|
||||
? t('{name} ({year}) est déjà dans l’arbre.', { name: `${firstNameLabel(p)} ${surnameLabel(p.lastName)}`.trim(), year: p.birthYear })
|
||||
: t('{name} est déjà dans l’arbre.', { name: `${firstNameLabel(p)} ${surnameLabel(p.lastName)}`.trim() })}</span>
|
||||
{onOpenPerson && (
|
||||
<button type="button" className="pz-btn pz-btn--ghost pz-btn--sm" onClick={() => onOpenPerson(p)}>{t('Ouvrir sa fiche')}</button>
|
||||
)}
|
||||
@@ -290,6 +291,7 @@ function AddPersonPanel({ visible, persons = [], loading = false, error = '', on
|
||||
<input
|
||||
id="ap-birthName"
|
||||
type="text"
|
||||
className={isSurnameUppercase() ? 'pz-caps' : undefined}
|
||||
value={birthName}
|
||||
onChange={(e) => setBirthName(e.target.value)}
|
||||
placeholder={t('Martin')}
|
||||
@@ -390,7 +392,7 @@ function AddPersonPanel({ visible, persons = [], loading = false, error = '', on
|
||||
<span className="apn-avatar" aria-hidden="true">
|
||||
{p.photo ? <PortraitThumb src={p.photo} crop={p.avatarCrop} /> : initialOf(p.firstName)}
|
||||
</span>
|
||||
<span className="apn-dropdown-name">{firstNameLabel(p)} <em>{p.lastName || ''}</em></span>
|
||||
<span className="apn-dropdown-name">{firstNameLabel(p)} <em>{surnameLabel(p.lastName)}</em></span>
|
||||
{(p.birthYear || p.birthDate) && (
|
||||
<span className="apn-dropdown-date">{p.birthYear || String(p.birthDate).slice(0, 4)}</span>
|
||||
)}
|
||||
|
||||
@@ -43,6 +43,8 @@ const AdminPanel = ({
|
||||
onFamilyTabsChange = null,
|
||||
fullNames = false,
|
||||
onFullNamesChange = null,
|
||||
surnameUppercase = false,
|
||||
onSurnameUppercaseChange = null,
|
||||
visible,
|
||||
treeId,
|
||||
authToken,
|
||||
@@ -72,6 +74,7 @@ const AdminPanel = ({
|
||||
// Contributions de la famille : 'pending' = validées par l'admin, 'direct' = appliquées immédiatement
|
||||
const [contributionPolicy, setContributionPolicy] = useState('pending')
|
||||
const [savingPolicy, setSavingPolicy] = useState(false)
|
||||
const [savingSurnames, setSavingSurnames] = useState(false)
|
||||
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false)
|
||||
const [confirmLeave, setConfirmLeave] = useState(false)
|
||||
@@ -177,6 +180,23 @@ const AdminPanel = ({
|
||||
}
|
||||
}
|
||||
|
||||
// Réglage de l'arbre, pas du navigateur : toute la famille voit les noms comme les gestionnaires l'ont choisi
|
||||
const handleSurnameUppercaseChange = async (on) => {
|
||||
if (!treeId || !authToken || savingSurnames) return
|
||||
onSurnameUppercaseChange?.(on)
|
||||
setSavingSurnames(true)
|
||||
setErrorMessage('')
|
||||
setSuccessMessage('')
|
||||
try {
|
||||
await updateTreeSettings(treeId, { surnameUppercase: on }, authToken)
|
||||
} catch {
|
||||
onSurnameUppercaseChange?.(!on)
|
||||
setErrorMessage(t("Impossible d'enregistrer ce réglage."))
|
||||
} finally {
|
||||
setSavingSurnames(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSaveTree = async (event) => {
|
||||
event.preventDefault()
|
||||
if (!treeId || !authToken || saving || !tree) return
|
||||
@@ -559,6 +579,19 @@ const AdminPanel = ({
|
||||
<small>{t("Le nom de naissance quand il est connu, sinon le nom d'usage. Réglage de ce navigateur.")}</small>
|
||||
</span>
|
||||
</label>
|
||||
<label className={`ts-choice ${surnameUppercase ? 'is-active' : ''}`}>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="surnameUppercase"
|
||||
checked={surnameUppercase}
|
||||
disabled={savingSurnames}
|
||||
onChange={(event) => handleSurnameUppercaseChange(event.target.checked)}
|
||||
/>
|
||||
<span className="ts-choice-text">
|
||||
<strong>{t('Les noms de famille en capitales')}</strong>
|
||||
<small>{t('Jeanne MARTIN plutôt que Jeanne Martin, pour toute la famille. Les noms restent enregistrés comme ils ont été tapés.')}</small>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</form>
|
||||
)}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { buildMediaUrl } from '../utils/mediaToken.js'
|
||||
import { API_BASE_URL } from '../api/client'
|
||||
@@ -116,11 +117,11 @@ function nameOfPersonRef(id, sessionChanges = []) {
|
||||
const key = String(id)
|
||||
if (key.startsWith('tmp:')) {
|
||||
const added = sessionChanges.find((c) => c.entityType === 'person' && c.afterJson?.ref === key)
|
||||
const name = `${added?.afterJson?.firstName || ''} ${added?.afterJson?.lastName || ''}`.trim()
|
||||
const name = `${added?.afterJson?.firstName || ''} ${surnameLabel(added?.afterJson?.lastName)}`.trim()
|
||||
return name || t('la nouvelle personne')
|
||||
}
|
||||
const person = treePersons.find((candidate) => String(candidate.id) === key)
|
||||
const name = `${person?.firstName || ''} ${person?.lastName || ''}`.trim()
|
||||
const name = `${person?.firstName || ''} ${surnameLabel(person?.lastName)}`.trim()
|
||||
return name || null
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ function getPersonDisplayName(change, sessionChanges = []) {
|
||||
const before = change.beforeJson && typeof change.beforeJson === 'object' ? change.beforeJson : null
|
||||
if (!after && !before) return null
|
||||
const data = { ...before, ...after }
|
||||
const name = `${data.firstName || ''} ${data.lastName || ''}`.trim()
|
||||
const name = `${data.firstName || ''} ${surnameLabel(data.lastName)}`.trim()
|
||||
return name || null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { ImagePlus, Search, UserPlus, X } from 'lucide-react'
|
||||
import './FamilyOnboarding.css'
|
||||
@@ -121,7 +122,7 @@ export function SouvenirPicker({ visible, persons = [], rootPersonId = null, onP
|
||||
{person.photo ? <PortraitThumb src={person.photo} crop={person.avatarCrop} /> : <span>{person.firstName?.[0] || '?'}</span>}
|
||||
</span>
|
||||
<span className="fo-name">
|
||||
<strong>{person.firstName} {person.lastName}</strong>
|
||||
<strong>{person.firstName} {surnameLabel(person.lastName)}</strong>
|
||||
{lifeYears(person) && <small>{lifeYears(person)}</small>}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { memo, useEffect, useImperativeHandle, useRef, useState, useCallback } from 'react'
|
||||
import { getPersonMedias, getParents, getChildren, getPersonUnions, persons as graphPersons, unions as graphUnions, filiations as graphFiliations } from '../data/mockData'
|
||||
import { PERSON_R, FLOAT_SPEED, FLOAT_AMPLITUDE, REPULSION_RADIUS, REPULSION_STRENGTH, MAX_ORBIT_MEDIAS, ENTRANCE_NODE_DURATION, ENTRANCE_CAMERA_DURATION, ENTRANCE_CAMERA_FROM_SCALE, ENTRANCE_REDUCED_DURATION, ENTRANCE_LINE_DELAY, ENTRANCE_LINE_DURATION, ENTRANCE_ORBIT_DELAY, ENTRANCE_ORBIT_DURATION, ENTRANCE_ORBIT_STAGGER } from './galaxy/constants'
|
||||
@@ -75,7 +76,7 @@ function barTabs(tabs, activeKey) {
|
||||
})
|
||||
}
|
||||
|
||||
const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlightIds = [], graphRevision = 0, annotationHandlers = null, transformReadRef = null, zoomApiRef = null, focusPersonId = null, assetRevision = 0, reorderEnabled = false, onReorderSiblings = null, familyTabs = true, fullNames = false, annotationViewRef = null, onAnnotationsAnchored = null, selfPersonId = null, ghosts = null, initialFamilyKey = null, onFamilyChange = null }) => {
|
||||
const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlightIds = [], graphRevision = 0, annotationHandlers = null, transformReadRef = null, zoomApiRef = null, focusPersonId = null, assetRevision = 0, reorderEnabled = false, onReorderSiblings = null, familyTabs = true, fullNames = false, surnameUppercase = false, annotationViewRef = null, onAnnotationsAnchored = null, selfPersonId = null, ghosts = null, initialFamilyKey = null, onFamilyChange = null }) => {
|
||||
const canvasRef = useRef(null)
|
||||
const layoutDataRef = useRef(null)
|
||||
// Onglets de familles (réglage `familyTabs`) : la liste des familles de l'arbre, calculée une fois par
|
||||
@@ -110,6 +111,8 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig
|
||||
const ghostsRef = useRef(ghosts)
|
||||
const fullNamesRef = useRef(fullNames)
|
||||
useEffect(() => { fullNamesRef.current = fullNames; needsRedrawRef.current = true }, [fullNames])
|
||||
// Noms en capitales : le libellé se relit au dessin (surnameLabel), il suffit de redessiner
|
||||
useEffect(() => { needsRedrawRef.current = true }, [surnameUppercase])
|
||||
useEffect(() => { ghostsRef.current = ghosts; needsRedrawRef.current = true }, [ghosts])
|
||||
const onAnnotationsAnchoredRef = useRef(onAnnotationsAnchored)
|
||||
useEffect(() => { onAnnotationsAnchoredRef.current = onAnnotationsAnchored }, [onAnnotationsAnchored])
|
||||
@@ -1361,7 +1364,7 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig
|
||||
onFocus={() => { if (!active) hoverTab(tb.key) }}
|
||||
onBlur={leaveTab}
|
||||
>
|
||||
<span className="family-tab-name">{tb.label ? tr('Famille {name}', { name: tb.label }) : tr('Famille')}</span>
|
||||
<span className="family-tab-name">{tb.label ? tr('Famille {name}', { name: surnameLabel(tb.label) }) : tr('Famille')}</span>
|
||||
<span className="family-tab-count" title={tr('{n} personnes', { n: tb.count })}>{tb.count}</span>
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Loader2, Search, Unlink, UserRound, X } from 'lucide-react'
|
||||
import { createPortal } from 'react-dom'
|
||||
@@ -233,7 +234,7 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
|
||||
// ne dit que l'origine du portrait (avatarFromImmich), jamais l'identifiant Immich.
|
||||
const unassignBlock = person.avatarFromImmich && (
|
||||
<div className="immich-current">
|
||||
<p>{t('{name} est déjà associée à une personne Immich.', { name: person.firstName || person.lastName })}</p>
|
||||
<p>{t('{name} est déjà associée à une personne Immich.', { name: person.firstName || surnameLabel(person.lastName) })}</p>
|
||||
<button type="button" className="pz-btn pz-btn--danger-ghost" onClick={handleUnassign} disabled={actionLoading}>
|
||||
<Unlink size={16} aria-hidden="true" /> {t('Retirer l’association')}
|
||||
</button>
|
||||
@@ -245,7 +246,7 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
|
||||
<div className="pz-modal immich-modal-card" role="dialog" aria-modal="true" aria-labelledby="immichFaceTitle">
|
||||
<div className="pz-modal-head">
|
||||
<p className="pz-eyebrow">{t('Reconnaissance des visages')}</p>
|
||||
<h1 id="immichFaceTitle" className="pz-title">{person.firstName} <em>{person.lastName}</em></h1>
|
||||
<h1 id="immichFaceTitle" className="pz-title">{person.firstName} <em>{surnameLabel(person.lastName)}</em></h1>
|
||||
</div>
|
||||
<button type="button" className="pz-btn pz-btn--ghost pz-btn--icon pz-modal-close" onClick={onClose} aria-label={t('Fermer')}>
|
||||
<X size={18} aria-hidden="true" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { readContributorName } from '../utils/contributorName'
|
||||
import { ArrowDown, ArrowUp, FileText, Image, MapPin, Mic, Plus, Quote, Route, Trash2, Upload, Video, X } from 'lucide-react'
|
||||
@@ -194,7 +195,7 @@ const MediaManagerPanel = ({
|
||||
<div className="pz-modal pz-modal--wide media-manager-modal-card" role="dialog" aria-modal="true" aria-labelledby="mediaManagerTitle">
|
||||
<div className="pz-modal-head">
|
||||
<p className="pz-eyebrow">{canManage ? t('Souvenirs') : t('Ajouter un souvenir pour')}</p>
|
||||
<h1 id="mediaManagerTitle" className="pz-title">{person.firstName} <em>{person.lastName}</em></h1>
|
||||
<h1 id="mediaManagerTitle" className="pz-title">{person.firstName} <em>{surnameLabel(person.lastName)}</em></h1>
|
||||
</div>
|
||||
<button type="button" className="pz-btn pz-btn--ghost pz-btn--icon pz-modal-close" onClick={onClose} aria-label={t('Fermer')}>
|
||||
<X size={18} aria-hidden="true" />
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '../utils/geoMedia'
|
||||
import './MediaViewer.css'
|
||||
import { t } from '../i18n/index.js'
|
||||
import { firstNameLabel } from '../utils/personName.js'
|
||||
import { firstNameLabel, surnameLabel } from '../utils/personName.js'
|
||||
import { youtubeEmbedUrl } from '../utils/youtube.js'
|
||||
import { eventTitle } from '../utils/lifeTimeline.js'
|
||||
import { getAccountErrorMessage } from '../utils/errorMessages.js'
|
||||
@@ -649,7 +649,7 @@ const MediaViewer = ({
|
||||
) : (
|
||||
<span className="mv-person-avatar mv-person-initial">{person?.firstName?.[0] || '?'}</span>
|
||||
)}
|
||||
<span className="mv-person-name">{person ? firstNameLabel(person) : ''} <em>{person?.lastName}</em></span>
|
||||
<span className="mv-person-name">{person ? firstNameLabel(person) : ''} <em>{surnameLabel(person?.lastName)}</em></span>
|
||||
{personYears && <span className="mv-person-years">{personYears}</span>}
|
||||
</span>
|
||||
<span className="pz-tag">{typeLabels[mediaType] || mediaType}</span>
|
||||
|
||||
@@ -16,7 +16,7 @@ import PortraitCropModal from './PortraitCropModal.jsx'
|
||||
import { imagePlacement } from '../utils/portraitCrop.js'
|
||||
import { t, dateLocale } from '../i18n/index.js'
|
||||
import { formatPlace } from '../utils/place.js'
|
||||
import { firstNameLabel, fullNameLabel, isFirstNameUnknown } from '../utils/personName.js'
|
||||
import { firstNameLabel, fullNameLabel, isFirstNameUnknown, isSurnameUppercase, surnameLabel } from '../utils/personName.js'
|
||||
import { isYearOnly } from '../utils/dateInput.js'
|
||||
import { ageInYears } from '../utils/age.js'
|
||||
import DateField from './DateField.jsx'
|
||||
@@ -589,7 +589,7 @@ const PersonCard = ({
|
||||
}
|
||||
|
||||
// Rendu d'un champ éditable ou lecture seule
|
||||
const renderEditableValue = ({ field, value, placeholder, type = 'text', format = null, emptyLabel = '-' }) => {
|
||||
const renderEditableValue = ({ field, value, placeholder, type = 'text', format = null, emptyLabel = '-', caps = false }) => {
|
||||
if (!editMode) {
|
||||
const isEmptyValue = value === null || value === undefined || value === ''
|
||||
// Une date complète se lit « 22 octobre 1928 », une année seule « 1928 », pas « 1 janvier 1928 »
|
||||
@@ -613,7 +613,7 @@ const PersonCard = ({
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className="pc-input value--editable"
|
||||
className={`pc-input value--editable${caps && isSurnameUppercase() ? ' pz-caps' : ''}`}
|
||||
value={getEditValue(field, value)}
|
||||
onChange={(e) => handleFieldChange(field, e.target.value)}
|
||||
placeholder={placeholder || '...'}
|
||||
@@ -759,7 +759,7 @@ const PersonCard = ({
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
className="pc-input pc-input--name pc-input--last"
|
||||
className={`pc-input pc-input--name pc-input--last${isSurnameUppercase() ? ' pz-caps' : ''}`}
|
||||
value={getEditValue('lastName', person.lastName)}
|
||||
onChange={(e) => {
|
||||
setLastNameMissing(false)
|
||||
@@ -774,7 +774,7 @@ const PersonCard = ({
|
||||
) : (
|
||||
<h2 className="pc-name">
|
||||
{isFirstNameUnknown(person) ? <span className="pc-name-unknown">{firstNameLabel(person)}</span> : person.firstName}
|
||||
{person.lastName && <>{' '}<em>{person.lastName}</em></>}
|
||||
{person.lastName && <>{' '}<em>{surnameLabel(person.lastName)}</em></>}
|
||||
</h2>
|
||||
)}
|
||||
{!editMode && metaItems.length > 0 && (
|
||||
@@ -972,7 +972,7 @@ const PersonCard = ({
|
||||
<div className="pc-rows">
|
||||
{infoRow('birthYear', t('Naissance'), birthFilled, renderEditableValue({ field: 'birthYear', value: person.birthDate || person.birthYear, placeholder: t('Date de naissance'), type: 'date' }), true)}
|
||||
{infoRow('birthPlace', t('Lieu'), isFilled(getEditValue('birthPlace', person.birthPlace)), renderEditableValue({ field: 'birthPlace', value: person.birthPlace || '', placeholder: t('Lieu de naissance'), format: formatPlace }))}
|
||||
{infoRow('birthName', t('Nom de naissance'), isFilled(getEditValue('birthName', person.birthName)), renderEditableValue({ field: 'birthName', value: person.birthName || '', placeholder: t('Nom de naissance') }))}
|
||||
{infoRow('birthName', t('Nom de naissance'), isFilled(getEditValue('birthName', person.birthName)), renderEditableValue({ field: 'birthName', value: person.birthName || '', placeholder: t('Nom de naissance'), format: surnameLabel, caps: true }))}
|
||||
{infoRow('nickname', t('Surnom'), isFilled(getEditValue('nickname', person.nickname)), renderEditableValue({ field: 'nickname', value: person.nickname || '', placeholder: t('Surnom') }))}
|
||||
{editMode && (
|
||||
<div className="pc-row pc-row--seg" data-pc-field="sex">
|
||||
@@ -1068,7 +1068,7 @@ const PersonCard = ({
|
||||
const partnerId = u.partner1Id === person.id ? u.partner2Id : u.partner1Id
|
||||
const partner = persons.find(p => p.id === partnerId)
|
||||
const yearRange = u.startYear ? (u.endYear ? `${u.startYear}–${u.endYear}` : t('depuis {year}', { year: u.startYear })) : ''
|
||||
return `${partner ? firstNameLabel(partner) : '?'} ${partner?.lastName || ''}${yearRange ? ` (${yearRange})` : ''}`
|
||||
return `${partner ? firstNameLabel(partner) : '?'} ${surnameLabel(partner?.lastName)}${yearRange ? ` (${yearRange})` : ''}`
|
||||
}).join(', ')}
|
||||
</span>
|
||||
</div>
|
||||
@@ -1359,7 +1359,7 @@ const RelationSearchInline = forwardRef(function RelationSearchInline(
|
||||
<span className="pc-rel-avatar" aria-hidden="true">
|
||||
{p.photo ? <PortraitThumb src={p.photo} crop={p.avatarCrop} /> : <span>{p.firstName[0]}</span>}
|
||||
</span>
|
||||
<span className="pc-rel-name">{firstNameLabel(p)} <em>{p.lastName || ''}</em></span>
|
||||
<span className="pc-rel-name">{firstNameLabel(p)} <em>{surnameLabel(p.lastName)}</em></span>
|
||||
{p.birthYear && <span className="pc-rel-meta">{p.birthYear}</span>}
|
||||
</button>
|
||||
</li>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { surnameLabel } from '../utils/personName.js'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Check, FolderOpen, ImagePlus, X } from 'lucide-react'
|
||||
import './PhotoStartPanel.css'
|
||||
@@ -310,7 +311,7 @@ export default function PhotoStartPanel({
|
||||
{state.preview ? <img src={state.preview} alt="" /> : initialsOf(person)}
|
||||
</span>
|
||||
<span className="psp-face-id">
|
||||
<span className="psp-face-name">{`${person.firstName} ${person.lastName || ''}`.trim()}</span>
|
||||
<span className="psp-face-name">{`${person.firstName} ${surnameLabel(person.lastName)}`.trim()}</span>
|
||||
{years && <span className="psp-face-years">{years}</span>}
|
||||
{state.error && <span className="psp-face-error">{state.error}</span>}
|
||||
</span>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { X } from 'lucide-react'
|
||||
|
||||
import { t, dateLocale } from '../i18n/index.js'
|
||||
import { firstNameLabel } from '../utils/personName.js'
|
||||
import { firstNameLabel, surnameLabel } from '../utils/personName.js'
|
||||
import PzBusy from './PzBusy'
|
||||
import './ProposalCard.css'
|
||||
import { initialsOf } from '../utils/initial.js'
|
||||
@@ -73,7 +73,7 @@ function ReviewActions({ ghost, review }) {
|
||||
export default function ProposalCard({ person, summary = '', review = null, onClose }) {
|
||||
const ghost = person?.ghost
|
||||
const years = [person?.birthYear, person?.deathYear].filter(Boolean).join(' – ')
|
||||
const name = [firstNameLabel(person), person?.lastName].filter(Boolean).join(' ')
|
||||
const name = [firstNameLabel(person), surnameLabel(person?.lastName)].filter(Boolean).join(' ')
|
||||
const initials = initialsOf(person)
|
||||
return (
|
||||
<div className="person-card proposal-card" role="dialog" aria-label={t('Proposition : {name}', { name })}>
|
||||
@@ -88,7 +88,7 @@ export default function ProposalCard({ person, summary = '', review = null, onCl
|
||||
<p className="pz-eyebrow proposal-eyebrow">{ghost?.source === 'draft' ? t('Brouillon') : ghost?.source === 'sent' ? t('En attente') : t('Proposition')}</p>
|
||||
<h2 className="pc-name">
|
||||
{person?.firstName ? person.firstName : <span className="pc-name-unknown">{firstNameLabel(person)}</span>}
|
||||
{person?.lastName && <>{' '}<em>{person.lastName}</em></>}
|
||||
{person?.lastName && <>{' '}<em>{surnameLabel(person.lastName)}</em></>}
|
||||
</h2>
|
||||
{years && <p className="proposal-years">{years}</p>}
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { t, dateLocale } from '../i18n/index.js'
|
||||
import { fetchSearchSources, searchSource } from '../api/searchSourcesApi.js'
|
||||
import { SEARCH_LINKS, SEARCH_LINK_REGIONS } from '../data/searchLinks.js'
|
||||
import { changesFromResult, personFromResult } from '../utils/searchResultChanges.js'
|
||||
import { fullNameLabel } from '../utils/personName.js'
|
||||
import { fullNameLabel, surnameLabel } from '../utils/personName.js'
|
||||
import Skeleton from './Skeleton.jsx'
|
||||
import PortraitThumb from './PortraitThumb.jsx'
|
||||
import { withEmphasis } from '../utils/richText.jsx'
|
||||
@@ -384,7 +384,7 @@ function SearchSourcesPanel({ visible, treeId, token, persons = [], canApply = f
|
||||
<li key={person.id}>
|
||||
<button type="button" className={`apn-dropdown-item${picker.relative?.id === person.id ? ' is-selected' : ''}`} aria-pressed={picker.mode === 'new' ? picker.relative?.id === person.id : undefined} onClick={() => handlePick(person)} disabled={picker.saving}>
|
||||
<span className="apn-avatar" aria-hidden="true">{person.photo ? <PortraitThumb src={person.photo} crop={person.avatarCrop} /> : (person.firstName || '?').charAt(0)}</span>
|
||||
<span className="apn-dropdown-name">{person.firstName} <em>{person.lastName}</em></span>
|
||||
<span className="apn-dropdown-name">{person.firstName} <em>{surnameLabel(person.lastName)}</em></span>
|
||||
<span className={`apn-dropdown-date${yearOff && picker.mode === 'existing' ? ' sp-year-off' : ''}`} title={yearOff && picker.mode === 'existing' ? t("Pas la même année de naissance que ce résultat") : undefined}>{personYears(person)}</span>
|
||||
</button>
|
||||
</li>
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from './constants'
|
||||
import { getEntranceProgress, drawPartialBezier } from './utils'
|
||||
import { fitNickname } from '../../utils/nickname.js'
|
||||
import { firstNameLabel, isFirstNameUnknown } from '../../utils/personName.js'
|
||||
import { firstNameLabel, isFirstNameUnknown, surnameLabel } from '../../utils/personName.js'
|
||||
import { initialsOf } from '../../utils/initial.js'
|
||||
import { blurhashCanvas } from '../../utils/blurhash.js'
|
||||
|
||||
@@ -634,7 +634,7 @@ function drawPersonNode(ctx, node, pos, nodeProgress, {
|
||||
ctx.textAlign = 'center'
|
||||
ctx.textBaseline = 'middle'
|
||||
// Réglage « nom de famille sous le prénom » (#168) : celui de naissance s'il est connu, coupé comme le surnom
|
||||
const familyName = fullNames && withDetail ? String(person.birthName || person.lastName || '').trim() : ''
|
||||
const familyName = fullNames && withDetail ? surnameLabel(person.birthName || person.lastName) : ''
|
||||
const familyLabel = familyName ? fitNickname(ctx, familyName, NICKNAME_MAX_W) : ''
|
||||
const lineShift = familyLabel ? 15 : 0
|
||||
if (nameLabel) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import './SearchResultsDropdown.css'
|
||||
import { t } from '../../i18n/index.js'
|
||||
import { firstNameLabel } from '../../utils/personName.js'
|
||||
import { firstNameLabel, surnameLabel } from '../../utils/personName.js'
|
||||
import PortraitThumb from '../PortraitThumb.jsx'
|
||||
|
||||
// Raison du match renvoyée par usePersonSearch (valeur française), traduite à l'affichage
|
||||
@@ -70,7 +70,7 @@ function SearchResultsDropdown({
|
||||
{/* Info personne */}
|
||||
<div className="search-result-info">
|
||||
<div className="search-result-name">
|
||||
{firstNameLabel(person)} <span className="search-result-lastname">{person.lastName}</span>
|
||||
{firstNameLabel(person)} <span className="search-result-lastname">{surnameLabel(person.lastName)}</span>
|
||||
</div>
|
||||
<div className="search-result-meta">
|
||||
{person.birthYear && <span className="search-result-year">{person.birthYear}{person.deathYear ? `–${person.deathYear}` : ''}</span>}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useMemo, useRef, useState } from 'react'
|
||||
import { setMediaToken } from '../utils/mediaToken.js'
|
||||
import { setSurnameUppercase } from '../utils/personName.js'
|
||||
import { API_BASE_URL } from '../api/client'
|
||||
import { fetchTreeGraph, unlockTreeAccess } from '../api/treeApi'
|
||||
import { loadGraphData, persons as graphPersons, resetToDemoData } from '../data/mockData'
|
||||
@@ -41,6 +42,7 @@ export function useTreeAccess() {
|
||||
accessMode: '',
|
||||
rootPersonId: null,
|
||||
accessToken: '',
|
||||
surnameUppercase: false,
|
||||
})
|
||||
const [bootState, setBootState] = useState('loading')
|
||||
const [gateLoading, setGateLoading] = useState(false)
|
||||
@@ -68,6 +70,7 @@ export function useTreeAccess() {
|
||||
const openTreeGraph = async (treeId, token, options = {}) => {
|
||||
const graphPayload = await fetchTreeGraph(treeId, token)
|
||||
setMediaToken(graphPayload.mediaToken)
|
||||
setSurnameUppercase(graphPayload.surnameUppercase)
|
||||
loadGraphData(graphPayload.graph, {
|
||||
mediaToken: graphPayload.mediaToken,
|
||||
apiBaseUrl: API_BASE_URL,
|
||||
@@ -99,6 +102,7 @@ export function useTreeAccess() {
|
||||
accessMode: options.accessMode ?? current.accessMode,
|
||||
rootPersonId: preferredRootPersonId,
|
||||
accessToken: token,
|
||||
surnameUppercase: graphPayload.surnameUppercase,
|
||||
}))
|
||||
|
||||
const effectiveRole = normalizeRole(options.role)
|
||||
@@ -195,7 +199,9 @@ export function useTreeAccess() {
|
||||
accessMode: 'demo',
|
||||
rootPersonId: null,
|
||||
accessToken: '',
|
||||
surnameUppercase: false,
|
||||
})
|
||||
setSurnameUppercase(false)
|
||||
setBootState('ready')
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ export default {
|
||||
"Une belle-famille plus large qu'un écran s'ouvre dans son propre onglet au lieu d'être dessinée dans l'arbre. Réglage de ce navigateur.": 'An in-law family wider than a screen opens in its own tab instead of being drawn in the tree. Saved in this browser.',
|
||||
'Le nom de famille sous le prénom': 'Last name under the first name',
|
||||
"Le nom de naissance quand il est connu, sinon le nom d'usage. Réglage de ce navigateur.": 'The maiden name when it is known, otherwise the current last name. Saved in this browser.',
|
||||
'Les noms de famille en capitales': 'Last names in capitals',
|
||||
'Jeanne MARTIN plutôt que Jeanne Martin, pour toute la famille. Les noms restent enregistrés comme ils ont été tapés.': 'Jeanne MARTIN rather than Jeanne Martin, for the whole family. Names stay saved the way they were typed.',
|
||||
// Arbre sur canvas (components/galaxy/renderers.js)
|
||||
'Voir les parents': 'See parents',
|
||||
'Voir {firstName}': 'See {firstName}',
|
||||
|
||||
@@ -101,6 +101,8 @@ p, li, blockquote, figcaption, dd, .pz-sub, .pz-small, .pz-hint, .pz-error, .pz-
|
||||
outline: none; border-color: var(--pz-a500); box-shadow: 0 0 0 3px var(--pz-a100);
|
||||
}
|
||||
.pz-hint { font: 400 12.5px/1.45 var(--pz-sans); color: var(--pz-muted); margin: 0; }
|
||||
/* Nom de famille en capitales (réglage de l'arbre) : seul l'affichage change, l'indication garde sa casse */
|
||||
.pz-caps:not(:placeholder-shown) { text-transform: uppercase; }
|
||||
.pz-error {
|
||||
display: flex; gap: 8px; align-items: flex-start; padding: 11px 14px; border-radius: var(--pz-r-s);
|
||||
background: var(--pz-danger-bg); color: var(--pz-danger); font: 500 13.5px/1.45 var(--pz-sans);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// enfant), limitée aux années où la personne a vécu. Une fiche sans aucun événement a donc déjà une frise.
|
||||
|
||||
import { t, dateLocale } from '../i18n/index.js'
|
||||
import { firstNameLabel } from './personName.js'
|
||||
import { firstNameLabel, surnameLabel } from './personName.js'
|
||||
import { formatPlace } from './place.js'
|
||||
import { ageInYears } from './age.js'
|
||||
|
||||
@@ -62,7 +62,7 @@ const yearOf = (value) => {
|
||||
return match ? Number(match[1]) : null
|
||||
}
|
||||
|
||||
const fullName = (p) => [p?.firstName, p?.lastName].filter(Boolean).join(' ')
|
||||
const fullName = (p) => [p?.firstName, surnameLabel(p?.lastName)].filter(Boolean).join(' ')
|
||||
|
||||
// « 12 mars » pour une date complète, rien pour une année seule (stockée au 1er janvier)
|
||||
function dayMonth(value) {
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
import { t } from '../i18n/index.js'
|
||||
import { locale, t } from '../i18n/index.js'
|
||||
|
||||
// Noms de famille en capitales (« Bertrand GAUTHIER ») : réglage de l'arbre ouvert, reçu avec le graphe.
|
||||
// Seul l'affichage change, le nom reste enregistré tel qu'il a été tapé.
|
||||
let surnameUppercase = false
|
||||
|
||||
export function setSurnameUppercase(on) {
|
||||
surnameUppercase = Boolean(on)
|
||||
}
|
||||
|
||||
export function isSurnameUppercase() {
|
||||
return surnameUppercase
|
||||
}
|
||||
|
||||
// Nom de famille (ou de naissance) tel qu'il s'affiche
|
||||
export function surnameLabel(value) {
|
||||
const name = String(value ?? '').trim()
|
||||
return surnameUppercase ? name.toLocaleUpperCase(locale) : name
|
||||
}
|
||||
|
||||
// Prénom inconnu : le backend stocke une chaîne vide. L'affichage dit « Prénom inconnu » (en italique).
|
||||
export function isFirstNameUnknown(person) {
|
||||
@@ -11,5 +29,5 @@ export function firstNameLabel(person) {
|
||||
|
||||
// « Prénom Nom » pour une phrase ou une liste ; le prénom inconnu s'affiche comme son libellé
|
||||
export function fullNameLabel(person) {
|
||||
return [firstNameLabel(person), person?.lastName].filter(Boolean).join(' ').trim()
|
||||
return [firstNameLabel(person), surnameLabel(person?.lastName)].filter(Boolean).join(' ').trim()
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { firstNameLabel, fullNameLabel, isFirstNameUnknown } from './personName.js'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { firstNameLabel, fullNameLabel, isFirstNameUnknown, setSurnameUppercase, surnameLabel } from './personName.js'
|
||||
|
||||
describe('prénom inconnu', () => {
|
||||
it('un prénom vide ou blanc est inconnu', () => {
|
||||
@@ -18,3 +18,26 @@ describe('prénom inconnu', () => {
|
||||
expect(fullNameLabel({ firstName: 'Marie', lastName: '' })).toBe('Marie')
|
||||
})
|
||||
})
|
||||
|
||||
describe('noms de famille en capitales', () => {
|
||||
afterEach(() => setSurnameUppercase(false))
|
||||
|
||||
it('laisse le nom tel qu il a été tapé tant que le réglage est éteint', () => {
|
||||
expect(surnameLabel('Gauthier')).toBe('Gauthier')
|
||||
expect(fullNameLabel({ firstName: 'Bertrand', lastName: 'Gauthier' })).toBe('Bertrand Gauthier')
|
||||
})
|
||||
|
||||
it('met le nom en capitales, accents et particules compris, sans toucher au prénom', () => {
|
||||
setSurnameUppercase(true)
|
||||
expect(surnameLabel(' de la Fontaine ')).toBe('DE LA FONTAINE')
|
||||
expect(surnameLabel('Lefèvre-Hébert')).toBe('LEFÈVRE-HÉBERT')
|
||||
expect(fullNameLabel({ firstName: 'Bertrand', lastName: 'Gauthier' })).toBe('Bertrand GAUTHIER')
|
||||
expect(fullNameLabel({ firstName: '', lastName: 'Gauthier' })).toBe('Prénom inconnu GAUTHIER')
|
||||
})
|
||||
|
||||
it('ne transforme pas une valeur absente', () => {
|
||||
setSurnameUppercase(true)
|
||||
expect(surnameLabel(null)).toBe('')
|
||||
expect(surnameLabel(undefined)).toBe('')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user