IO-1881 Related RO notes.
This commit is contained in:
@@ -31663,6 +31663,27 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>labels</name>
|
<name>labels</name>
|
||||||
<children>
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>addtorelatedro</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>
|
<concept_node>
|
||||||
<name>newnoteplaceholder</name>
|
<name>newnoteplaceholder</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function ChatPresetsComponent({ bodyshop, setMessage, className }) {
|
|||||||
const menu = (
|
const menu = (
|
||||||
<Menu>
|
<Menu>
|
||||||
{bodyshop.md_messaging_presets.map((i, idx) => (
|
{bodyshop.md_messaging_presets.map((i, idx) => (
|
||||||
<Menu.Item onClick={() => setMessage(i.text)} onItemHover key={idx}>
|
<Menu.Item onClick={() => setMessage(i.text)} key={idx}>
|
||||||
{i.label}
|
{i.label}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function JoblinePresetButton({ bodyshop, form }) {
|
|||||||
const menu = (
|
const menu = (
|
||||||
<Menu>
|
<Menu>
|
||||||
{bodyshop.md_jobline_presets.map((i, idx) => (
|
{bodyshop.md_jobline_presets.map((i, idx) => (
|
||||||
<Menu.Item onClick={() => handleSelect(i)} onItemHover key={idx}>
|
<Menu.Item onClick={() => handleSelect(i)} key={idx}>
|
||||||
{i.label}
|
{i.label}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export function JobNotesContainer({ jobId, insertAuditTrail }) {
|
|||||||
jobId={jobId}
|
jobId={jobId}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
data={data ? data.jobs_by_pk.notes : null}
|
data={data ? data.jobs_by_pk.notes : null}
|
||||||
|
relatedRos={data ? data.jobs_by_pk.vehicle.jobs : null}
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
deleteLoading={deleteLoading}
|
deleteLoading={deleteLoading}
|
||||||
handleNoteDelete={handleNoteDelete}
|
handleNoteDelete={handleNoteDelete}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export function JobNotesComponent({
|
|||||||
setNoteUpsertContext,
|
setNoteUpsertContext,
|
||||||
deleteLoading,
|
deleteLoading,
|
||||||
ro_number,
|
ro_number,
|
||||||
|
relatedRos,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const Templates = TemplateList("job_special", {
|
const Templates = TemplateList("job_special", {
|
||||||
@@ -149,6 +150,7 @@ export function JobNotesComponent({
|
|||||||
actions: { refetch: refetch },
|
actions: { refetch: refetch },
|
||||||
context: {
|
context: {
|
||||||
jobId: jobId,
|
jobId: jobId,
|
||||||
|
relatedRos: relatedRos,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,51 +1,92 @@
|
|||||||
import { Col, Form, Input, Row, Switch } from "antd";
|
import { Checkbox, Col, Form, Input, Row, Space, Switch, Tag } 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 { createStructuredSelector } from "reselect";
|
||||||
|
import { selectNoteUpsert } from "../../redux/modals/modals.selectors";
|
||||||
import NotesPresetButton from "../notes-preset-button/notes-preset-button.component";
|
import NotesPresetButton from "../notes-preset-button/notes-preset-button.component";
|
||||||
|
|
||||||
export default function NoteUpsertModalComponent({ form }) {
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
noteUpsertModal: selectNoteUpsert,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
|
});
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(NoteUpsertModalComponent);
|
||||||
|
|
||||||
|
export function NoteUpsertModalComponent({ form, noteUpsertModal }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { jobId, existingNote, relatedRos } = noteUpsertModal.context;
|
||||||
|
|
||||||
|
const filteredRelatedRos = relatedRos
|
||||||
|
? relatedRos.filter((j) => j.id !== jobId)
|
||||||
|
: [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row gutter={[16, 16]}>
|
<>
|
||||||
<Col span={8}>
|
<Row gutter={[16, 16]}>
|
||||||
<Form.Item
|
<Col span={8}>
|
||||||
label={t("notes.fields.critical")}
|
<Form.Item
|
||||||
name="critical"
|
label={t("notes.fields.critical")}
|
||||||
valuePropName="checked"
|
name="critical"
|
||||||
>
|
valuePropName="checked"
|
||||||
<Switch />
|
>
|
||||||
</Form.Item>
|
<Switch />
|
||||||
</Col>
|
</Form.Item>
|
||||||
<Col span={8}>
|
</Col>
|
||||||
<Form.Item
|
<Col span={8}>
|
||||||
label={t("notes.fields.private")}
|
<Form.Item
|
||||||
name="private"
|
label={t("notes.fields.private")}
|
||||||
valuePropName="checked"
|
name="private"
|
||||||
>
|
valuePropName="checked"
|
||||||
<Switch />
|
>
|
||||||
</Form.Item>
|
<Switch />
|
||||||
</Col>
|
</Form.Item>
|
||||||
<Col span={8}>
|
</Col>
|
||||||
<NotesPresetButton form={form} />
|
<Col span={8}>
|
||||||
</Col>
|
<NotesPresetButton form={form} />
|
||||||
<Col span={24}>
|
</Col>
|
||||||
<Form.Item
|
<Col span={24}>
|
||||||
label={t("notes.fields.text")}
|
<Form.Item
|
||||||
name="text"
|
label={t("notes.fields.text")}
|
||||||
rules={[
|
name="text"
|
||||||
{
|
rules={[
|
||||||
required: true,
|
{
|
||||||
//message: t("general.validation.required"),
|
required: true,
|
||||||
},
|
//message: t("general.validation.required"),
|
||||||
]}
|
},
|
||||||
>
|
]}
|
||||||
<Input.TextArea
|
>
|
||||||
rows={8}
|
<Input.TextArea
|
||||||
placeholder={t("notes.labels.newnoteplaceholder")}
|
rows={8}
|
||||||
/>
|
placeholder={t("notes.labels.newnoteplaceholder")}
|
||||||
</Form.Item>
|
/>
|
||||||
</Col>
|
</Form.Item>
|
||||||
</Row>
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<div>
|
||||||
|
<div>{!existingNote && t("notes.labels.addtorelatedro")}</div>
|
||||||
|
{!existingNote &&
|
||||||
|
filteredRelatedRos.map((j, idx) => (
|
||||||
|
<Space key={j.id} align="center">
|
||||||
|
<Form.Item
|
||||||
|
noStyle
|
||||||
|
name={["relatedros", j.id]}
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Checkbox />
|
||||||
|
</Form.Item>
|
||||||
|
<Tag>
|
||||||
|
{`${j.ro_number || "N/A"}${j.clm_no ? ` | ${j.clm_no}` : ""}${
|
||||||
|
j.status ? ` | ${j.status}` : ""
|
||||||
|
}`}
|
||||||
|
</Tag>
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import React, { useEffect } 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 { createStructuredSelector } from "reselect";
|
||||||
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { INSERT_NEW_NOTE, UPDATE_NOTE } from "../../graphql/notes.queries";
|
import { INSERT_NEW_NOTE, UPDATE_NOTE } from "../../graphql/notes.queries";
|
||||||
|
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||||
import { selectNoteUpsert } from "../../redux/modals/modals.selectors";
|
import { selectNoteUpsert } from "../../redux/modals/modals.selectors";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
import NoteUpsertModalComponent from "./note-upsert-modal.component";
|
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
|
||||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
|
||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
|
import NoteUpsertModalComponent from "./note-upsert-modal.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
@@ -48,7 +48,9 @@ export function NoteUpsertModalContainer({
|
|||||||
}
|
}
|
||||||
}, [existingNote, form, visible]);
|
}, [existingNote, form, visible]);
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = async (formValues) => {
|
||||||
|
const { relatedros, ...values } = formValues;
|
||||||
|
|
||||||
if (existingNote) {
|
if (existingNote) {
|
||||||
logImEXEvent("job_note_update");
|
logImEXEvent("job_note_update");
|
||||||
|
|
||||||
@@ -70,24 +72,48 @@ export function NoteUpsertModalContainer({
|
|||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
} else {
|
} else {
|
||||||
logImEXEvent("job_note_insert");
|
logImEXEvent("job_note_insert");
|
||||||
|
const AdditionalNoteInserts = Object.keys(relatedros).filter(
|
||||||
|
(key) => relatedros[key]
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
"🚀 ~ file: note-upsert-modal.container.jsx ~ line 78 ~ handleFinish ~ AdditionalNoteInserts",
|
||||||
|
AdditionalNoteInserts
|
||||||
|
);
|
||||||
|
|
||||||
insertNote({
|
await insertNote({
|
||||||
variables: {
|
variables: {
|
||||||
noteInput: [
|
noteInput: [
|
||||||
{ ...values, jobid: jobId, created_by: currentUser.email },
|
{ ...values, jobid: jobId, created_by: currentUser.email },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).then((r) => {
|
});
|
||||||
if (refetch) refetch();
|
|
||||||
form.resetFields();
|
if (AdditionalNoteInserts.length > 0) {
|
||||||
toggleModalVisible();
|
//Insert the others.
|
||||||
notification["success"]({
|
AdditionalNoteInserts.forEach(async (newJobId) => {
|
||||||
message: t("notes.successes.create"),
|
await insertNote({
|
||||||
});
|
variables: {
|
||||||
insertAuditTrail({
|
noteInput: [
|
||||||
jobid: context.jobId,
|
{ ...values, jobid: newJobId, created_by: currentUser.email },
|
||||||
operation: AuditTrailMapping.jobnoteadded(),
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
insertAuditTrail({
|
||||||
|
jobid: newJobId,
|
||||||
|
operation: AuditTrailMapping.jobnoteadded(),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refetch) refetch();
|
||||||
|
form.resetFields();
|
||||||
|
toggleModalVisible();
|
||||||
|
notification["success"]({
|
||||||
|
message: t("notes.successes.create"),
|
||||||
|
});
|
||||||
|
insertAuditTrail({
|
||||||
|
jobid: context.jobId,
|
||||||
|
operation: AuditTrailMapping.jobnoteadded(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function NotesPresetButton({ bodyshop, form }) {
|
|||||||
const menu = (
|
const menu = (
|
||||||
<Menu>
|
<Menu>
|
||||||
{bodyshop.md_notes_presets.map((i, idx) => (
|
{bodyshop.md_notes_presets.map((i, idx) => (
|
||||||
<Menu.Item onClick={() => handleSelect(i)} onItemHover key={idx}>
|
<Menu.Item onClick={() => handleSelect(i)} key={idx}>
|
||||||
{i.label}
|
{i.label}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ export const QUERY_NOTES_BY_JOB_PK = gql`
|
|||||||
jobs_by_pk(id: $id) {
|
jobs_by_pk(id: $id) {
|
||||||
id
|
id
|
||||||
ro_number
|
ro_number
|
||||||
|
vehicle{
|
||||||
|
jobs{
|
||||||
|
id
|
||||||
|
ro_number
|
||||||
|
status
|
||||||
|
clm_no
|
||||||
|
}
|
||||||
|
}
|
||||||
notes {
|
notes {
|
||||||
created_at
|
created_at
|
||||||
created_by
|
created_by
|
||||||
|
|||||||
@@ -1861,6 +1861,7 @@
|
|||||||
"updatedat": "Updated At"
|
"updatedat": "Updated At"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"addtorelatedro": "Add to Related ROs",
|
||||||
"newnoteplaceholder": "Add a note...",
|
"newnoteplaceholder": "Add a note...",
|
||||||
"notetoadd": "Note to Add"
|
"notetoadd": "Note to Add"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1861,6 +1861,7 @@
|
|||||||
"updatedat": "Actualizado en"
|
"updatedat": "Actualizado en"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"addtorelatedro": "",
|
||||||
"newnoteplaceholder": "Agrega una nota...",
|
"newnoteplaceholder": "Agrega una nota...",
|
||||||
"notetoadd": ""
|
"notetoadd": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1861,6 +1861,7 @@
|
|||||||
"updatedat": "Mis à jour à"
|
"updatedat": "Mis à jour à"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"addtorelatedro": "",
|
||||||
"newnoteplaceholder": "Ajouter une note...",
|
"newnoteplaceholder": "Ajouter une note...",
|
||||||
"notetoadd": ""
|
"notetoadd": ""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user