feature/IO-3487-Auto-Add-Profile-Watchers - Fix Auto Add on a profile level
This commit is contained in:
@@ -253,6 +253,10 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract, disabled
|
||||
}
|
||||
};
|
||||
|
||||
if (currentUser?.email) {
|
||||
newJob.created_user_email = currentUser.email;
|
||||
}
|
||||
|
||||
//Calcualte the new job totals.
|
||||
|
||||
const newTotals = (
|
||||
|
||||
@@ -43,16 +43,18 @@ export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines, tec
|
||||
const handleCreateIou = async () => {
|
||||
setLoading(true);
|
||||
//Query all of the job details to recreate.
|
||||
const iouId = await CreateIouForJob(
|
||||
client,
|
||||
job.id,
|
||||
{
|
||||
const iouId = await CreateIouForJob({
|
||||
apolloClient: client,
|
||||
jobLinesToKeep: selectedJobLines,
|
||||
jobId: job.id,
|
||||
config: {
|
||||
status: bodyshop.md_ro_statuses.default_open,
|
||||
bodyshopid: bodyshop.id,
|
||||
useremail: currentUser.email
|
||||
},
|
||||
selectedJobLines
|
||||
);
|
||||
currentUser
|
||||
});
|
||||
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("jobs.successes.ioucreated"),
|
||||
|
||||
@@ -154,6 +154,10 @@ export function JobsAvailableContainer({ bodyshop, currentUser, insertAuditTrail
|
||||
: {})
|
||||
};
|
||||
|
||||
if (currentUser?.email) {
|
||||
newJob.created_user_email = currentUser.email;
|
||||
}
|
||||
|
||||
if (selectedOwner) {
|
||||
newJob.ownerid = selectedOwner;
|
||||
delete newJob.owner;
|
||||
|
||||
@@ -175,25 +175,33 @@ export function JobsDetailHeaderActions({
|
||||
};
|
||||
|
||||
const handleDuplicate = () =>
|
||||
DuplicateJob(
|
||||
client,
|
||||
job.id,
|
||||
{ defaultOpenStatus: bodyshop.md_ro_statuses.default_imported },
|
||||
(newJobId) => {
|
||||
DuplicateJob({
|
||||
apolloClient: client,
|
||||
jobId: job.id,
|
||||
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported },
|
||||
completionCallback: (newJobId) => {
|
||||
history(`/manage/jobs/${newJobId}`);
|
||||
notification.success({
|
||||
message: t("jobs.successes.duplicated")
|
||||
});
|
||||
},
|
||||
true
|
||||
);
|
||||
keepJobLines: true,
|
||||
currentUser
|
||||
});
|
||||
|
||||
const handleDuplicateConfirm = () =>
|
||||
DuplicateJob(client, job.id, { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported }, (newJobId) => {
|
||||
history(`/manage/jobs/${newJobId}`);
|
||||
notification.success({
|
||||
message: t("jobs.successes.duplicated")
|
||||
});
|
||||
DuplicateJob({
|
||||
apolloClient: client,
|
||||
jobId: job.id,
|
||||
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported },
|
||||
completionCallback: (newJobId) => {
|
||||
history(`/manage/jobs/${newJobId}`);
|
||||
notification.success({
|
||||
message: t("jobs.successes.duplicated")
|
||||
});
|
||||
},
|
||||
keepJobLines: false,
|
||||
currentUser
|
||||
});
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
|
||||
@@ -5,7 +5,14 @@ import { INSERT_NEW_JOB, QUERY_JOB_FOR_DUPE } from "../../graphql/jobs.queries";
|
||||
import dayjs from "../../utils/day";
|
||||
import i18n from "i18next";
|
||||
|
||||
export default async function DuplicateJob(apolloClient, jobId, config, completionCallback, keepJobLines = false) {
|
||||
export default async function DuplicateJob({
|
||||
apolloClient,
|
||||
jobId,
|
||||
config,
|
||||
completionCallback,
|
||||
keepJobLines = false,
|
||||
currentUser
|
||||
}) {
|
||||
logImEXEvent("job_duplicate");
|
||||
|
||||
const { defaultOpenStatus } = config;
|
||||
@@ -19,6 +26,7 @@ export default async function DuplicateJob(apolloClient, jobId, config, completi
|
||||
const existingJob = _.cloneDeep(jobs_by_pk);
|
||||
delete existingJob.__typename;
|
||||
delete existingJob.id;
|
||||
delete existingJob.created_user_email;
|
||||
delete existingJob.createdat;
|
||||
delete existingJob.updatedat;
|
||||
delete existingJob.cieca_stl;
|
||||
@@ -29,6 +37,10 @@ export default async function DuplicateJob(apolloClient, jobId, config, completi
|
||||
status: defaultOpenStatus
|
||||
};
|
||||
|
||||
if (currentUser?.email) {
|
||||
newJob.created_user_email = currentUser.email;
|
||||
}
|
||||
|
||||
const _tempLines = _.cloneDeep(existingJob.joblines);
|
||||
_tempLines.forEach((line) => {
|
||||
delete line.id;
|
||||
@@ -55,7 +67,7 @@ export default async function DuplicateJob(apolloClient, jobId, config, completi
|
||||
return;
|
||||
}
|
||||
|
||||
export async function CreateIouForJob(apolloClient, jobId, config, jobLinesToKeep) {
|
||||
export async function CreateIouForJob({ apolloClient, jobId, config, jobLinesToKeep, currentUser }) {
|
||||
logImEXEvent("job_create_iou");
|
||||
|
||||
const { status } = config;
|
||||
@@ -109,6 +121,9 @@ export async function CreateIouForJob(apolloClient, jobId, config, jobLinesToKee
|
||||
delete newJob.joblines;
|
||||
newJob.joblines = { data: _tempLines };
|
||||
|
||||
if (currentUser?.email) {
|
||||
newJob.created_user_email = currentUser.email;
|
||||
}
|
||||
const res2 = await apolloClient.mutate({
|
||||
mutation: INSERT_NEW_JOB,
|
||||
variables: { job: [newJob] }
|
||||
|
||||
Reference in New Issue
Block a user