From 4d60ffd597d601166f64cf0af8d41510091124c2 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 31 Jul 2020 10:25:58 -0700 Subject: [PATCH] Added parts location to job line list view. BOD-208 --- bodyshop_translations.babel | 63 ++++++++++++++ .../job-detail-lines/job-lines.component.jsx | 7 ++ .../job-line-location-popup.component.jsx | 83 +++++++++++++++++++ .../shop-info/shop-info.component.jsx | 56 +++++++++++++ .../shop-info.speedprint.component.jsx | 2 +- client/src/graphql/bodyshop.queries.js | 2 + client/src/graphql/jobs-lines.queries.js | 3 + client/src/translations/en_us/common.json | 3 + client/src/translations/es/common.json | 3 + client/src/translations/fr/common.json | 3 + .../down.yaml | 5 ++ .../up.yaml | 6 ++ .../down.yaml | 58 +++++++++++++ .../up.yaml | 59 +++++++++++++ .../down.yaml | 52 ++++++++++++ .../up.yaml | 53 ++++++++++++ .../down.yaml | 5 ++ .../up.yaml | 5 ++ .../down.yaml | 76 +++++++++++++++++ .../up.yaml | 77 +++++++++++++++++ .../down.yaml | 77 +++++++++++++++++ .../up.yaml | 78 +++++++++++++++++ .../down.yaml | 76 +++++++++++++++++ .../up.yaml | 77 +++++++++++++++++ hasura/migrations/metadata.yaml | 5 ++ 25 files changed, 933 insertions(+), 1 deletion(-) create mode 100644 client/src/components/job-line-location-popup/job-line-location-popup.component.jsx create mode 100644 hasura/migrations/1596214147082_alter_table_public_bodyshops_add_column_md_parts_locations/down.yaml create mode 100644 hasura/migrations/1596214147082_alter_table_public_bodyshops_add_column_md_parts_locations/up.yaml create mode 100644 hasura/migrations/1596214157786_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1596214157786_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1596214165919_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1596214165919_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1596214559217_alter_table_public_joblines_add_column_location/down.yaml create mode 100644 hasura/migrations/1596214559217_alter_table_public_joblines_add_column_location/up.yaml create mode 100644 hasura/migrations/1596214571725_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1596214571725_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1596214578452_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1596214578452_update_permission_user_public_table_joblines/up.yaml create mode 100644 hasura/migrations/1596214586798_update_permission_user_public_table_joblines/down.yaml create mode 100644 hasura/migrations/1596214586798_update_permission_user_public_table_joblines/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index c73ff4b0c..76f6984b1 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -886,6 +886,27 @@ + + addpartslocation + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + addspeedprint false @@ -1379,6 +1400,27 @@ + + partslocation + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + responsibilitycenter false @@ -8601,6 +8643,27 @@ + + location + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + mod_lb_hrs false diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 01d9e3333..fbc9e289e 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -13,6 +13,7 @@ import { alphaSort } from "../../utils/sorters"; // import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container"; import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container"; import JobLineNotePopup from "../job-line-note-popup/job-line-note-popup.component"; +import JobLineLocationPopup from "../job-line-location-popup/job-line-location-popup.component"; const mapDispatchToProps = (dispatch) => ({ setJobLineEditContext: (context) => @@ -170,6 +171,12 @@ export function JobLinesComponent({ key: "notes", render: (text, record) => , }, + { + title: t("joblines.fields.location"), + dataIndex: "location", + key: "location", + render: (text, record) => , + }, { title: t("joblines.fields.status"), dataIndex: "status", diff --git a/client/src/components/job-line-location-popup/job-line-location-popup.component.jsx b/client/src/components/job-line-location-popup/job-line-location-popup.component.jsx new file mode 100644 index 000000000..8d0d0d138 --- /dev/null +++ b/client/src/components/job-line-location-popup/job-line-location-popup.component.jsx @@ -0,0 +1,83 @@ +import React, { useState, useEffect } from "react"; +import { Input, notification, Select } from "antd"; +import LoadingSpinner from "../loading-spinner/loading-spinner.component"; +import { useMutation } from "react-apollo"; +import { UPDATE_JOB_LINE } from "../../graphql/jobs-lines.queries"; +import { useTranslation } from "react-i18next"; + +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); + +export function JobLineLocationPopup({ bodyshop, jobline }) { + const [editing, setEditing] = useState(false); + const [loading, setLoading] = useState(false); + const [location, setLocation] = useState(jobline.location); + const [updateJob] = useMutation(UPDATE_JOB_LINE); + const { t } = useTranslation(); + + useEffect(() => { + if (editing) setLocation(jobline.location); + }, [editing, jobline.location]); + + const handleChange = (e) => { + setLocation(e); + }; + + const handleSave = async (e) => { + setLoading(true); + const result = await updateJob({ + variables: { lineId: jobline.id, line: { location: location || "" } }, + }); + + if (!!!result.errors) { + notification["success"]({ message: t("joblines.successes.saved") }); + } else { + notification["error"]({ + message: t("joblines.errors.saving", { + error: JSON.stringify(result.errors), + }), + }); + } + setLoading(false); + setEditing(false); + }; + + if (editing) + return ( + + + {bodyshop.md_parts_locations.map((loc, idx) => ( + + {loc} + + ))} + + + ); + return ( + setEditing(true)} + > + {jobline.location} + + ); +} +export default connect( + mapStateToProps, + mapDispatchToProps +)(JobLineLocationPopup); diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index d0efeeff9..8a5183d11 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -17,6 +17,7 @@ import ShopInfoSchedulingComponent from "./shop-info.scheduling.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import ShopInfoIntakeChecklistComponent from "./shop-info.intake.component"; import ShopInfoSpeedPrint from "./shop-info.speedprint.component"; +import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; export default function ShopInfoComponent({ form, saveLoading }) { const { t } = useTranslation(); @@ -273,6 +274,61 @@ export default function ShopInfoComponent({ form, saveLoading }) { ); }} + + + {(fields, { add, remove, move }) => { + return ( + + {fields.map((field, index) => ( + + + + + + + { + remove(field.name); + }} + /> + + + + ))} + + { + add(); + }} + style={{ width: "100%" }} + > + {t("bodyshop.actions.addpartslocation")} + + + + ); + }} +