From 79982a6c3f1b41c2c93dbf43b5020f894a94539c Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 19 Jan 2021 09:53:28 -0800 Subject: [PATCH] Added duplicate without repair data IO-580 --- bodyshop_translations.babel | 21 ++++++ .../jobs-detail-header-actions.component.jsx | 66 +++++++++++++------ ...bs-detail-header-actions.duplicate.util.js | 30 +++++---- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 6 files changed, 85 insertions(+), 35 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index f0a48e614..41bcf1745 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -19870,6 +19870,27 @@ + + duplicatenolines + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + newcccontract false diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index c90794005..a5bfc9038 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -145,28 +145,52 @@ export function JobsDetailHeaderActions({ {t("jobs.actions.addtoproduction")} )} + + + e.stopPropagation()} + onConfirm={() => + DuplicateJob( + client, + job.id, + { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported }, + (newJobId) => { + history.push(`/manage/jobs/${newJobId}`); + }, + true + ) + } + getPopupContainer={(trigger) => trigger.parentNode} + > + {t("menus.jobsactions.duplicate")} + + + + e.stopPropagation()} + onConfirm={() => + DuplicateJob( + client, + job.id, + { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported }, + (newJobId) => { + history.push(`/manage/jobs/${newJobId}`); + } + ) + } + getPopupContainer={(trigger) => trigger.parentNode} + > + {t("menus.jobsactions.duplicatenolines")} + + + - - e.stopPropagation()} - onConfirm={() => - DuplicateJob( - client, - job.id, - { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported }, - (newJobId) => { - history.push(`/manage/jobs/${newJobId}`); - } - ) - } - getPopupContainer={(trigger) => trigger.parentNode} - > - {t("menus.jobsactions.duplicate")} - - { const { jobs_by_pk: existingJob } = res.data; - delete existingJob.__typename; - delete existingJob.id; - existingJob.date_estimated = new Date(); - existingJob.status = defaultOpenStatus; + const newJob = _.cloneDeep(existingJob); + delete newJob.__typename; + delete newJob.id; + newJob.date_estimated = new Date(); + newJob.status = defaultOpenStatus; - const _tempLines = existingJob.joblines; + const _tempLines = newJob.joblines; _tempLines.forEach((line) => { delete line.id; delete line.__typename; }); - delete existingJob.joblines; - existingJob.joblines = { data: _tempLines }; + delete newJob.joblines; + newJob.joblines = keepJobLines ? { data: _tempLines } : null; apolloClient .mutate({ mutation: INSERT_NEW_JOB, - variables: { job: [existingJob] }, + variables: { job: [newJob] }, }) .then((res2) => { if (completionCallback) diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 3eaa7005e..348e63ac5 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1199,6 +1199,7 @@ "admin": "Admin", "closejob": "Close Job", "duplicate": "Duplicate this Job", + "duplicatenolines": "Duplicate this Job without Repair Data", "newcccontract": "Create Courtesy Car Contract" }, "jobsdetail": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 30326ac58..fd2d638f1 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1199,6 +1199,7 @@ "admin": "", "closejob": "", "duplicate": "", + "duplicatenolines": "", "newcccontract": "" }, "jobsdetail": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index cc8bad61c..b0b7e0f23 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1199,6 +1199,7 @@ "admin": "", "closejob": "", "duplicate": "", + "duplicatenolines": "", "newcccontract": "" }, "jobsdetail": {