diff --git a/databox/client/src/api/attributes.ts b/databox/client/src/api/attributes.ts index 563d51159..b188b1bd0 100644 --- a/databox/client/src/api/attributes.ts +++ b/databox/client/src/api/attributes.ts @@ -7,8 +7,10 @@ export const attributeDefinitionNS = '/attribute-definitions'; export async function putAttributeDefinition( id: string | undefined, - data: AttributeDefinition + data: Partial ): Promise { + delete data.workspace; + return ((await apiClient.put(`${attributeDefinitionNS}/${id}`, data)).data); } diff --git a/databox/client/src/components/Dialog/Workspace/AttributeClassManager.tsx b/databox/client/src/components/Dialog/Workspace/AttributeClassManager.tsx index 58636481b..6e92cf6c5 100644 --- a/databox/client/src/components/Dialog/Workspace/AttributeClassManager.tsx +++ b/databox/client/src/components/Dialog/Workspace/AttributeClassManager.tsx @@ -32,10 +32,16 @@ function Item({ control, watch, setValue, + reset, formState: {errors, isDirty} } = useForm({ defaultValues: data, }); + + React.useEffect(() => { + reset(data); + }, [data]); + useDirtyFormPrompt(isDirty); const isPublic = watch('public');