From 68533fa751b37f7ae259d3b1c4bef0d7acee0905 Mon Sep 17 00:00:00 2001 From: niestrow Date: Fri, 29 Nov 2024 16:45:22 +0100 Subject: [PATCH 1/5] Fix project description not working --- frontend-v2/src/features/projects/Project.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/frontend-v2/src/features/projects/Project.tsx b/frontend-v2/src/features/projects/Project.tsx index 4a90759c..7ac934c8 100644 --- a/frontend-v2/src/features/projects/Project.tsx +++ b/frontend-v2/src/features/projects/Project.tsx @@ -120,6 +120,8 @@ const ProjectRow: FC = ({ reset, handleSubmit, control, + setValue, + register, formState: { isDirty }, } = useForm({ defaultValues: { project, compound: defaultCompound }, @@ -158,6 +160,7 @@ const ProjectRow: FC = ({ () => dispatch(decrementDirtyCount()), ); } + console.log('project', project, data.project) if (JSON.stringify(project) !== JSON.stringify(data.project)) { dispatch(incrementDirtyCount()); updateProject({ id: project.id, project: data.project }).then(() => @@ -169,13 +172,8 @@ const ProjectRow: FC = ({ [handleSubmit, compound, project, updateCompound, updateProject], ); - const [fieldValue, setFieldValue] = useFieldState({ - name: "project.description", - control, - }); - const onCancel = () => { - setFieldValue(project.description); + setValue('project.description', project.description); }; if (isLoading) { @@ -414,8 +412,7 @@ const ProjectRow: FC = ({ project={project} > setFieldValue(event.target.value)} - value={fieldValue} + {...register('project.description')} sx={{ width: "50vw" }} disabled={!isEditMode} multiline From c83602296e1216f4264b17d085d893f8fcb13607 Mon Sep 17 00:00:00 2001 From: niestrow Date: Fri, 29 Nov 2024 16:49:46 +0100 Subject: [PATCH 2/5] Fix doses input getting narrow on large scales --- frontend-v2/src/features/trial/Doses.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend-v2/src/features/trial/Doses.tsx b/frontend-v2/src/features/trial/Doses.tsx index 323064a0..d4da0a82 100644 --- a/frontend-v2/src/features/trial/Doses.tsx +++ b/frontend-v2/src/features/trial/Doses.tsx @@ -195,6 +195,7 @@ const Doses: FC = ({ onChange, project, protocol, units }) => { Date: Fri, 29 Nov 2024 16:54:53 +0100 Subject: [PATCH 3/5] Fix unit showing id instead of symbol --- frontend-v2/src/features/drug/Drug.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend-v2/src/features/drug/Drug.tsx b/frontend-v2/src/features/drug/Drug.tsx index 24b8eaa8..4d2e2cb3 100644 --- a/frontend-v2/src/features/drug/Drug.tsx +++ b/frontend-v2/src/features/drug/Drug.tsx @@ -224,7 +224,7 @@ const Drug: FC = () => { setIsEditIndex(isEdit ? index : null); }; - console.log("efficacy_experiments", efficacy_experiments); + console.log("units", units); return (
@@ -408,7 +408,9 @@ const Drug: FC = () => { /> ) : ( - {getValues(`efficacy_experiments.${index}.c50_unit`) || + {units.find( + (u) => u.id === getValues(`efficacy_experiments.${index}.c50_unit`), + )?.symbol || "-"} )} From 87e3c59da8b2594cdc40a784c3a038db4b3d9eee Mon Sep 17 00:00:00 2001 From: niestrow Date: Fri, 29 Nov 2024 17:24:40 +0100 Subject: [PATCH 4/5] FIx sharing project not saving --- frontend-v2/src/features/projects/Project.tsx | 35 ++++++++++++------- .../src/features/projects/UserAccess.tsx | 10 +++++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/frontend-v2/src/features/projects/Project.tsx b/frontend-v2/src/features/projects/Project.tsx index 7ac934c8..7db9a7fe 100644 --- a/frontend-v2/src/features/projects/Project.tsx +++ b/frontend-v2/src/features/projects/Project.tsx @@ -160,7 +160,6 @@ const ProjectRow: FC = ({ () => dispatch(decrementDirtyCount()), ); } - console.log('project', project, data.project) if (JSON.stringify(project) !== JSON.stringify(data.project)) { dispatch(incrementDirtyCount()); updateProject({ id: project.id, project: data.project }).then(() => @@ -173,9 +172,15 @@ const ProjectRow: FC = ({ ); const onCancel = () => { - setValue('project.description', project.description); + setValue("project.description", project.description); }; + const onShareCanel = () => { + setValue("project.user_access", project.user_access); + setUserAccessOpen(false); + setIsEditMode(false); + } + if (isLoading) { return
Loading...
; } @@ -341,7 +346,10 @@ const ProjectRow: FC = ({ setUserAccessOpen(true)} + onClick={() => { + setIsEditMode(true); + setUserAccessOpen(true); + }} disabled={isSharedWithMe} > @@ -352,15 +360,6 @@ const ProjectRow: FC = ({ - {isSharedWithMe && (
@@ -402,6 +401,16 @@ const ProjectRow: FC = ({ )} + {isDescriptionModalOpen && ( = ({ project={project} > void; remove: (index: number) => void; + onCancel: () => void; control: Control; onClose: () => void; } @@ -41,7 +42,7 @@ const UserAccess: FC = ({ userAccess, append, remove, - control, + onCancel, onClose, }) => { const { data: users } = useUserListQuery(); @@ -122,6 +123,13 @@ const UserAccess: FC = ({ margin: ".5rem", }} > +