Added duplicate without repair data IO-580
This commit is contained in:
@@ -19870,6 +19870,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>duplicatenolines</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>newcccontract</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -145,28 +145,52 @@ export function JobsDetailHeaderActions({
|
||||
{t("jobs.actions.addtoproduction")}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.SubMenu title={t("menus.jobsactions.duplicate")}>
|
||||
<Menu.Item>
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.duplicateconfirm")}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
onClick={(e) => 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")}
|
||||
</Popconfirm>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.duplicateconfirm")}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
onClick={(e) => 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")}
|
||||
</Popconfirm>
|
||||
</Menu.Item>
|
||||
</Menu.SubMenu>
|
||||
|
||||
<Menu.Item key="duplicatejob">
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.duplicateconfirm")}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
onClick={(e) => 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")}
|
||||
</Popconfirm>
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
key="postbills"
|
||||
disabled={jobRO}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import {
|
||||
QUERY_ALL_JOB_FIELDS,
|
||||
INSERT_NEW_JOB,
|
||||
} from "../../graphql/jobs.queries";
|
||||
import _ from "lodash";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
|
||||
import {
|
||||
INSERT_NEW_JOB,
|
||||
QUERY_ALL_JOB_FIELDS,
|
||||
} from "../../graphql/jobs.queries";
|
||||
export default function DuplicateJob(
|
||||
apolloClient,
|
||||
jobId,
|
||||
config,
|
||||
completionCallback
|
||||
completionCallback,
|
||||
keepJobLines = false
|
||||
) {
|
||||
logImEXEvent("job_duplicate");
|
||||
|
||||
@@ -18,25 +19,26 @@ export default function DuplicateJob(
|
||||
.query({ query: QUERY_ALL_JOB_FIELDS, variables: { id: jobId } })
|
||||
.then((res) => {
|
||||
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)
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -1199,6 +1199,7 @@
|
||||
"admin": "",
|
||||
"closejob": "",
|
||||
"duplicate": "",
|
||||
"duplicatenolines": "",
|
||||
"newcccontract": ""
|
||||
},
|
||||
"jobsdetail": {
|
||||
|
||||
@@ -1199,6 +1199,7 @@
|
||||
"admin": "",
|
||||
"closejob": "",
|
||||
"duplicate": "",
|
||||
"duplicatenolines": "",
|
||||
"newcccontract": ""
|
||||
},
|
||||
"jobsdetail": {
|
||||
|
||||
Reference in New Issue
Block a user