Delete non-converted job IO-589
This commit is contained in:
@@ -17399,6 +17399,27 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<concept_node>
|
||||
<name>deleteconfirm</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>difference</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -18753,6 +18774,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>delete</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>deleted</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -19849,6 +19891,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>deletejob</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>duplicate</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { DownCircleFilled } from "@ant-design/icons";
|
||||
import { useApolloClient } from "@apollo/react-hooks";
|
||||
import { Button, Dropdown, Menu, Popconfirm } from "antd";
|
||||
import { useApolloClient, useMutation } from "@apollo/react-hooks";
|
||||
import { Button, Dropdown, Menu, notification, Popconfirm } from "antd";
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link, useHistory } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { DELETE_JOB } from "../../graphql/jobs.queries";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
|
||||
import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component";
|
||||
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
jobRO: selectJobReadOnly,
|
||||
@@ -43,7 +43,7 @@ export function JobsDetailHeaderActions({
|
||||
const { t } = useTranslation();
|
||||
const client = useApolloClient();
|
||||
const history = useHistory();
|
||||
|
||||
const [deleteJob] = useMutation(DELETE_JOB);
|
||||
const jobInProduction = useMemo(() => {
|
||||
return bodyshop.md_ro_statuses.production_statuses.includes(job.status);
|
||||
}, [job, bodyshop.md_ro_statuses.production_statuses]);
|
||||
@@ -252,6 +252,37 @@ export function JobsDetailHeaderActions({
|
||||
>
|
||||
{t("jobs.labels.jobcosting")}
|
||||
</Menu.Item>
|
||||
{job && !job.converted && (
|
||||
<Menu.Item>
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.deleteconfirm")}
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onConfirm={async () => {
|
||||
//delete the job.
|
||||
const result = await deleteJob({ variables: { id: job.id } });
|
||||
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.delete"),
|
||||
});
|
||||
//go back to jobs list.
|
||||
history.push(`/manage/`);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.deleted", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}}
|
||||
getPopupContainer={(trigger) => trigger.parentNode}
|
||||
>
|
||||
{t("menus.jobsactions.deletejob")}
|
||||
</Popconfirm>
|
||||
</Menu.Item>
|
||||
)}
|
||||
</Menu>
|
||||
);
|
||||
return (
|
||||
|
||||
@@ -1320,3 +1320,11 @@ export const QUERY_JOB_LBR_ADJUSTMENTS = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_JOB = gql`
|
||||
mutation DELETE_JOB($id: uuid!) {
|
||||
delete_jobs_by_pk(id: $id) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1069,6 +1069,7 @@
|
||||
"waived": "Waived",
|
||||
"yes": "Yes"
|
||||
},
|
||||
"deleteconfirm": "Are you sure you want to delete this job? This cannot be undone. ",
|
||||
"difference": "Difference",
|
||||
"documents": "Documents",
|
||||
"documents-images": "Images",
|
||||
@@ -1137,6 +1138,7 @@
|
||||
"created": "Job created successfully. Click to view.",
|
||||
"created_subtitle": "Estimate Number {{est_number}} has been created.",
|
||||
"creatednoclick": "Job created successfully. ",
|
||||
"delete": "Job deleted successfully.",
|
||||
"deleted": "Job deleted successfully.",
|
||||
"exported": "Job exported successfully. ",
|
||||
"invoiced": "Job closed and invoiced successfully.",
|
||||
@@ -1198,6 +1200,7 @@
|
||||
"jobsactions": {
|
||||
"admin": "Admin",
|
||||
"closejob": "Close Job",
|
||||
"deletejob": "Delete Job",
|
||||
"duplicate": "Duplicate this Job",
|
||||
"duplicatenolines": "Duplicate this Job without Repair Data",
|
||||
"newcccontract": "Create Courtesy Car Contract"
|
||||
|
||||
@@ -1069,6 +1069,7 @@
|
||||
"waived": "",
|
||||
"yes": ""
|
||||
},
|
||||
"deleteconfirm": "",
|
||||
"difference": "",
|
||||
"documents": "documentos",
|
||||
"documents-images": "",
|
||||
@@ -1137,6 +1138,7 @@
|
||||
"created": "Trabajo creado con éxito. Click para ver.",
|
||||
"created_subtitle": "",
|
||||
"creatednoclick": "",
|
||||
"delete": "",
|
||||
"deleted": "Trabajo eliminado con éxito.",
|
||||
"exported": "",
|
||||
"invoiced": "",
|
||||
@@ -1198,6 +1200,7 @@
|
||||
"jobsactions": {
|
||||
"admin": "",
|
||||
"closejob": "",
|
||||
"deletejob": "",
|
||||
"duplicate": "",
|
||||
"duplicatenolines": "",
|
||||
"newcccontract": ""
|
||||
|
||||
@@ -1069,6 +1069,7 @@
|
||||
"waived": "",
|
||||
"yes": ""
|
||||
},
|
||||
"deleteconfirm": "",
|
||||
"difference": "",
|
||||
"documents": "Les documents",
|
||||
"documents-images": "",
|
||||
@@ -1137,6 +1138,7 @@
|
||||
"created": "Le travail a été créé avec succès. Clique pour voir.",
|
||||
"created_subtitle": "",
|
||||
"creatednoclick": "",
|
||||
"delete": "",
|
||||
"deleted": "Le travail a bien été supprimé.",
|
||||
"exported": "",
|
||||
"invoiced": "",
|
||||
@@ -1198,6 +1200,7 @@
|
||||
"jobsactions": {
|
||||
"admin": "",
|
||||
"closejob": "",
|
||||
"deletejob": "",
|
||||
"duplicate": "",
|
||||
"duplicatenolines": "",
|
||||
"newcccontract": ""
|
||||
|
||||
Reference in New Issue
Block a user