diff --git a/client/src/components/production-board-kanban/production-board-kanban.settings.component.jsx b/client/src/components/production-board-kanban/production-board-kanban.settings.component.jsx
index b5bb92d90..73192590b 100644
--- a/client/src/components/production-board-kanban/production-board-kanban.settings.component.jsx
+++ b/client/src/components/production-board-kanban/production-board-kanban.settings.component.jsx
@@ -4,23 +4,26 @@ import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { UPDATE_KANBAN_SETTINGS } from "../../graphql/user.queries";
-export default function ProductionBoardKanbanSettings({ associationSettings, parentLoading, onSettingsChange }) {
+export default function ProductionBoardKanbanSettings({ associationSettings, parentLoading }) {
const [form] = Form.useForm();
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState(false);
const [hasChanges, setHasChanges] = useState(false);
- const [orientation, setOrientation] = useState(true); // Default to vertical
-
+ const [orientation, setOrientation] = useState(true);
+ const [compact, setCompact] = useState(false);
+ const [colored, setColored] = useState(false);
const [updateKbSettings] = useMutation(UPDATE_KANBAN_SETTINGS);
+ const { t } = useTranslation();
useEffect(() => {
if (associationSettings?.kanban_settings) {
+ const { orientation = true, compact = true, cardcolor = true } = associationSettings.kanban_settings;
form.setFieldsValue(associationSettings.kanban_settings);
- setOrientation(associationSettings.kanban_settings?.orientation ?? true);
+ setOrientation(orientation);
+ setCompact(compact);
+ setColored(cardcolor);
}
- }, [form, associationSettings, open]);
-
- const { t } = useTranslation();
+ }, [form, associationSettings]);
const handleFinish = async (values) => {
setLoading(true);
@@ -29,9 +32,10 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
const result = await updateKbSettings({
variables: {
id: associationSettings?.id,
- ks: { ...values, orientation }
+ ks: { ...values, orientation, compact, cardcolor: colored }
}
});
+
if (result.errors) {
notification.open({
type: "error",
@@ -40,40 +44,56 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
})
});
}
+
setOpen(false);
setLoading(false);
parentLoading(false);
setHasChanges(false);
};
- const handleValuesChange = () => {
- setHasChanges(true);
- };
+ const handleValuesChange = () => setHasChanges(true);
- const handleOrientationChange = (checked) => {
- setOrientation(checked);
+ const handleCheckedChanges = (checked, callback) => {
+ callback(checked);
setHasChanges(true);
};
const cardStyle = { minWidth: "50vw", marginTop: 10 };
+ const renderSwitchItem = (name, checked, callback, labelKey, checkedChildrenKey, unCheckedChildrenKey) => (
+
+
+ handleCheckedChanges(checked, callback)}
+ />
+
+
+ );
+
+ const renderCheckboxItem = (name, labelKey) => (
+
+
+ {t(labelKey)}
+
+
+ );
+
const renderCardSettings = () => (
<>
+ {renderSwitchItem(
+ "orientation",
+ orientation,
+ setOrientation,
+ "production.labels.orientation",
+ "production.labels.vertical",
+ "production.labels.horizontal"
+ )}
-
-
-
-
-
-
-
{t("production.options.small")}
@@ -82,77 +102,39 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
-
-
-
-
- {t("production.labels.compact")}
-
-
-
-
- {t("production.labels.cardcolor")}
-
-
+ {renderSwitchItem(
+ "compact",
+ compact,
+ setCompact,
+ "production.labels.compact",
+ "production.labels.tall",
+ "production.labels.wide"
+ )}
+ {renderSwitchItem(
+ "cardcolor",
+ colored,
+ setColored,
+ "production.labels.cardcolor",
+ "production.labels.on",
+ "production.labels.off"
+ )}
-
-
- {t("production.labels.model_info")}
-
-
-
-
- {t("production.labels.ownr_nm")}
-
-
-
-
- {t("production.labels.clm_no")}
-
-
-
-
- {t("production.labels.ins_co_nm")}
-
-
-
-
- {t("production.labels.employeeassignments")}
-
-
-
-
- {t("production.labels.actual_in")}
-
-
-
-
- {t("production.labels.scheduled_completion")}
-
-
-
-
- {t("production.labels.ats")}
-
-
-
-
- {t("production.labels.production_note")}
-
-
-
-
- {t("production.labels.sublets")}
-
-
-
-
- {t("production.labels.partsstatus")}
-
-
+ {[
+ "model_info",
+ "ownr_nm",
+ "clm_no",
+ "ins_co_nm",
+ "employeeassignments",
+ "actual_in",
+ "scheduled_completion",
+ "ats",
+ "production_note",
+ "sublets",
+ "partsstatus"
+ ].map((item) => renderCheckboxItem(item, `production.labels.${item}`))}
>
@@ -172,7 +154,7 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
-