From f7e74c50437ea9a572763f3bf8af63b43b997c13 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 11 Sep 2020 14:43:04 -0700 Subject: [PATCH] Modified how template list is generated to be a function to allow checking whether the templates can be printed. --- client/public/render-styles.css | 56 ++++--- client/src/components/_test/paymentMethod.jsx | 4 +- ...bs-detail-header-actions.csi.component.jsx | 12 +- .../parts-order-modal.container.jsx | 8 +- .../payment-modal/payment-modal.container.jsx | 4 +- .../print-center-jobs.component.jsx | 26 ++-- .../print-center-jobs.list.js | 60 -------- .../print-center-speed-print.component.jsx | 4 +- .../schedule-job-modal.container.jsx | 2 +- .../shop-info/shop-info.intake.component.jsx | 12 +- .../shop-info.speedprint.component.jsx | 4 +- .../shop-template-add.component.jsx | 2 +- ...-template-editor-save-button.component.jsx | 9 +- .../shop-template-editor.component.jsx | 12 +- .../shop-template-test-render.component.jsx | 7 +- .../shop-templates-list.container.jsx | 6 +- ...me-tickets-summary-employees.component.jsx | 2 +- client/src/utils/TemplateConstants.js | 140 ++++++++++-------- client/templates/helpers.md | 3 + server/render/renderHandlebars.js | 1 + 20 files changed, 167 insertions(+), 207 deletions(-) delete mode 100644 client/src/components/print-center-jobs/print-center-jobs.list.js diff --git a/client/public/render-styles.css b/client/public/render-styles.css index 8e7aef8ec..f4232a02a 100644 --- a/client/public/render-styles.css +++ b/client/public/render-styles.css @@ -1,36 +1,13 @@ body { - font-family: "Open Sans", sans-serif; - line-height: 1.25; + /* font-family: "Open Sans", sans-serif; */ + /* line-height: 1.25; */ /* padding: 10mm 10mm 10mm 10mm !important; */ } + @page { - size: auto; /* auto is the initial value */ - - /* this affects the margin in the printer settings */ - margin: 25mm 25mm 25mm 25mm; - color: tomato; + margin: 50px; } -/* Unknown whether the below actually gets embedded */ -/* @media print { - @page { - size: Letter; - margin: 0; - } - html, - body { - width: 210mm; - - height: 282mm; - font-size: 11px; - background: #fff; - overflow: visible; - } - body { - padding-top: 15mm; - } -} */ - table.imex-table { border: 1px solid #ccc; border-collapse: collapse; @@ -38,27 +15,44 @@ table.imex-table { padding: 0; width: 100%; table-layout: fixed; + font-size: inherit; + + page-break-inside: auto; } table.imex-table caption { - font-size: 1.5em; + /* font-size: 1.5em; */ margin: 0.5em 0 0.75em; + font-size: inherit; } table.imex-table tr { - background-color: #f8f8f8; + /* background-color: #f8f8f8; */ border: 1px solid #ddd; - padding: 0.1rem; + padding: 0.2rem; + font-size: inherit; + + page-break-inside: avoid; + page-break-after: auto; } table.imex-table th, table.imex-table td { padding: 0.3rem; text-align: center; + font-size: inherit; +} +table.imex-table th.left, +table.imex-table td.left { + padding: 0.3rem; + text-align: left; + font-size: inherit; } table.imex-table th { - font-size: 0.85em; + /* font-size: 0.85em; */ letter-spacing: 0.1em; text-transform: uppercase; + + /* display: table-header-group; */ } diff --git a/client/src/components/_test/paymentMethod.jsx b/client/src/components/_test/paymentMethod.jsx index e32ebc2c9..af5c38d1c 100644 --- a/client/src/components/_test/paymentMethod.jsx +++ b/client/src/components/_test/paymentMethod.jsx @@ -1,6 +1,6 @@ import { PaymentRequestButtonElement, - useStripe + useStripe, } from "@stripe/react-stripe-js"; import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; @@ -72,7 +72,7 @@ function Test({ bodyshop, setEmailOptions }) { replyTo: bodyshop.email, }, template: { - name: TemplateList.parts_order_confirmation.key, + name: TemplateList().parts_order_confirmation.key, variables: { id: "a7c2d4e1-f519-42a9-a071-c48cf0f22979", }, diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx index 6cecc1ff2..436f9fa66 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx @@ -89,7 +89,7 @@ export function JobsDetailHeaderCsi({ replyTo: bodyshop.email, }, template: { - name: TemplateList.csi_invitation.key, + name: TemplateList().csi_invitation.key, variables: { id: result.data.insert_csi.returning[0].id, }, @@ -108,14 +108,16 @@ export function JobsDetailHeaderCsi({ + key="email" + disabled={!!!job.ownr_ea} + > {t("general.labels.email")} + key="text" + disabled={!!!job.ownr_ph1} + > {t("general.labels.text")} diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index b115a1779..c372734a9 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -154,8 +154,8 @@ export function PartsOrderModalContainer({ }, template: { name: isReturn - ? TemplateList.parts_return_confirmation.key - : TemplateList.parts_order_confirmation.key, + ? TemplateList().parts_return_confirmation.key + : TemplateList().parts_order_confirmation.key, variables: { id: insertResult.data.insert_parts_orders.returning[0].id, }, @@ -166,8 +166,8 @@ export function PartsOrderModalContainer({ await RenderTemplate( { name: isReturn - ? TemplateList.parts_return_confirmation.key - : TemplateList.parts_order_confirmation.key, + ? TemplateList().parts_return_confirmation.key + : TemplateList().parts_order_confirmation.key, variables: { id: insertResult.data.insert_parts_orders.returning[0].id, }, diff --git a/client/src/components/payment-modal/payment-modal.container.jsx b/client/src/components/payment-modal/payment-modal.container.jsx index b24da0534..e380b3098 100644 --- a/client/src/components/payment-modal/payment-modal.container.jsx +++ b/client/src/components/payment-modal/payment-modal.container.jsx @@ -123,7 +123,7 @@ function InvoiceEnterModalContainer({ replyTo: bodyshop.email, }, template: { - name: TemplateList.payment_receipt.key, + name: TemplateList().payment_receipt.key, variables: { id: newPayment.data.insert_payments.returning[0].id, }, @@ -133,7 +133,7 @@ function InvoiceEnterModalContainer({ displayTemplateInWindow( await RenderTemplate( { - name: TemplateList.payment_receipt.key, + name: TemplateList().payment_receipt.key, variables: { id: newPayment.data.insert_payments.returning[0].id, }, diff --git a/client/src/components/print-center-jobs/print-center-jobs.component.jsx b/client/src/components/print-center-jobs/print-center-jobs.component.jsx index e2ff632be..9a94f5492 100644 --- a/client/src/components/print-center-jobs/print-center-jobs.component.jsx +++ b/client/src/components/print-center-jobs/print-center-jobs.component.jsx @@ -11,7 +11,8 @@ import { } from "../../redux/user/user.selectors"; import PrintCenterItem from "../print-center-item/print-center-item.component"; import PrintCenterSpeedPrint from "../print-center-speed-print/print-center-speed-print.component"; -import JobsReports from "./print-center-jobs.list"; +import { TemplateList } from "../../utils/TemplateConstants"; +import { useTranslation } from "react-i18next"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -27,8 +28,13 @@ const mapDispatchToProps = (dispatch) => ({ const colSpan = { md: { span: 24 }, lg: { span: 12 } }; export function PrintCenterJobsComponent({ bodyshop, printCenterModal }) { + const { t } = useTranslation(); const { id: jobId } = printCenterModal.context; - const JobsReportsList = JobsReports(null); + const tempList = TemplateList(); + const JobsReportsList = Object.keys(tempList).map((key) => { + return tempList[key]; + }); + console.log("PrintCenterJobsComponent -> JobsReportsList", JobsReportsList); return (
@@ -38,20 +44,20 @@ export function PrintCenterJobsComponent({ bodyshop, printCenterModal }) { - {JobsReportsList.map((section) => ( - -
    - {section.items.map((item) => ( + +
      + {JobsReportsList.filter((t) => t.drivingId === "job").map( + (item) => ( - ))} -
    -
    - ))} + ) + )}{" "} +
{" "} +
diff --git a/client/src/components/print-center-jobs/print-center-jobs.list.js b/client/src/components/print-center-jobs/print-center-jobs.list.js deleted file mode 100644 index afbb0d0f4..000000000 --- a/client/src/components/print-center-jobs/print-center-jobs.list.js +++ /dev/null @@ -1,60 +0,0 @@ -import i18n from "i18next"; - -export default function JobsReports(job) { - return [ - { - title: i18n.t("printcenter.labels.repairorder"), - key: "printcenter.jobs.repairorder", - disabled: false, - items: [ - { - key: "appointment_reminder", - title: i18n.t("printcenter.jobs.appointment_reminder"), - disabled: false, - }, - { - key: "estimate_detail", - title: i18n.t("printcenter.jobs.estimate_detail"), - disabled: false, - }, - { - key: "job_totals", - title: i18n.t("printcenter.jobs.job_totals"), - disabled: false, - }, - { - key: "work_authorization", - title: i18n.t("printcenter.jobs.work_authorization"), - disabled: false, - }, - { - key: "fippa_work_authorization", - title: i18n.t("printcenter.jobs.fippa_work_authorization"), - disabled: false, - }, - { - key: "casl_work_authorization", - title: i18n.t("printcenter.jobs.casl_work_authorization"), - disabled: false, - }, - { - key: "coversheet", - title: i18n.t("printcenter.jobs.coversheet"), - disabled: false, - }, - ], - }, - { - title: i18n.t("printcenter.labels.misc"), - key: "printcenter.jobs.misc", - disabled: false, - items: [ - { - key: "iou", - title: i18n.t("printcenter.jobs.iou"), - disabled: true, - }, - ], - }, - ]; -} diff --git a/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx b/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx index 57542ef25..512f78b93 100644 --- a/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx +++ b/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx @@ -70,8 +70,8 @@ export function PrintCenterSpeedPrint({ bodyshop, jobId }) { const renderTemplateList = (templates) => ( {templates.map((template, idx) => { - if (idx === templates.length - 1) return TemplateList[template].title; - return `${TemplateList[template].title}, `; + if (idx === templates.length - 1) return TemplateList()[template].title; + return `${TemplateList()[template].title}, `; })} ); diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx index 444deb379..ac7557689 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx @@ -140,7 +140,7 @@ export function ScheduleJobModalContainer({ replyTo: bodyshop.email, }, template: { - name: TemplateList.appointment_confirmation.key, + name: TemplateList().appointment_confirmation.key, variables: { id: appt.data.insert_appointments.returning[0].id, }, diff --git a/client/src/components/shop-info/shop-info.intake.component.jsx b/client/src/components/shop-info/shop-info.intake.component.jsx index 3a555f832..da4124ea8 100644 --- a/client/src/components/shop-info/shop-info.intake.component.jsx +++ b/client/src/components/shop-info/shop-info.intake.component.jsx @@ -130,10 +130,10 @@ export default function ShopInfoIntakeChecklistComponent({ form }) { @@ -252,10 +252,10 @@ export default function ShopInfoIntakeChecklistComponent({ form }) { diff --git a/client/src/components/shop-info/shop-info.speedprint.component.jsx b/client/src/components/shop-info/shop-info.speedprint.component.jsx index 60be40a70..a983a0c75 100644 --- a/client/src/components/shop-info/shop-info.speedprint.component.jsx +++ b/client/src/components/shop-info/shop-info.speedprint.component.jsx @@ -60,8 +60,8 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) { ]} >