Ignore custom margins on certain templates.

This commit is contained in:
Patrick Fic
2022-03-22 13:41:06 -06:00
parent 15c305317a
commit f2b2011900
2 changed files with 27 additions and 18 deletions

View File

@@ -24,6 +24,7 @@ export default async function RenderTemplate(
let { contextData, useShopSpecificTemplate } = await fetchContextData( let { contextData, useShopSpecificTemplate } = await fetchContextData(
templateObject templateObject
); );
const { ignoreCustomMargins } = Templates[templateObject.name];
let reportRequest = { let reportRequest = {
template: { template: {
@@ -34,18 +35,22 @@ export default async function RenderTemplate(
? {} ? {}
: { : {
recipe: "chrome-pdf", recipe: "chrome-pdf",
chrome: { ...(!ignoreCustomMargins && {
marginTop: chrome: {
(bodyshop.logo_img_path && marginTop:
bodyshop.logo_img_path &&
bodyshop.logo_img_path.headerMargin && bodyshop.logo_img_path.headerMargin &&
bodyshop.logo_img_path.headerMargin > 36) || bodyshop.logo_img_path.headerMargin > 36
"36px", ? bodyshop.logo_img_path.headerMargin
marginBottom: : "36px",
(bodyshop.logo_img_path && marginBottom:
bodyshop.logo_img_path &&
bodyshop.logo_img_path.footerMargin && bodyshop.logo_img_path.footerMargin &&
bodyshop.logo_img_path.footerMargin > 36) || bodyshop.logo_img_path.footerMargin > 36
"36px", ? bodyshop.logo_img_path.footerMargin
}, : "36px",
},
}),
}), }),
...(renderAsExcel ? { recipe: "html-to-xlsx" } : {}), ...(renderAsExcel ? { recipe: "html-to-xlsx" } : {}),
}, },
@@ -143,15 +148,17 @@ export async function RenderTemplates(
recipe: "chrome-pdf", recipe: "chrome-pdf",
chrome: { chrome: {
marginTop: marginTop:
(bodyshop.logo_img_path && bodyshop.logo_img_path &&
bodyshop.logo_img_path.headerMargin && bodyshop.logo_img_path.headerMargin &&
bodyshop.logo_img_path.headerMargin > 36) || bodyshop.logo_img_path.headerMargin > 36
"36px", ? bodyshop.logo_img_path.headerMargin
: "36px",
marginBottom: marginBottom:
(bodyshop.logo_img_path && bodyshop.logo_img_path &&
bodyshop.logo_img_path.footerMargin && bodyshop.logo_img_path.footerMargin &&
bodyshop.logo_img_path.footerMargin > 36) || bodyshop.logo_img_path.footerMargin > 36
"36px", ? bodyshop.logo_img_path.footerMargin
: "36px",
}, },
}), }),
pdfOperations: templateAndData.map((template) => { pdfOperations: templateAndData.map((template) => {

View File

@@ -371,6 +371,7 @@ export const TemplateList = (type, context) => {
subject: i18n.t("printcenter.jobs.parts_label_single"), subject: i18n.t("printcenter.jobs.parts_label_single"),
disabled: false, disabled: false,
group: "ro", group: "ro",
ignoreCustomMargins: true,
}, },
envelope_return_address: { envelope_return_address: {
title: i18n.t("printcenter.jobs.envelope_return_address"), title: i18n.t("printcenter.jobs.envelope_return_address"),
@@ -379,6 +380,7 @@ export const TemplateList = (type, context) => {
key: "envelope_return_address", key: "envelope_return_address",
disabled: false, disabled: false,
group: "ro", group: "ro",
ignoreCustomMargins: true,
}, },
sgi_certificate_of_repairs: { sgi_certificate_of_repairs: {
title: i18n.t("printcenter.jobs.sgi_certificate_of_repairs"), title: i18n.t("printcenter.jobs.sgi_certificate_of_repairs"),