Added manual job stage transitions IO-427
This commit is contained in:
@@ -12813,6 +12813,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>removefromproduction</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>schedule</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -112,6 +112,10 @@ export function JobChecklistForm({
|
||||
scheduled_completion: job && job.scheduled_completion,
|
||||
scheduled_delivery: job && job.scheduled_delivery,
|
||||
}),
|
||||
...(type === "deliver" && {
|
||||
removeFromProduction: true,
|
||||
actual_completion: job && job.actual_completion,
|
||||
}),
|
||||
}}
|
||||
>
|
||||
{t("checklist.labels.checklist")}
|
||||
|
||||
@@ -21,6 +21,7 @@ export function JobsChangeStatus({ job, bodyshop, jobRO }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [availableStatuses, setAvailableStatuses] = useState([]);
|
||||
const [otherStages, setOtherStages] = useState([]);
|
||||
const [mutationUpdateJobstatus] = useMutation(UPDATE_JOB_STATUS);
|
||||
const updateJobStatus = (status) => {
|
||||
mutationUpdateJobstatus({
|
||||
@@ -34,26 +35,41 @@ export function JobsChangeStatus({ job, bodyshop, jobRO }) {
|
||||
notification["error"]({ message: t("jobs.errors.saving") });
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
//Figure out what scenario were in, populate accodingly
|
||||
if (job && bodyshop) {
|
||||
if (bodyshop.md_ro_statuses.pre_production_statuses.includes(job.status))
|
||||
if (
|
||||
bodyshop.md_ro_statuses.pre_production_statuses.includes(job.status)
|
||||
) {
|
||||
setAvailableStatuses(bodyshop.md_ro_statuses.pre_production_statuses);
|
||||
else if (bodyshop.md_ro_statuses.production_statuses.includes(job.status))
|
||||
if (bodyshop.md_ro_statuses.production_statuses[0])
|
||||
setOtherStages([bodyshop.md_ro_statuses.production_statuses[0]]);
|
||||
} else if (
|
||||
bodyshop.md_ro_statuses.production_statuses.includes(job.status)
|
||||
) {
|
||||
setAvailableStatuses(bodyshop.md_ro_statuses.production_statuses);
|
||||
else if (
|
||||
setOtherStages([
|
||||
bodyshop.md_ro_statuses.default_imported,
|
||||
bodyshop.md_ro_statuses.default_delivered,
|
||||
]);
|
||||
} else if (
|
||||
bodyshop.md_ro_statuses.post_production_statuses.includes(job.status)
|
||||
)
|
||||
) {
|
||||
setAvailableStatuses(bodyshop.md_ro_statuses.post_production_statuses);
|
||||
else {
|
||||
if (bodyshop.md_ro_statuses.production_statuses[0])
|
||||
setOtherStages([bodyshop.md_ro_statuses.production_statuses[0]]);
|
||||
} else {
|
||||
console.log(
|
||||
"Status didn't match any restrictions. Allowing all status changes."
|
||||
);
|
||||
setAvailableStatuses(bodyshop.statuses);
|
||||
setAvailableStatuses(bodyshop.md_ro_statuses.statuses);
|
||||
}
|
||||
}
|
||||
}, [job, setAvailableStatuses, bodyshop]);
|
||||
|
||||
console.log("availableStatuses", availableStatuses);
|
||||
console.log("otherStages", otherStages);
|
||||
const statusmenu = (
|
||||
<Menu
|
||||
onClick={(e) => {
|
||||
@@ -63,6 +79,10 @@ export function JobsChangeStatus({ job, bodyshop, jobRO }) {
|
||||
{availableStatuses.map((item) => (
|
||||
<Menu.Item key={item}>{item}</Menu.Item>
|
||||
))}
|
||||
<Menu.Divider />
|
||||
{otherStages.map((item, idx) => (
|
||||
<Menu.Item key={item}>{item}</Menu.Item>
|
||||
))}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
export default function AddToProduction(
|
||||
apolloClient,
|
||||
jobId,
|
||||
completionCallback
|
||||
completionCallback,
|
||||
remove = false
|
||||
) {
|
||||
logImEXEvent("job_add_to_production");
|
||||
|
||||
@@ -14,17 +15,17 @@ export default function AddToProduction(
|
||||
apolloClient
|
||||
.mutate({
|
||||
mutation: UPDATE_JOB,
|
||||
variables: { jobId: jobId, job: { inproduction: true } },
|
||||
variables: { jobId: jobId, job: { inproduction: !remove } },
|
||||
})
|
||||
.then((res) => {
|
||||
notification["success"]({
|
||||
message: i18n.t("jobs.successes.addedtoproduction"),
|
||||
message: i18n.t("jobs.successes.save"),
|
||||
});
|
||||
if (completionCallback) completionCallback();
|
||||
})
|
||||
.catch((error) => {
|
||||
notification["errors"]({
|
||||
message: i18n.t("jobs.errors.addingtoproduction", {
|
||||
message: i18n.t("jobs.errors.saving", {
|
||||
error: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -128,13 +128,24 @@ export function JobsDetailHeaderActions({
|
||||
{t("menus.jobsactions.newcccontract")}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
key="addtoproduction"
|
||||
disabled={!!!job.converted || !!job.inproduction || jobRO}
|
||||
onClick={() => AddToProduction(client, job.id, refetch)}
|
||||
>
|
||||
{t("jobs.actions.addtoproduction")}
|
||||
</Menu.Item>
|
||||
{job.inproduction ? (
|
||||
<Menu.Item
|
||||
key="addtoproduction"
|
||||
disabled={!!!job.converted || jobRO}
|
||||
onClick={() => AddToProduction(client, job.id, refetch, true)}
|
||||
>
|
||||
{t("jobs.actions.removefromproduction")}
|
||||
</Menu.Item>
|
||||
) : (
|
||||
<Menu.Item
|
||||
key="addtoproduction"
|
||||
disabled={!!!job.converted || !!job.inproduction || jobRO}
|
||||
onClick={() => AddToProduction(client, job.id, refetch)}
|
||||
>
|
||||
{t("jobs.actions.addtoproduction")}
|
||||
</Menu.Item>
|
||||
)}
|
||||
|
||||
<Menu.Item key="duplicatejob">
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.duplicateconfirm")}
|
||||
|
||||
@@ -833,6 +833,7 @@
|
||||
"printCenter": "Print Center",
|
||||
"recalculate": "Recalculate",
|
||||
"reconcile": "Reconcile",
|
||||
"removefromproduction": "Remove from Production",
|
||||
"schedule": "Schedule",
|
||||
"sendcsi": "Send CSI",
|
||||
"viewdetail": "View Details"
|
||||
|
||||
@@ -833,6 +833,7 @@
|
||||
"printCenter": "Centro de impresión",
|
||||
"recalculate": "",
|
||||
"reconcile": "",
|
||||
"removefromproduction": "",
|
||||
"schedule": "Programar",
|
||||
"sendcsi": "",
|
||||
"viewdetail": ""
|
||||
|
||||
@@ -833,6 +833,7 @@
|
||||
"printCenter": "Centre d'impression",
|
||||
"recalculate": "",
|
||||
"reconcile": "",
|
||||
"removefromproduction": "",
|
||||
"schedule": "Programme",
|
||||
"sendcsi": "",
|
||||
"viewdetail": ""
|
||||
|
||||
Reference in New Issue
Block a user