[78] Plannummer im Titelblock (laufend oder Layout.planNumber), Sheet und PDF; Tests
This commit is contained in:
1 parent
5fec1ea809
commit
8a4e7293dc
5 files changed
+27
-3
No files matched your search
@@ -57,7 +57,8 @@ function drawTitleBlock(
|
|||||||
doc.setTextColor(17, 17, 17);
|
doc.setTextColor(17, 17, 17);
|
||||||
doc.setFont("helvetica", "bold");
|
doc.setFont("helvetica", "bold");
|
||||||
doc.setFontSize(9);
|
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.setFont("helvetica", "normal");
|
||||||
doc.setFontSize(8);
|
doc.setFontSize(8);
|
||||||
|
|||||||
@@ -270,6 +270,15 @@ describe("resolveTitleBlock — Master-Vererbung + Defaults", () => {
|
|||||||
expect(tb.scale).toBe("1:50");
|
expect(tb.scale).toBe("1:50");
|
||||||
expect(tb.date).toBe("2026-07-07");
|
expect(tb.date).toBe("2026-07-07");
|
||||||
expect(tb.author).toBe("");
|
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", () => {
|
it("Master-Werte übersteuern die Defaults", () => {
|
||||||
|
|||||||
@@ -641,6 +641,8 @@ export interface ResolvedTitleBlock {
|
|||||||
scale: string;
|
scale: string;
|
||||||
date: string;
|
date: string;
|
||||||
author: 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}` : "—"),
|
scale: nonEmpty(tb.scale) ?? (scaleN ? `1:${scaleN}` : "—"),
|
||||||
date: nonEmpty(tb.date) ?? today,
|
date: nonEmpty(tb.date) ?? today,
|
||||||
author: nonEmpty(tb.author) ?? "",
|
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
|
* Sichtbare Kategorie-Codes eines Ausschnitts als Set (für `generatePlan`). Aus
|
||||||
* der gespeicherten `layerVisibility`-Map (Code → sichtbar) abgeleitet.
|
* der gespeicherten `layerVisibility`-Map (Code → sichtbar) abgeleitet.
|
||||||
|
|||||||
@@ -2748,6 +2748,8 @@ export interface Layout {
|
|||||||
name: string;
|
name: string;
|
||||||
paper: LayoutPaperFormat;
|
paper: LayoutPaperFormat;
|
||||||
orientation: LayoutOrientation;
|
orientation: LayoutOrientation;
|
||||||
|
/** Eigene Plannummer im Titelblock; fehlt = laufende Nummer (`resolveTitleBlock`). */
|
||||||
|
planNumber?: string;
|
||||||
/** Referenz auf ein {@link MasterLayout}; ohne → kein Master (blanko Blatt). */
|
/** Referenz auf ein {@link MasterLayout}; ohne → kein Master (blanko Blatt). */
|
||||||
masterId?: string;
|
masterId?: string;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export function TitleBlockSvg({
|
|||||||
orientation,
|
orientation,
|
||||||
}: {
|
}: {
|
||||||
sheet: { w: number; h: number };
|
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;
|
paper: LayoutPaperFormat;
|
||||||
orientation: LayoutOrientation;
|
orientation: LayoutOrientation;
|
||||||
}) {
|
}) {
|
||||||
@@ -157,7 +157,10 @@ export function TitleBlockSvg({
|
|||||||
<line x1={x} y1={y + 8} x2={x + boxW} y2={y + 8} stroke="#111111" strokeWidth={0.2} />
|
<line x1={x} y1={y + 8} x2={x + boxW} y2={y + 8} stroke="#111111" strokeWidth={0.2} />
|
||||||
<line x1={x} y1={y + boxH - 7} x2={x + boxW} y2={y + boxH - 7} stroke="#111111" strokeWidth={0.2} />
|
<line x1={x} y1={y + boxH - 7} x2={x + boxW} y2={y + boxH - 7} stroke="#111111" strokeWidth={0.2} />
|
||||||
<text x={x + 3} y={y + 5.6} fontSize={3.4} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111">
|
<text x={x + 3} y={y + 5.6} fontSize={3.4} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111">
|
||||||
{clip(tb.projectName, 34)}
|
{clip(tb.projectName, 28)}
|
||||||
|
</text>
|
||||||
|
<text x={x + boxW - 3} y={y + 5.6} fontSize={3.4} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111" textAnchor="end">
|
||||||
|
{tb.planNumber}
|
||||||
</text>
|
</text>
|
||||||
<text x={x + 3} y={y + 13} fontSize={3} fontFamily="Helvetica, Arial, sans-serif" fill="#111111">
|
<text x={x + 3} y={y + 13} fontSize={3} fontFamily="Helvetica, Arial, sans-serif" fill="#111111">
|
||||||
{clip(tb.sheetName, 36)}
|
{clip(tb.sheetName, 36)}
|
||||||
|
|||||||
Reference in new issue
Block a user