IO-1412 Resolve production list saving and loading.

This commit is contained in:
Patrick Fic
2021-10-05 09:40:25 -07:00
parent b59a5303c6
commit cdb4da9e5f
3 changed files with 24 additions and 12 deletions

View File

@@ -66,12 +66,7 @@ export function ProductionListSaveConfigButton({
};
const popMenu = (
<div>
<Form
layout="vertical"
form={form}
onFinish={handleSaveConfig}
initialValues={{ driveable: true, towin: false }}
>
<Form layout="vertical" form={form} onFinish={handleSaveConfig}>
<Form.Item
label={t("production.labels.viewname")}
name="name"

View File

@@ -55,6 +55,19 @@ export function ProductionListTable({
if (assoc) {
await updateDefaultProdView({
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);
};
const assoc = bodyshop.associations.find(
(a) => a.useremail === currentUser.email
);
const defaultView = assoc && assoc.default_prod_list_view;
return (
<div style={{ width: "10rem" }}>
<Select
onSelect={handleSelect}
placeholder={t("production.labels.selectview")}
optionLabelProp="label"
defaultValue={defaultView}
>
{bodyshop.production_config.map((config) => (
<Select.Option key={config.name} label={config.name}>

View File

@@ -32,12 +32,11 @@ export function ProductionListTable({
}) {
const [searchText, setSearchText] = useState("");
const defaultView = useMemo(() => {
const assoc = bodyshop.associations.find(
(a) => a.useremail === currentUser.email
);
return assoc && assoc.default_prod_list_view;
}, [bodyshop.associations, currentUser.email]);
const assoc = bodyshop.associations.find(
(a) => a.useremail === currentUser.email
);
const defaultView = assoc && assoc.default_prod_list_view;
const [state, setState] = useState(
(bodyshop.production_config &&