diff --git a/frontend/src/client/admin-rules-edit.ts b/frontend/src/client/admin-rules-edit.ts index 694a0b5..f91d60a 100644 --- a/frontend/src/client/admin-rules-edit.ts +++ b/frontend/src/client/admin-rules-edit.ts @@ -51,7 +51,10 @@ interface Rule { interface ProceedingType { id: number; code: string; - name_de: string; + // `name` is the German display name on the wire; the Go `ProceedingType` + // model serialises `db:"name"` as JSON key `name`. Don't reach for + // `name_de` — that field does not exist in this payload (m/paliad#113). + name: string; name_en: string; } @@ -169,7 +172,8 @@ function fillProceedingSelect(selectId: string, list: ProceedingType[]) { for (const pt of list) { const opt = document.createElement("option"); opt.value = String(pt.id); - opt.textContent = `${pt.code} · ${getLang() === "en" ? pt.name_en : pt.name_de}`; + const name = getLang() === "en" ? pt.name_en : pt.name; + opt.textContent = name ? `${pt.code} · ${name}` : pt.code; sel.appendChild(opt); } } diff --git a/frontend/src/client/admin-rules-list.ts b/frontend/src/client/admin-rules-list.ts index b360f46..be6f736 100644 --- a/frontend/src/client/admin-rules-list.ts +++ b/frontend/src/client/admin-rules-list.ts @@ -29,7 +29,11 @@ interface Rule { interface ProceedingType { id: number; code: string; - name_de: string; + // `name` is the German display name on the wire; the Go `ProceedingType` + // model serialises `db:"name"` as JSON key `name` (the schema treats DE + // as primary). EN lives in `name_en`. Don't reach for `name_de` — that + // field does not exist in this payload (cf. m/paliad#113). + name: string; name_en: string; category: string; } @@ -125,7 +129,12 @@ function proceedingLabel(id: number | null | undefined): string { if (id == null) return "—"; const pt = proceedings.find((p) => p.id === id); if (!pt) return `#${id}`; - const name = getLang() === "en" ? pt.name_en : pt.name_de; + const name = getLang() === "en" ? pt.name_en : pt.name; + // Guard against a proceeding row that's missing the active-language + // name (or against a stale field-name mismatch slipping back in). + // Show the code on its own rather than "code · undefined" — that + // literal string is the smell that surfaced this bug (m/paliad#113). + if (!name) return pt.code; return `${pt.code} · ${name}`; } @@ -153,7 +162,8 @@ async function loadProceedings(): Promise { for (const pt of proceedings) { const opt = document.createElement("option"); opt.value = String(pt.id); - opt.textContent = `${pt.code} · ${getLang() === "en" ? pt.name_en : pt.name_de}`; + const name = getLang() === "en" ? pt.name_en : pt.name; + opt.textContent = name ? `${pt.code} · ${name}` : pt.code; sel.appendChild(opt); } }