Skip to content

Commit

Permalink
Fix handling of custom page size configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
cass-kazumori committed Jan 2, 2024
1 parent c3491a9 commit 155ced6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/models/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const sourceRotation = urlSafe(z.enum(["none", "90cw", "90ccw", "out_binding", "
/** @type { keyof typeof import("../constants").PAGE_SIZES } */
const availablePaperSizes = Object.keys(PAGE_SIZES);

const paperSize = urlSafe(z.enum(availablePaperSizes)).default("A4");
const paperSize = urlSafe(z.enum([...availablePaperSizes, "CUSTOM"])).default("A4");

const paperSizeUnit = urlSafe(z.enum(["pt", "in", "cm"])).default("pt");

Expand All @@ -52,12 +52,9 @@ const sigFormat = urlSafe(z.enum(["perfect", "standardsig", "customsig", "1_3rd"

const wackySpacing = urlSafe(z.enum(["wacky_pack", "wacky_gap"])).default("wacky_pack");

const fileDownload = urlSafe(z.enum(["aggregated", "both", "signatures"]).default("both"));

const printFile = urlSafe(z.enum(["aggregated", "signatures", "both"])).default("both");

export const schema = z.object({
fileDownload,
printFile,
sourceRotation,
rotatePage: urlSafe(coercedBoolean).default(false),
Expand Down
8 changes: 4 additions & 4 deletions src/utils/renderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ export function renderFormFromSettings(configuration) {
document.querySelector('select[name="printer_type"]').value = configuration.printerType;

// Set options which are not always present
if (configuration.paperSizeCustomHeight !== undefined) {
if (configuration.paperSize === "CUSTOM" && configuration.paperSizeCustomHeight !== undefined && configuration.paperSizeCustomWidth !== undefined) {
document.querySelector('input[name="paper_size_custom_height"]').value = configuration.paperSizeCustomHeight;
}

if (configuration.paperSizeCustomWidth !== undefined) {
document.querySelector('input[name="paper_size_custom_width"]').value = configuration.paperSizeCustomWidth;
updateAddOrRemoveCustomPaperOption();
updatePaperSelectOptionsUnits();
document.querySelector('select[name="paper_size"]').value = "CUSTOM";
}

if (configuration.sigFormat == "customsig") {
Expand Down

0 comments on commit 155ced6

Please sign in to comment.