feat(est): save print settings to ESTX
This commit is contained in:
@@ -123,7 +123,10 @@ const EstReport = (() => {
|
||||
const original = new Map(
|
||||
(EstApp.state.project.printCatalog || []).map((row) => [row.Index, row]),
|
||||
);
|
||||
catalog = defaults.map((row) => ({ ...row, ...original.get(row.Index) }));
|
||||
catalog = defaults.map((row) => ({
|
||||
...row,
|
||||
...original.get(row.Index),
|
||||
}));
|
||||
const table = EstApp.state.project.tables[EstApp.state.view];
|
||||
const s = setting(),
|
||||
{ esc } = EstApp;
|
||||
@@ -174,7 +177,11 @@ const EstReport = (() => {
|
||||
EstApp.change(() => {
|
||||
const next = { ...setting(), [key]: value };
|
||||
if (key === "form") {
|
||||
const original = catalog.find((row) => String(row.Index) === value);
|
||||
const found = catalog.find((row) => String(row.Index) === value);
|
||||
const original = found && {
|
||||
...found,
|
||||
...EstApp.state.project.nativePrintChanges?.[value],
|
||||
};
|
||||
if (original) {
|
||||
next.rowsPerPage = Math.max(
|
||||
1,
|
||||
@@ -188,6 +195,18 @@ const EstReport = (() => {
|
||||
EstApp.state.project.documents ||= {};
|
||||
EstApp.state.project.documents[next.form] = value;
|
||||
}
|
||||
if (
|
||||
["margin", "rowsPerPage"].includes(key) &&
|
||||
next.form !== "current" &&
|
||||
EstApp.state.project.printCatalog?.some((row) => String(row.Index) === next.form)
|
||||
) {
|
||||
EstApp.state.project.nativePrintChanges ||= {};
|
||||
const changes = (EstApp.state.project.nativePrintChanges[next.form] ||= {});
|
||||
if (key === "margin")
|
||||
for (const side of ["PrintTop", "PrintBottom", "PrintLeft", "PrintRight"])
|
||||
changes[side] = value;
|
||||
else changes.PrintLineCount = value;
|
||||
}
|
||||
if (key === "form") next.notes = EstApp.state.project.documents?.[value] || "";
|
||||
EstApp.state.project.printSettings = next;
|
||||
}, false);
|
||||
|
||||
Reference in New Issue
Block a user