- Fix bug where changing the card settings would default the orientation back to horizontal despite showing vertical mode on the toggle.

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-07-08 10:46:31 -04:00
parent 8199ab83ef
commit 4b6b4c0c63
4 changed files with 30 additions and 20 deletions

View File

@@ -9,10 +9,13 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState(false);
const [hasChanges, setHasChanges] = useState(false);
const [orientation, setOrientation] = useState(true); // Default to vertical
const [updateKbSettings] = useMutation(UPDATE_KANBAN_SETTINGS);
useEffect(() => {
form.setFieldsValue(associationSettings?.kanban_settings);
setOrientation(associationSettings?.kanban_settings?.orientation ?? true);
}, [form, associationSettings, open]);
const { t } = useTranslation();
@@ -24,7 +27,7 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
const result = await updateKbSettings({
variables: {
id: associationSettings?.id,
ks: values
ks: { ...values, orientation }
}
});
if (result.errors) {
@@ -45,6 +48,11 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
setHasChanges(true);
};
const handleOrientationChange = (checked) => {
setOrientation(checked);
setHasChanges(true);
};
const cardStyle = { minWidth: "50vw", marginTop: 10 };
const renderCardSettings = () => (
@@ -131,8 +139,13 @@ export default function ProductionBoardKanbanSettings({ associationSettings, par
<Row gutter={[16, 16]}>
<Col span={4} style={{ display: "flex", alignItems: "center" }}>
<span style={{ marginRight: "8px" }}>Orientation</span>
<Form.Item name="orientation" valuePropName="checked" style={{ marginBottom: 0 }}>
<Switch checkedChildren="Vertical" unCheckedChildren="Horizontal" defaultChecked />
<Form.Item valuePropName="checked" style={{ marginBottom: 0 }}>
<Switch
checkedChildren="Vertical"
unCheckedChildren="Horizontal"
checked={orientation}
onChange={handleOrientationChange}
/>
</Form.Item>
</Col>
</Row>