IO-1412 Resolve production list saving and loading.
This commit is contained in:
@@ -66,12 +66,7 @@ export function ProductionListSaveConfigButton({
|
|||||||
};
|
};
|
||||||
const popMenu = (
|
const popMenu = (
|
||||||
<div>
|
<div>
|
||||||
<Form
|
<Form layout="vertical" form={form} onFinish={handleSaveConfig}>
|
||||||
layout="vertical"
|
|
||||||
form={form}
|
|
||||||
onFinish={handleSaveConfig}
|
|
||||||
initialValues={{ driveable: true, towin: false }}
|
|
||||||
>
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("production.labels.viewname")}
|
label={t("production.labels.viewname")}
|
||||||
name="name"
|
name="name"
|
||||||
|
|||||||
@@ -55,6 +55,19 @@ export function ProductionListTable({
|
|||||||
if (assoc) {
|
if (assoc) {
|
||||||
await updateDefaultProdView({
|
await updateDefaultProdView({
|
||||||
variables: { assocId: assoc.id, view: value },
|
variables: { assocId: assoc.id, view: value },
|
||||||
|
update(cache) {
|
||||||
|
cache.modify({
|
||||||
|
id: cache.identify(bodyshop),
|
||||||
|
fields: {
|
||||||
|
associations(existingAssociations, { readField }) {
|
||||||
|
return existingAssociations.map((a) => {
|
||||||
|
if (a.useremail !== currentUser.email) return a;
|
||||||
|
return { ...a, default_prod_list_view: value };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -85,13 +98,18 @@ export function ProductionListTable({
|
|||||||
|
|
||||||
setState(bodyshop.production_config[0].columns.tableState);
|
setState(bodyshop.production_config[0].columns.tableState);
|
||||||
};
|
};
|
||||||
|
const assoc = bodyshop.associations.find(
|
||||||
|
(a) => a.useremail === currentUser.email
|
||||||
|
);
|
||||||
|
|
||||||
|
const defaultView = assoc && assoc.default_prod_list_view;
|
||||||
return (
|
return (
|
||||||
<div style={{ width: "10rem" }}>
|
<div style={{ width: "10rem" }}>
|
||||||
<Select
|
<Select
|
||||||
onSelect={handleSelect}
|
onSelect={handleSelect}
|
||||||
placeholder={t("production.labels.selectview")}
|
placeholder={t("production.labels.selectview")}
|
||||||
optionLabelProp="label"
|
optionLabelProp="label"
|
||||||
|
defaultValue={defaultView}
|
||||||
>
|
>
|
||||||
{bodyshop.production_config.map((config) => (
|
{bodyshop.production_config.map((config) => (
|
||||||
<Select.Option key={config.name} label={config.name}>
|
<Select.Option key={config.name} label={config.name}>
|
||||||
|
|||||||
@@ -32,12 +32,11 @@ export function ProductionListTable({
|
|||||||
}) {
|
}) {
|
||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
const defaultView = useMemo(() => {
|
const assoc = bodyshop.associations.find(
|
||||||
const assoc = bodyshop.associations.find(
|
(a) => a.useremail === currentUser.email
|
||||||
(a) => a.useremail === currentUser.email
|
);
|
||||||
);
|
|
||||||
return assoc && assoc.default_prod_list_view;
|
const defaultView = assoc && assoc.default_prod_list_view;
|
||||||
}, [bodyshop.associations, currentUser.email]);
|
|
||||||
|
|
||||||
const [state, setState] = useState(
|
const [state, setState] = useState(
|
||||||
(bodyshop.production_config &&
|
(bodyshop.production_config &&
|
||||||
|
|||||||
Reference in New Issue
Block a user