[79][80][82] Publikationssätze, PDF-Ebenen und grafische Legenden auf Layout-Blättern
Publikationssätze: Satz aus Layouts/Ansichten mit Ausgabe (PDF ein Dokument oder je Blatt, DXF/DWG mit Layouts), Dateinamen-Muster, Papier-/Massstab-Übersteuerung, Revisionsindex (im Titelblock, optional hochgezählt) und Protokoll. PDF-Ebenen: Optional Content selbst geschrieben (jsPDF kennt keine), je Kategorie/Viewport, Rahmen, Blatt-Zeichnung, Legende. Legenden: Material/Schraffur, Linientyp, Kategorie aus den Viewports (oder Handauswahl), Muster vom Kern-Generator. Modellfelder nur in Rust (optional): publishSets, publishLog, projectNumber, Layout.revision, Layout.legends.
This commit is contained in:
27 files changed
+1979
-68
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// Publikationssätze ([79]) in der Hülle: Satz anlegen/ändern/löschen als Ops, Satz ausführen = Dateien erzeugen,
|
||||
// speichern (mehrere als ZIP), Revisionsindex erhöhen und ins Protokoll schreiben (ein Undo-Schritt).
|
||||
|
||||
import { fieldOps, type CoreOp } from "../core";
|
||||
import type { Project, PublishSet } from "../model/types";
|
||||
import { planPublish, publishOps } from "../export/publishSet";
|
||||
import { bundlePublished, runPublish } from "../export/publishRun";
|
||||
import { saveBinaryFile } from "../native/saveFile";
|
||||
import { getState } from "./appStore";
|
||||
import { t } from "../i18n";
|
||||
|
||||
export function addPublishSetOps(p: Project, id: string): CoreOp[] {
|
||||
const set: PublishSet = { id, name: t("publish.defaultName"), layoutIds: (p.layouts ?? []).map((l) => l.id) };
|
||||
return fieldOps(p, "publishSets", [...(p.publishSets ?? []), set]);
|
||||
}
|
||||
|
||||
export function patchPublishSetOps(p: Project, id: string, patch: Partial<Omit<PublishSet, "id">>): CoreOp[] {
|
||||
return fieldOps(p, "publishSets", (p.publishSets ?? []).map((s) => (s.id === id ? { ...s, ...patch } : s)));
|
||||
}
|
||||
|
||||
export function deletePublishSetOps(p: Project, id: string): CoreOp[] {
|
||||
return fieldOps(p, "publishSets", (p.publishSets ?? []).filter((s) => s.id !== id));
|
||||
}
|
||||
|
||||
/** Führt einen Satz aus; liefert die Ops (Index + Protokoll), wenn gespeichert wurde, sonst `null`. */
|
||||
export async function publishSet(project: Project, setId: string): Promise<CoreOp[] | null> {
|
||||
const set = (project.publishSets ?? []).find((s) => s.id === setId);
|
||||
if (!set) return null;
|
||||
const now = new Date();
|
||||
const plan = planPublish(project, set, now.toISOString().slice(0, 10));
|
||||
if (plan.files.length === 0) {
|
||||
getState().notify(t("publish.empty"), "error");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const files = await runPublish(project, set, plan);
|
||||
const bundle = await bundlePublished(files, `${set.name}.zip`);
|
||||
if (!bundle) return null;
|
||||
const saved = await saveBinaryFile(bundle.bytes, bundle.fileName, bundle.mime);
|
||||
if (!saved) return null;
|
||||
getState().notify(`${t("publish.done")}: ${files.length}`, "info");
|
||||
return publishOps(project, set, plan, now.toISOString(), `pub-${now.getTime()}`);
|
||||
} catch (err) {
|
||||
getState().notify(`${t("publish.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
createSheetLevel,
|
||||
} from "../model/layoutModel";
|
||||
import { folderPdfBytes } from "../export/layoutPdf";
|
||||
import { addPublishSetOps, deletePublishSetOps, patchPublishSetOps, publishSet } from "./publishActions";
|
||||
import { saveBinaryFile } from "../native/saveFile";
|
||||
import type { useProjectActions } from "./useProjectActions";
|
||||
import type { useSelectionState } from "./useSelectionState";
|
||||
@@ -1447,6 +1448,19 @@ export function usePanelHostBase(opts: {
|
||||
fieldOps(p, "layoutFolders", moveFolderToFolder(p.layoutFolders ?? [], folderId, parentId)),
|
||||
);
|
||||
},
|
||||
onAddPublishSet: () => {
|
||||
const id = `pubset-${Date.now()}`;
|
||||
applyChange((p) => addPublishSetOps(p, id));
|
||||
return id;
|
||||
},
|
||||
onPatchPublishSet: (id, patch) => applyChange((p) => patchPublishSetOps(p, id, patch), `pubset-${id}`),
|
||||
onSetProjectNumber: (value) => applyChange((p) => fieldOps(p, "projectNumber", value.trim() ? value : undefined), "projectNumber"),
|
||||
onDeletePublishSet: (id) => applyChange((p) => deletePublishSetOps(p, id)),
|
||||
onPublishSet: (id) => {
|
||||
void publishSet(project, id).then((ops) => {
|
||||
if (ops && ops.length > 0) applyChange(ops);
|
||||
});
|
||||
},
|
||||
};
|
||||
return value;
|
||||
// setProject-Closures sind stabil genug; Neuberechnung bei project/active.
|
||||
|
||||
Reference in new issue
Block a user