IO-744 Voiding Note
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project be_version="2.7.1" version="1.2">
|
<babeledit_project version="1.2" be_version="2.7.1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -20710,6 +20710,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>voidnote</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>
|
||||||
</children>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
<folder_node>
|
<folder_node>
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
import { DownCircleFilled } from "@ant-design/icons";
|
import { DownCircleFilled } from "@ant-design/icons";
|
||||||
import { useApolloClient, useMutation } from "@apollo/client";
|
import { useApolloClient, useMutation } from "@apollo/client";
|
||||||
import { Button, Dropdown, Menu, notification, Popconfirm } from "antd";
|
import { Button, Dropdown, Menu, notification, Popconfirm } from "antd";
|
||||||
|
import moment from "moment";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link, useHistory } from "react-router-dom";
|
import { Link, useHistory } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { DELETE_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { DELETE_JOB, UPDATE_JOB, VOID_JOB } from "../../graphql/jobs.queries";
|
||||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import {
|
||||||
|
selectBodyshop,
|
||||||
|
selectCurrentUser,
|
||||||
|
} from "../../redux/user/user.selectors";
|
||||||
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
|
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
|
||||||
import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component";
|
import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component";
|
||||||
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
|
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
jobRO: selectJobReadOnly,
|
jobRO: selectJobReadOnly,
|
||||||
|
currentUser: selectCurrentUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -35,6 +41,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function JobsDetailHeaderActions({
|
export function JobsDetailHeaderActions({
|
||||||
job,
|
job,
|
||||||
bodyshop,
|
bodyshop,
|
||||||
|
currentUser,
|
||||||
refetch,
|
refetch,
|
||||||
setScheduleContext,
|
setScheduleContext,
|
||||||
setBillEnterContext,
|
setBillEnterContext,
|
||||||
@@ -48,6 +55,7 @@ export function JobsDetailHeaderActions({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [deleteJob] = useMutation(DELETE_JOB);
|
const [deleteJob] = useMutation(DELETE_JOB);
|
||||||
const [updateJob] = useMutation(UPDATE_JOB);
|
const [updateJob] = useMutation(UPDATE_JOB);
|
||||||
|
const [voidJob] = useMutation(VOID_JOB);
|
||||||
const jobInProduction = useMemo(() => {
|
const jobInProduction = useMemo(() => {
|
||||||
return bodyshop.md_ro_statuses.production_statuses.includes(job.status);
|
return bodyshop.md_ro_statuses.production_statuses.includes(job.status);
|
||||||
}, [job, bodyshop.md_ro_statuses.production_statuses]);
|
}, [job, bodyshop.md_ro_statuses.production_statuses]);
|
||||||
@@ -338,13 +346,24 @@ export function JobsDetailHeaderActions({
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
//delete the job.
|
//delete the job.
|
||||||
const result = await updateJob({
|
const result = await voidJob({
|
||||||
variables: {
|
variables: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
job: {
|
job: {
|
||||||
status: bodyshop.md_ro_statuses.default_void,
|
status: bodyshop.md_ro_statuses.default_void,
|
||||||
voided: true,
|
voided: true,
|
||||||
},
|
},
|
||||||
|
note: [
|
||||||
|
{
|
||||||
|
jobid: job.id,
|
||||||
|
created_by: currentUser.email,
|
||||||
|
audit: true,
|
||||||
|
text: t("jobs.labels.voidnote", {
|
||||||
|
date: moment().format("MM/DD/yyy"),
|
||||||
|
time: moment().format("hh:mm a"),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,23 @@ import { Button, Table } from "antd";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import NoteUpsertModal from "../note-upsert-modal/note-upsert-modal.container";
|
import NoteUpsertModal from "../note-upsert-modal/note-upsert-modal.container";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
jobRO: selectJobReadOnly,
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setNoteUpsertContext: (context) =>
|
setNoteUpsertContext: (context) =>
|
||||||
dispatch(setModalContext({ context: context, modal: "noteUpsert" })),
|
dispatch(setModalContext({ context: context, modal: "noteUpsert" })),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function JobNotesComponent({
|
export function JobNotesComponent({
|
||||||
|
jobRO,
|
||||||
loading,
|
loading,
|
||||||
data,
|
data,
|
||||||
refetch,
|
refetch,
|
||||||
@@ -78,13 +85,13 @@ export function JobNotesComponent({
|
|||||||
<span>
|
<span>
|
||||||
<Button
|
<Button
|
||||||
loading={deleteLoading}
|
loading={deleteLoading}
|
||||||
disabled={record.audit}
|
disabled={record.audit || jobRO}
|
||||||
onClick={() => handleNoteDelete(record.id)}
|
onClick={() => handleNoteDelete(record.id)}
|
||||||
>
|
>
|
||||||
<DeleteFilled />
|
<DeleteFilled />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
disabled={record.audit}
|
disabled={record.audit || jobRO}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setNoteUpsertContext({
|
setNoteUpsertContext({
|
||||||
actions: { refetch: refetch },
|
actions: { refetch: refetch },
|
||||||
|
|||||||
@@ -756,6 +756,27 @@ export const UPDATE_JOB = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const VOID_JOB = gql`
|
||||||
|
mutation VOID_JOB(
|
||||||
|
$jobId: uuid!
|
||||||
|
$job: jobs_set_input!
|
||||||
|
$note: [notes_insert_input!]!
|
||||||
|
) {
|
||||||
|
update_jobs_by_pk(_set: $job, pk_columns: { id: $jobId }) {
|
||||||
|
id
|
||||||
|
date_exported
|
||||||
|
status
|
||||||
|
alt_transport
|
||||||
|
ro_number
|
||||||
|
production_vars
|
||||||
|
lbr_adjustments
|
||||||
|
}
|
||||||
|
insert_notes(objects: $note) {
|
||||||
|
affected_rows
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const UPDATE_JOBS = gql`
|
export const UPDATE_JOBS = gql`
|
||||||
mutation UPDATE_JOBS($jobIds: [uuid!]!, $fields: jobs_set_input!) {
|
mutation UPDATE_JOBS($jobIds: [uuid!]!, $fields: jobs_set_input!) {
|
||||||
update_jobs(where: { id: { _in: $jobIds } }, _set: $fields) {
|
update_jobs(where: { id: { _in: $jobIds } }, _set: $fields) {
|
||||||
|
|||||||
@@ -1238,7 +1238,8 @@
|
|||||||
"vehicle_info": "Vehicle",
|
"vehicle_info": "Vehicle",
|
||||||
"vehicleassociation": "Vehicle Association",
|
"vehicleassociation": "Vehicle Association",
|
||||||
"viewallocations": "View Allocations",
|
"viewallocations": "View Allocations",
|
||||||
"voidjob": "Are you sure you want to void this job? This cannot be easily undone. "
|
"voidjob": "Are you sure you want to void this job? This cannot be easily undone. ",
|
||||||
|
"voidnote": "This repair order was voided on {{date}} at {{time}}."
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"addedtoproduction": "Job added to production board.",
|
"addedtoproduction": "Job added to production board.",
|
||||||
|
|||||||
@@ -1238,7 +1238,8 @@
|
|||||||
"vehicle_info": "Vehículo",
|
"vehicle_info": "Vehículo",
|
||||||
"vehicleassociation": "",
|
"vehicleassociation": "",
|
||||||
"viewallocations": "",
|
"viewallocations": "",
|
||||||
"voidjob": ""
|
"voidjob": "",
|
||||||
|
"voidnote": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"addedtoproduction": "",
|
"addedtoproduction": "",
|
||||||
|
|||||||
@@ -1238,7 +1238,8 @@
|
|||||||
"vehicle_info": "Véhicule",
|
"vehicle_info": "Véhicule",
|
||||||
"vehicleassociation": "",
|
"vehicleassociation": "",
|
||||||
"viewallocations": "",
|
"viewallocations": "",
|
||||||
"voidjob": ""
|
"voidjob": "",
|
||||||
|
"voidnote": ""
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"addedtoproduction": "",
|
"addedtoproduction": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user