diff --git a/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx b/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx new file mode 100644 index 000000000..e9cc0f4e0 --- /dev/null +++ b/client/src/components/production-board-kanban-card/production-board-kanban-card-color-legend.component.jsx @@ -0,0 +1,39 @@ +import { Col, List, Space, Typography } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; + +const CardColorLegend = ({ bodyshop, cardSettings }) => { + const { t } = useTranslation(); + const data = bodyshop.ssbuckets.map((size) => ({ + label: size.label, + color: size.color?.hex ?? "white", + })); + + return ( + + {t("production.labels.legend")} + ( + + +
+
{item.label}
+
+
+ )} + /> + + ); +}; + +export default CardColorLegend; diff --git a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx index 750204fb5..cb955a9c6 100644 --- a/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx +++ b/client/src/components/production-board-kanban-card/production-board-kanban-card.component.jsx @@ -18,6 +18,28 @@ import moment from "moment"; import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component"; +const cardColor = (ssbuckets, totalHrs) => { + const bucket = ssbuckets.filter( + (bucket) => + bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true) + )[0]; + + if (bucket.color) { + return bucket.color.hex; + } + + return ""; +}; + +function getContrastYIQ(hexColor) { + const r = parseInt(hexColor.substr(1, 2), 16); + const g = parseInt(hexColor.substr(3, 2), 16); + const b = parseInt(hexColor.substr(5, 2), 16); + const yiq = (r * 299 + g * 587 + b * 114) / 1000; + + return yiq >= 128 ? "black" : "white"; +} + export default function ProductionBoardCard( technician, card, @@ -54,10 +76,19 @@ export default function ProductionBoardCard( .isSame(moment(card.scheduled_completion), "day") && "production-completion-soon")); + const totalHrs = + card.labhrs.aggregate.sum.mod_lb_hrs + card.larhrs.aggregate.sum.mod_lb_hrs; + const bgColor = cardColor(bodyshop.ssbuckets, totalHrs); + return ( diff --git a/client/src/components/production-board-kanban/production-board-kanban.card-settings.component.jsx b/client/src/components/production-board-kanban/production-board-kanban.card-settings.component.jsx index 25c77e307..bc7f83494 100644 --- a/client/src/components/production-board-kanban/production-board-kanban.card-settings.component.jsx +++ b/client/src/components/production-board-kanban/production-board-kanban.card-settings.component.jsx @@ -104,6 +104,13 @@ export default function ProductionBoardKanbanCardSettings({ > + + + } /> + + {cardSettings.cardcolor && ( + + )} + + + + + + { diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index f52178267..1819fadbe 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -508,7 +508,8 @@ "id": "ID", "label": "Label", "lt": "Less than (hrs)", - "target": "Target (count)" + "target": "Target (count)", + "color": "Job Color" }, "state": "Province/State", "state_tax_id": "Provincial/State Tax ID (PST, QST)", @@ -2385,7 +2386,9 @@ "sublets": "Sublets", "totalhours": "Total Hrs ", "touchtime": "T/T", - "viewname": "View Name" + "viewname": "View Name", + "legend": "Legend:", + "cardcolor": "Card Colors" }, "successes": { "removed": "Job removed from production."