Släktträd och tidslinje
Relationer får ett släktband (förälder, partner, syskon) och en period. Nytt släktträd som ritas av släktbanden, och en tidslinje som samlar födelse och död, scenarier, egna händelser och relationsperioder med ålder vid varje tillfälle. Datum skrivs som ÅÅÅÅ, ÅÅÅÅ-MM eller ÅÅÅÅ-MM-DD. Följer med i export, import och papperskorg. Migreringen 0006 ger gamla relationer som "Förälder till" rätt släktband. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dcb5d43429
commit
bd269d70a5
32 files changed
+2285
-25
No files matched your search
+16
-3
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdir, readdir, rm } from "node:fs/promises";
|
||||
import type { EntityKind, Prisma } from "@prisma/client";
|
||||
import type { EntityKind, FamilyBond, Prisma } from "@prisma/client";
|
||||
import { describe } from "vitest";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { UPLOAD_DIR } from "@/lib/files";
|
||||
@@ -56,8 +56,21 @@ export async function makeEntity(
|
||||
});
|
||||
}
|
||||
|
||||
export async function makeRelation(bookId: string, fromId: string, toId: string, type = "Vänner", memberIds: string[] = []) {
|
||||
export async function makeRelation(
|
||||
bookId: string,
|
||||
fromId: string,
|
||||
toId: string,
|
||||
type = "Vänner",
|
||||
memberIds: string[] = [],
|
||||
extra: { bond?: FamilyBond; startDate?: string; endDate?: string } = {},
|
||||
) {
|
||||
return prisma.relation.create({
|
||||
data: { bookId, fromId, toId, type, code: await nextRelationCode(bookId), members: { create: memberIds.map((entityId) => ({ entityId })) } },
|
||||
data: { bookId, fromId, toId, type, ...extra, code: await nextRelationCode(bookId), members: { create: memberIds.map((entityId) => ({ entityId })) } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function makeEvent(bookId: string, title: string, date: string, participantIds: string[] = [], extra: { endDate?: string; description?: string } = {}) {
|
||||
return prisma.storyEvent.create({
|
||||
data: { bookId, title, date, ...extra, participants: { create: participantIds.map((entityId) => ({ entityId })) } },
|
||||
});
|
||||
}
|
||||
@@ -11,6 +11,7 @@ export function validExport(overrides: Partial<ExportData> = {}): ExportData {
|
||||
book: { title: "Testbok", subtitle: null, genre: null, description: null },
|
||||
entities: [],
|
||||
relations: [],
|
||||
events: [],
|
||||
shifts: [],
|
||||
maps: [],
|
||||
templates: [],
|
||||
@@ -22,6 +23,10 @@ export function entityRow(id: string, kind: ExportData["entities"][number]["kind
|
||||
return { id, kind, name, code: null, summary: null, tags: [], data: {}, image: null, ...extra };
|
||||
}
|
||||
|
||||
export function relationRow(id: string, fromId: string, toId: string, type: string, extra: Partial<ExportData["relations"][number]> = {}): ExportData["relations"][number] {
|
||||
return { id, code: null, fromId, toId, type, description: null, data: {}, members: [], bond: null, startDate: null, endDate: null, ...extra };
|
||||
}
|
||||
|
||||
/** En riktig bild (PNG, JPEG eller WebP) av önskad storlek, för tester av bildbehandling och uppladdning. */
|
||||
export async function makeImage(
|
||||
width: number,
|
||||
|
||||
Reference in new issue
Block a user