fix: edit object modal

This commit is contained in:
Aaryan Khandelwal 2023-09-20 16:33:33 +05:30
parent c714b5e50c
commit 4a13b30874
3 changed files with 14 additions and 5 deletions

View File

@ -39,7 +39,11 @@ export const TypesDropdown: React.FC<Props> = ({ onClick }) => {
<Plus size={14} strokeWidth={1.5} />
Add Attribute
</Menu.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<div
className={`${
open ? "" : "hidden"
} fixed z-20 top-0 left-0 h-full w-full cursor-auto`}
>
<Menu.Items
ref={optionsRef}
className="fixed z-10 border-[0.5px] border-custom-border-300 p-1 min-w-[10rem] max-h-60 rounded bg-custom-background-100 text-xs shadow-custom-shadow-rg focus:outline-none overflow-y-auto"

View File

@ -110,8 +110,13 @@ export const ObjectModal: React.FC<Props> = observer(
if (!workspaceSlug) return;
customAttributes.fetchEntityDetails(workspaceSlug.toString(), object.id).then((res) => {
setObject({ ...res });
setObject((prev) => ({ ...prev, ...res }));
});
} else {
setObject((prev) => ({
...prev,
...customAttributes.entities?.find((e) => e.id === object.id),
}));
}
}, [customAttributes, object.id, workspaceSlug]);
@ -119,8 +124,8 @@ export const ObjectModal: React.FC<Props> = observer(
useEffect(() => {
if (!objectIdToEdit) return;
setObject((prevData) => ({
...prevData,
setObject((prev) => ({
...prev,
id: objectIdToEdit,
}));
}, [objectIdToEdit]);

View File

@ -8,7 +8,7 @@ import type { ICustomAttribute } from "types";
class CustomAttributesStore {
entities: ICustomAttribute[] | null = null;
entityAttributes: {
[key: string]: { [key: string]: ICustomAttribute };
[entityId: string]: { [entityAttributeId: string]: ICustomAttribute };
} = {};
// loaders
fetchEntitiesLoader = false;