Automatiska ID, nya registertyper och ID-register
- Löpande ID per bok och typ enligt idöversikten (KI, FI, BI, DI, LI, UI, FD, RI, RD, SI, REI, PI, SCI, KD-R_/KD-E_), prefix samlade i src/lib/ids.ts - Nya typer: Fordon, Skiss, Research, Referens, Appar, Hemsidor (grupp Register) - Sida med ID-register med sök och filter - Migration 0003_auto_ids med backfill av befintliga poster - ID visas i listor, postsidor, kartpanel och scheman - README och Register/-mallar Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0b65494cf5
commit
8a0e93f559
32 files changed
+664
-48
No files matched your search
+5
-2
@@ -5,6 +5,7 @@ import { prisma } from "@/lib/db";
|
||||
import { deleteImage, isUpload, saveImage } from "@/lib/files";
|
||||
import { revalidateBook, str } from "@/lib/form";
|
||||
import { MARKER_COLORS } from "@/lib/kinds";
|
||||
import { nextMapCode, nextMarkerCode } from "@/lib/ids";
|
||||
import { requireBook } from "@/lib/session";
|
||||
|
||||
async function requireMap(bookId: string, mapId: string) {
|
||||
@@ -27,7 +28,8 @@ export async function createMap(formData: FormData) {
|
||||
imageFile = await saveImage(upload);
|
||||
}
|
||||
|
||||
const map = await prisma.bookMap.create({ data: { bookId: book.id, name, kind, imageFile } });
|
||||
const code = await nextMapCode(book.id, kind);
|
||||
const map = await prisma.bookMap.create({ data: { bookId: book.id, code, name, kind, imageFile } });
|
||||
revalidateBook(book.id);
|
||||
redirect(`/books/${book.id}/maps/${map.id}`);
|
||||
}
|
||||
@@ -89,7 +91,8 @@ async function cleanMarker(bookId: string, input: MarkerInput) {
|
||||
|
||||
export async function createMarker(bookId: string, mapId: string, input: MarkerInput) {
|
||||
const { book, map } = await requireMap(bookId, mapId);
|
||||
await prisma.marker.create({ data: { ...(await cleanMarker(book.id, input)), mapId: map.id } });
|
||||
const data = await cleanMarker(book.id, input);
|
||||
await prisma.marker.create({ data: { ...data, code: await nextMarkerCode(book.id), mapId: map.id } });
|
||||
revalidateBook(book.id);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user