Fälttyp för koppling till post i mallar

- Ny fälttyp reference med valfri posttyp (refKind): rullista i formuläret,
  länk med ID på postsidan och rutan "Används av" på den kopplade posten
- Server kontrollerar att kopplad post finns i boken och har rätt typ
- Gemensam hantering av fältvärden (lib/field-values.ts) för poster och relationer
- Standardmallar använder kopplingar för Lokal, Skiss, Företag, Ägare och Referens
- Mallredigerare, översättningar och README

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-24 21:02:39 +02:00
1 parent 6cea76899f
commit e840adf526
13 files changed
+235 -57

No files matched your search

@@ -3,6 +3,7 @@ import { saveEntity } from "@/actions/entities";
import { EntityForm } from "@/components/entity-form";
import { PageBody, PageHeader } from "@/components/page";
import { getT } from "@/i18n/server";
import { prisma } from "@/lib/db";
import { KIND_BY_SLUG } from "@/lib/kinds";
import { requireBook } from "@/lib/session";
import { getTemplate } from "@/lib/templates";
@@ -21,6 +22,11 @@ export default async function NewEntityPage({
if (!info) notFound();
const { t, locale } = await getT();
const { fields } = await getTemplate(bookId, info.kind, locale);
const refEntities = await prisma.entity.findMany({
where: { bookId },
select: { id: true, name: true, kind: true, code: true },
orderBy: { name: "asc" },
});
return (
<>
@@ -31,6 +37,7 @@ export default async function NewEntityPage({
bookId={bookId}
kind={info.kind}
fields={fields}
refEntities={refEntities}
defaultName={name?.slice(0, 200)}
cancelHref={`/books/${bookId}/e/${slug}`}
t={t}