mirror of
https://github.com/IliesAllali/parenthese.git
synced 2026-11-16 16:33:28 +00:00
Merge pull request #87 from IliesAllali/fix/ajout-prenom-inconnu
Prénom inconnu, et fermer l'ajout au clic sur une personne
This commit is contained in:
18 files changed
+179
-50
No files matched your search
@@ -68,7 +68,7 @@ const reviewSessionSchema = z.object({
|
||||
})
|
||||
|
||||
const personCreateSchema = z.object({
|
||||
firstName: z.string().min(1).max(120),
|
||||
firstName: z.string().trim().max(120),
|
||||
lastName: z.string().min(1).max(120),
|
||||
birthName: z.string().max(120).optional().nullable(),
|
||||
nickname: z.string().max(120).optional().nullable(),
|
||||
@@ -85,7 +85,7 @@ const personCreateSchema = z.object({
|
||||
|
||||
const personUpdateSchema = z
|
||||
.object({
|
||||
firstName: z.string().min(1).max(120).optional(),
|
||||
firstName: z.string().trim().max(120).optional(),
|
||||
lastName: z.string().min(1).max(120).optional(),
|
||||
birthName: z.string().max(120).optional().nullable(),
|
||||
nickname: z.string().max(120).optional().nullable(),
|
||||
|
||||
@@ -258,8 +258,14 @@ function pushLifeEvent(lines: string[], event: ExportedEvent, tags: Record<strin
|
||||
|
||||
// ─── Name Parsing ────────────────────────────────────────────────────────────
|
||||
|
||||
// Valeur de « 1 NAME ». Prénom inconnu (chaîne vide) : « /Dupont/ », sans espace de tête
|
||||
export function gedcomNameValue(firstName: string, lastName: string): string {
|
||||
const given = firstName ? `${oneLine(firstName)} ` : ''
|
||||
return `${given}/${oneLine(lastName).replace(/\//g, '')}/`
|
||||
}
|
||||
|
||||
// « Jean /Dupont/ » : lu par indexOf, l'ancienne expression régulière était quadratique sur les espaces
|
||||
function parseGedcomName(value: string): { firstName: string; lastName: string } {
|
||||
export function parseGedcomName(value: string): { firstName: string; lastName: string } {
|
||||
const open = value.indexOf('/')
|
||||
const close = open >= 0 ? value.indexOf('/', open + 1) : -1
|
||||
if (open >= 0 && close > open) {
|
||||
@@ -453,7 +459,7 @@ export const gedcomRoutes: FastifyPluginAsync = async (app) => {
|
||||
for (const person of persons) {
|
||||
const xref = sanitizeXref(person.id)
|
||||
lines.push(`0 @I${xref}@ INDI`)
|
||||
lines.push(`1 NAME ${oneLine(person.firstName)} /${oneLine(person.lastName).replace(/\//g, '')}/`)
|
||||
lines.push(`1 NAME ${gedcomNameValue(person.firstName, person.lastName)}`)
|
||||
if (person.nickname) lines.push(`2 NICK ${oneLine(person.nickname)}`)
|
||||
|
||||
if (person.sex === 'male' || person.sex === 'M') lines.push('1 SEX M')
|
||||
@@ -655,7 +661,7 @@ export const gedcomRoutes: FastifyPluginAsync = async (app) => {
|
||||
const nameNode = findChild(indi, 'NAME')
|
||||
const { firstName, lastName } = nameNode
|
||||
? parseGedcomName(nameNode.value)
|
||||
: { firstName: '?', lastName: '' }
|
||||
: { firstName: '', lastName: '' }
|
||||
|
||||
const sexNode = findChild(indi, 'SEX')
|
||||
const sex = sexNode?.value === 'M' ? 'male' : sexNode?.value === 'F' ? 'female' : null
|
||||
@@ -671,7 +677,8 @@ export const gedcomRoutes: FastifyPluginAsync = async (app) => {
|
||||
|
||||
const notes = clip(personNotes(indi, records), 2000)
|
||||
|
||||
const personFirstName = (firstName || '?').slice(0, 120)
|
||||
// Prénom absent du fichier : chaîne vide, comme un prénom inconnu dans l'arbre
|
||||
const personFirstName = (firstName || '').slice(0, 120)
|
||||
const personLastName = (lastName || '').slice(0, 120)
|
||||
const birthDate = isoDateToDbDate(birthDateIso)
|
||||
const deathDate = isoDateToDbDate(deathDateIso)
|
||||
|
||||
@@ -273,6 +273,7 @@ export const mediaRoutes: FastifyPluginAsync = async (app) => {
|
||||
select: {
|
||||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -362,7 +363,7 @@ export const mediaRoutes: FastifyPluginAsync = async (app) => {
|
||||
submittedByLabel: payload.data.submittedByLabel?.trim() || contribution.submittedByLabel,
|
||||
mode: contribution.mode,
|
||||
status: contribution.autoStatus,
|
||||
title: `Souvenir pour ${person.firstName}`.slice(0, 120),
|
||||
title: `Souvenir pour ${person.firstName || person.lastName}`.slice(0, 120),
|
||||
reviewedAt: contribution.autoStatus === 'approved' ? now : undefined,
|
||||
reviewedBy: contribution.autoStatus === 'approved' ? contribution.submittedByUserId : undefined,
|
||||
},
|
||||
|
||||
@@ -84,7 +84,7 @@ const listAuditQuerySchema = z.object({
|
||||
const isoDateRegex = /^\d{4}-\d{2}-\d{2}$/
|
||||
|
||||
const createPersonSchema = z.object({
|
||||
firstName: z.string().min(1).max(120),
|
||||
firstName: z.string().trim().max(120),
|
||||
lastName: z.string().min(1).max(120),
|
||||
birthName: z.string().max(120).optional().nullable(),
|
||||
nickname: z.string().max(120).optional().nullable(),
|
||||
@@ -101,7 +101,7 @@ const createPersonSchema = z.object({
|
||||
|
||||
const patchPersonSchema = z
|
||||
.object({
|
||||
firstName: z.string().min(1).max(120).optional(),
|
||||
firstName: z.string().trim().max(120).optional(),
|
||||
lastName: z.string().min(1).max(120).optional(),
|
||||
birthName: z.string().max(120).optional().nullable(),
|
||||
nickname: z.string().max(120).optional().nullable(),
|
||||
@@ -2125,7 +2125,7 @@ export const treeRoutes: FastifyPluginAsync = async (app) => {
|
||||
|
||||
const person = await app.prisma.person.findFirst({
|
||||
where: { id: params.data.personId, treeId: params.data.id, deletedAt: null },
|
||||
select: { id: true, firstName: true },
|
||||
select: { id: true, firstName: true, lastName: true },
|
||||
})
|
||||
if (!person) return reply.code(404).send({ error: 'person_not_found' })
|
||||
|
||||
@@ -2164,7 +2164,7 @@ export const treeRoutes: FastifyPluginAsync = async (app) => {
|
||||
submittedByLabel: payload.data.submittedByLabel?.trim() || contribution.submittedByLabel,
|
||||
mode: contribution.mode,
|
||||
status: contribution.autoStatus,
|
||||
title: `Moment pour ${person.firstName}`.slice(0, 120),
|
||||
title: `Moment pour ${person.firstName || person.lastName}`.slice(0, 120),
|
||||
reviewedAt: isPending ? undefined : new Date(),
|
||||
reviewedBy: isPending ? undefined : contribution.submittedByUserId,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user