From 3498fbc8f1fdcc152fa4aa3fed12f7bf35f303fd Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Fri, 16 Aug 2024 11:14:32 -0400 Subject: [PATCH] - Add Alert Filter to visual production board Signed-off-by: Dave Richer --- .../production-board-filters.component.jsx | 25 ++++++++++++++++--- .../production-board-kanban.utils.js | 7 +++++- client/src/translations/en_us/common.json | 3 ++- client/src/translations/es/common.json | 3 ++- client/src/translations/fr/common.json | 3 ++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/client/src/components/production-board-filters/production-board-filters.component.jsx b/client/src/components/production-board-filters/production-board-filters.component.jsx index 421759534..90afb4fe7 100644 --- a/client/src/components/production-board-filters/production-board-filters.component.jsx +++ b/client/src/components/production-board-filters/production-board-filters.component.jsx @@ -1,22 +1,32 @@ -import { Input, Space, Spin } from "antd"; -import React from "react"; +import { Button, Input, Space, Spin } from "antd"; +import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; +import { ExclamationCircleFilled, ExclamationCircleOutlined } from "@ant-design/icons"; import { selectBodyshop } from "../../redux/user/user.selectors"; import EmployeeSearchSelectComponent from "../employee-search-select/employee-search-select.component"; const mapStateToProps = createStructuredSelector({ - //currentUser: selectCurrentUser bodyshop: selectBodyshop }); + const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); + export default connect(mapStateToProps, mapDispatchToProps)(ProductionBoardFilters); export function ProductionBoardFilters({ bodyshop, filter, setFilter, loading }) { const { t } = useTranslation(); + const [alertFilter, setAlertFilter] = useState(false); + + const toggleAlertFilter = () => { + const newAlertFilter = !alertFilter; + setAlertFilter(newAlertFilter); + setFilter({ ...filter, alert: newAlertFilter }); + }; + return ( {loading && } @@ -31,10 +41,17 @@ export function ProductionBoardFilters({ bodyshop, filter, setFilter, loading }) style={{ minWidth: "20rem" }} options={bodyshop.employees.filter((e) => e.active)} value={filter.employeeId} - placeholder={t("production.labels.employeesearch")} + placeholder={t("production.labels.alerts")} onChange={(emp) => setFilter({ ...filter, employeeId: emp })} allowClear /> + ); } diff --git a/client/src/components/production-board-kanban/production-board-kanban.utils.js b/client/src/components/production-board-kanban/production-board-kanban.utils.js index fed3d12db..ba3974c1a 100644 --- a/client/src/components/production-board-kanban/production-board-kanban.utils.js +++ b/client/src/components/production-board-kanban/production-board-kanban.utils.js @@ -29,7 +29,7 @@ const sortByParentId = (arr) => { // Function to create board data based on statuses and jobs, with optional filtering export const createBoardData = ({ statuses, data, filter, cardSettings }) => { - const { search, employeeId } = filter; + const { search, employeeId, alert } = filter; const lanes = statuses.map((status) => ({ id: status, @@ -52,6 +52,11 @@ export const createBoardData = ({ statuses, data, filter, cardSettings }) => { ); } + // Filter jobs by alert if alert filter is true + if (alert) { + filteredJobs = filteredJobs.filter((job) => job.production_vars?.alert); + } + const DataGroupedByStatus = groupBy(filteredJobs, "status"); Object.keys(DataGroupedByStatus).forEach((statusGroupKey) => { diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 4dd123fd8..c2d776fbf 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2833,7 +2833,8 @@ "sublets": "Sublets", "totalhours": "Total Hrs ", "touchtime": "T/T", - "viewname": "View Name" + "viewname": "View Name", + "alerts": "Alerts" }, "successes": { "removed": "Job removed from production." diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index bafe9ced5..c2da8510a 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2833,7 +2833,8 @@ "sublets": "", "totalhours": "", "touchtime": "", - "viewname": "" + "viewname": "", + "alerts": "" }, "successes": { "removed": "" diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 5fd0c1280..005accb1c 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2833,7 +2833,8 @@ "sublets": "", "totalhours": "", "touchtime": "", - "viewname": "" + "viewname": "", + "alerts": "" }, "successes": { "removed": ""