From f2b2011900d3ebfe14f5f052812860680c6639d3 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 22 Mar 2022 13:41:06 -0600 Subject: [PATCH] Ignore custom margins on certain templates. --- client/src/utils/RenderTemplate.js | 43 ++++++++++++++++----------- client/src/utils/TemplateConstants.js | 2 ++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/client/src/utils/RenderTemplate.js b/client/src/utils/RenderTemplate.js index 9a2201c2f..716322937 100644 --- a/client/src/utils/RenderTemplate.js +++ b/client/src/utils/RenderTemplate.js @@ -24,6 +24,7 @@ export default async function RenderTemplate( let { contextData, useShopSpecificTemplate } = await fetchContextData( templateObject ); + const { ignoreCustomMargins } = Templates[templateObject.name]; let reportRequest = { template: { @@ -34,18 +35,22 @@ export default async function RenderTemplate( ? {} : { recipe: "chrome-pdf", - chrome: { - marginTop: - (bodyshop.logo_img_path && + ...(!ignoreCustomMargins && { + chrome: { + marginTop: + bodyshop.logo_img_path && bodyshop.logo_img_path.headerMargin && - bodyshop.logo_img_path.headerMargin > 36) || - "36px", - marginBottom: - (bodyshop.logo_img_path && + bodyshop.logo_img_path.headerMargin > 36 + ? bodyshop.logo_img_path.headerMargin + : "36px", + marginBottom: + bodyshop.logo_img_path && bodyshop.logo_img_path.footerMargin && - bodyshop.logo_img_path.footerMargin > 36) || - "36px", - }, + bodyshop.logo_img_path.footerMargin > 36 + ? bodyshop.logo_img_path.footerMargin + : "36px", + }, + }), }), ...(renderAsExcel ? { recipe: "html-to-xlsx" } : {}), }, @@ -143,15 +148,17 @@ export async function RenderTemplates( recipe: "chrome-pdf", chrome: { marginTop: - (bodyshop.logo_img_path && - bodyshop.logo_img_path.headerMargin && - bodyshop.logo_img_path.headerMargin > 36) || - "36px", + bodyshop.logo_img_path && + bodyshop.logo_img_path.headerMargin && + bodyshop.logo_img_path.headerMargin > 36 + ? bodyshop.logo_img_path.headerMargin + : "36px", marginBottom: - (bodyshop.logo_img_path && - bodyshop.logo_img_path.footerMargin && - bodyshop.logo_img_path.footerMargin > 36) || - "36px", + bodyshop.logo_img_path && + bodyshop.logo_img_path.footerMargin && + bodyshop.logo_img_path.footerMargin > 36 + ? bodyshop.logo_img_path.footerMargin + : "36px", }, }), pdfOperations: templateAndData.map((template) => { diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js index 6201afada..06f624a4a 100644 --- a/client/src/utils/TemplateConstants.js +++ b/client/src/utils/TemplateConstants.js @@ -371,6 +371,7 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.parts_label_single"), disabled: false, group: "ro", + ignoreCustomMargins: true, }, envelope_return_address: { title: i18n.t("printcenter.jobs.envelope_return_address"), @@ -379,6 +380,7 @@ export const TemplateList = (type, context) => { key: "envelope_return_address", disabled: false, group: "ro", + ignoreCustomMargins: true, }, sgi_certificate_of_repairs: { title: i18n.t("printcenter.jobs.sgi_certificate_of_repairs"),