diff --git a/src/export/layoutPdf.ts b/src/export/layoutPdf.ts index 67546757..acf8e159 100644 --- a/src/export/layoutPdf.ts +++ b/src/export/layoutPdf.ts @@ -57,7 +57,8 @@ function drawTitleBlock( doc.setTextColor(17, 17, 17); doc.setFont("helvetica", "bold"); doc.setFontSize(9); - doc.text(clip(tb.projectName, 34), x + 3, y + 5.6); + doc.text(clip(tb.projectName, 28), x + 3, y + 5.6); + doc.text(tb.planNumber, x + boxW - 3, y + 5.6, { align: "right" }); doc.setFont("helvetica", "normal"); doc.setFontSize(8); diff --git a/src/model/layoutModel.test.ts b/src/model/layoutModel.test.ts index 4adbff36..2eb41bd6 100644 --- a/src/model/layoutModel.test.ts +++ b/src/model/layoutModel.test.ts @@ -270,6 +270,15 @@ describe("resolveTitleBlock — Master-Vererbung + Defaults", () => { expect(tb.scale).toBe("1:50"); expect(tb.date).toBe("2026-07-07"); expect(tb.author).toBe(""); + expect(tb.planNumber).toBe("01"); // nicht in project.layouts → erste Nummer + }); + + it("Plannummer: laufend nach Reihenfolge, eigene Nummer übersteuert", () => { + const a = createLayout("a", "A", "a4", "portrait"); + const b = createLayout("b", "B", "a4", "portrait"); + const pp = { ...p, layouts: [a, b] }; + expect(resolveTitleBlock(pp, b, undefined, "2026-07-07").planNumber).toBe("02"); + expect(resolveTitleBlock(pp, { ...b, planNumber: "A-101" }, undefined, "2026-07-07").planNumber).toBe("A-101"); }); it("Master-Werte übersteuern die Defaults", () => { diff --git a/src/model/layoutModel.ts b/src/model/layoutModel.ts index e92709f9..8fa7ab74 100644 --- a/src/model/layoutModel.ts +++ b/src/model/layoutModel.ts @@ -641,6 +641,8 @@ export interface ResolvedTitleBlock { scale: string; date: string; author: string; + /** Plannummer: `Layout.planNumber`, sonst laufende Nummer des Blatts im Projekt ("01", "02" …). */ + planNumber: string; } /** @@ -671,9 +673,16 @@ export function resolveTitleBlock( scale: nonEmpty(tb.scale) ?? (scaleN ? `1:${scaleN}` : "—"), date: nonEmpty(tb.date) ?? today, author: nonEmpty(tb.author) ?? "", + planNumber: nonEmpty(layout.planNumber) ?? autoPlanNumber(project, layout), }; } +/** Laufende Plannummer: Position des Layouts in `project.layouts` (1-basiert, zweistellig). */ +function autoPlanNumber(project: Project, layout: Layout): string { + const i = (project.layouts ?? []).findIndex((l) => l.id === layout.id); + return String((i < 0 ? 0 : i) + 1).padStart(2, "0"); +} + /** * Sichtbare Kategorie-Codes eines Ausschnitts als Set (für `generatePlan`). Aus * der gespeicherten `layerVisibility`-Map (Code → sichtbar) abgeleitet. diff --git a/src/model/types.ts b/src/model/types.ts index 50e25b2f..0922d68a 100644 --- a/src/model/types.ts +++ b/src/model/types.ts @@ -2748,6 +2748,8 @@ export interface Layout { name: string; paper: LayoutPaperFormat; orientation: LayoutOrientation; + /** Eigene Plannummer im Titelblock; fehlt = laufende Nummer (`resolveTitleBlock`). */ + planNumber?: string; /** Referenz auf ein {@link MasterLayout}; ohne → kein Master (blanko Blatt). */ masterId?: string; /** diff --git a/src/ui/LayoutSheet.tsx b/src/ui/LayoutSheet.tsx index 8af711f7..90e68253 100644 --- a/src/ui/LayoutSheet.tsx +++ b/src/ui/LayoutSheet.tsx @@ -141,7 +141,7 @@ export function TitleBlockSvg({ orientation, }: { sheet: { w: number; h: number }; - tb: { projectName: string; sheetName: string; scale: string; date: string; author: string }; + tb: { projectName: string; sheetName: string; scale: string; date: string; author: string; planNumber: string }; paper: LayoutPaperFormat; orientation: LayoutOrientation; }) { @@ -157,7 +157,10 @@ export function TitleBlockSvg({ - {clip(tb.projectName, 34)} + {clip(tb.projectName, 28)} + + + {tb.planNumber} {clip(tb.sheetName, 36)}