From 1e00b376ea1e8c1e8f9d44320e5fb063d6657ba4 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 24 Jul 2020 13:54:13 -0700 Subject: [PATCH] Fixed production list sider shwoing on click by adding new component --- ...roduction-list-columns.alert.component.jsx | 4 +- ...on-list-columns.bodypriority.component.jsx | 12 ++--- .../production-list-columns.data.js | 10 +++++ ...n-list-columns.paintpriority.component.jsx | 2 +- ...-list-columns.productionnote.component.jsx | 4 +- ...oduction-list-columns.status.component.jsx | 2 +- .../production-list-detail.component.jsx | 24 +++++++--- .../production-list-table.component.jsx | 45 ++++++++----------- server.js | 3 +- 9 files changed, 62 insertions(+), 44 deletions(-) diff --git a/client/src/components/production-list-columns/production-list-columns.alert.component.jsx b/client/src/components/production-list-columns/production-list-columns.alert.component.jsx index 69c80989f..5ab493d2c 100644 --- a/client/src/components/production-list-columns/production-list-columns.alert.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.alert.component.jsx @@ -11,9 +11,9 @@ export default function ProductionListColumnAlert({ record }) { const [updateAlert] = useMutation(UPDATE_JOB); - const handleAlertToggle = () => { + const handleAlertToggle = (e) => { logImEXEvent("production_toggle_alert"); - + e.stopPropagation(); updateAlert({ variables: { jobId: record.id, diff --git a/client/src/components/production-list-columns/production-list-columns.bodypriority.component.jsx b/client/src/components/production-list-columns/production-list-columns.bodypriority.component.jsx index a56f93a31..603c7e333 100644 --- a/client/src/components/production-list-columns/production-list-columns.bodypriority.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.bodypriority.component.jsx @@ -12,7 +12,7 @@ export default function ProductionListColumnBodyPriority({ record }) { const handleSetBodyPriority = (e) => { logImEXEvent("production_set_body_priority"); - + e.stopPropagation(); const { key } = e; updateAlert({ variables: { @@ -33,19 +33,21 @@ export default function ProductionListColumnBodyPriority({ record }) { - + {t("production.actions.bodypriority-clear")} + key="set" + title={t("production.actions.bodypriority-set")} + > {new Array(9).fill().map((value, index) => ( {index + 1} ))} } - trigger={["contextMenu"]}> + trigger={["contextMenu"]} + >
{record.production_vars && record.production_vars.bodypriority}
diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index 7449e100e..370ca2797 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -11,7 +11,17 @@ import ProductionListColumnPaintPriority from "./production-list-columns.paintpr import ProductionListColumnStatus from "./production-list-columns.status.component"; import ProductionListColumnNote from "./production-list-columns.productionnote.component"; + export default [ + { + title: i18n.t("jobs.actions.viewdetail"), + dataIndex: "viewdetail", + key: "viewdetail", + ellipsis: true, + render: (text, record) => ( + {i18n.t("general.labels.view")} + ), + }, { title: i18n.t("jobs.fields.ro_number"), dataIndex: "ro_number", diff --git a/client/src/components/production-list-columns/production-list-columns.paintpriority.component.jsx b/client/src/components/production-list-columns/production-list-columns.paintpriority.component.jsx index ee15f747d..1379ca6c4 100644 --- a/client/src/components/production-list-columns/production-list-columns.paintpriority.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.paintpriority.component.jsx @@ -12,7 +12,7 @@ export default function ProductionListColumnPaintPriority({ record }) { const handleSetPaintPriority = (e) => { logImEXEvent("production_set_paint_priority"); - + e.stopPropagation(); const { key } = e; updateAlert({ variables: { diff --git a/client/src/components/production-list-columns/production-list-columns.productionnote.component.jsx b/client/src/components/production-list-columns/production-list-columns.productionnote.component.jsx index dc1c0aced..ac4b8e80c 100644 --- a/client/src/components/production-list-columns/production-list-columns.productionnote.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.productionnote.component.jsx @@ -18,7 +18,7 @@ export default function ProductionListColumnProductionNote({ record }) { const handleSaveNote = (e) => { logImEXEvent("production_add_note"); - + e.stopPropagation(); setVisible(false); updateAlert({ variables: { @@ -36,10 +36,12 @@ export default function ProductionListColumnProductionNote({ record }) { }; const handleChange = (e) => { + e.stopPropagation(); setNote(e.target.value); }; const handleVisibleChange = (flag) => { + setVisible(flag); if (flag) setNote((record.production_vars && record.production_vars.note) || ""); diff --git a/client/src/components/production-list-columns/production-list-columns.status.component.jsx b/client/src/components/production-list-columns/production-list-columns.status.component.jsx index 9adfa7a3c..77df7622b 100644 --- a/client/src/components/production-list-columns/production-list-columns.status.component.jsx +++ b/client/src/components/production-list-columns/production-list-columns.status.component.jsx @@ -16,7 +16,7 @@ export function ProductionListColumnStatus({ record, bodyshop }) { const handleSetStatus = (e) => { logImEXEvent("production_change_status"); - + e.stopPropagation(); const { key } = e; updateJob({ variables: { diff --git a/client/src/components/production-list-detail/production-list-detail.component.jsx b/client/src/components/production-list-detail/production-list-detail.component.jsx index fda1c792f..147105d3e 100644 --- a/client/src/components/production-list-detail/production-list-detail.component.jsx +++ b/client/src/components/production-list-detail/production-list-detail.component.jsx @@ -6,27 +6,39 @@ import { DateFormatter } from "../../utils/DateFormatter"; import PartsPieGraph from "../parts-status-pie/parts-status-pie.component"; import Barcode from "react-barcode"; import ProductionRemoveButton from "../production-remove-button/production-remove-button.component"; +import queryString from "query-string"; +import { useHistory, useLocation } from "react-router-dom"; + +export default function ProductionListDetail({ jobs }) { + const search = queryString.parse(useLocation().search); + const history = useHistory(); + const { selected } = search; -export default function ProductionListDetail({ selected, setSelected, jobs }) { const { t } = useTranslation(); const theJob = jobs.find((j) => j.id === selected) || {}; + const handleClose = () => { + delete search.selected; + history.push({ search: queryString.stringify(search) }); + }; + return ( setSelected(null)} - visible={!!selected}> + onClose={handleClose} + visible={!!selected} + >
- + {theJob.ro_number || ""} diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index a83f18c1d..ecd626ff8 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -33,7 +33,6 @@ export function ProductionListTable({ filteredInfo: { text: "" }, } ); - const [selected, setSelected] = useState(null); const { t } = useTranslation(); const Now = new Date(); const handleTableChange = (pagination, filters, sorter) => { @@ -67,7 +66,7 @@ export function ProductionListTable({ const headerItem = (col) => ( @@ -75,7 +74,8 @@ export function ProductionListTable({ } - trigger={["contextMenu"]}> + trigger={["contextMenu"]} + > {col.title} ); @@ -115,7 +115,8 @@ export function ProductionListTable({ ); - const handleSelectRecord = (record) => { - if (selected !== record.id) { - setSelected(record.id); - } else { - setSelected(null); - } - }; + // const handleSelectRecord = (record) => { + // if (selected !== record.id) { + // setSelected(record.id); + // } else { + // setSelected(null); + // } + // }; if (!!!columns) return
No columns found.
; return (
- + + nodeSelector="th" + handleSelector=".prod-header-dropdown" + > { - return { - onClick: (event) => { - handleSelectRecord(record); - }, - }; - }} dataSource={dataSource} onChange={handleTableChange} rowClassName={(record, index) => { diff --git a/server.js b/server.js index 5ae9bba04..0a6d04237 100644 --- a/server.js +++ b/server.js @@ -94,12 +94,13 @@ app.post("/utils/time", utils.servertime); //Serve React App if in Production if (process.env.NODE_ENV === "production") { app.use(express.static(path.join(__dirname, "client/build"))); + app.use(express.static(path.join(__dirname, "admin/build"))); app.get("/service-worker.js", (req, res) => { res.sendFile(path.resolve(__dirname, "..", "build", "service-worker.js")); }); - app.get("/admin/*", function (req, res) { + app.get("/admin*", function (req, res) { res.sendFile(path.join(__dirname, "admin/build", "index.html")); });