Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI enhancements fixes #614

Merged
merged 5 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend-v2/src/features/drug/Drug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const Drug: FC = () => {
setIsEditIndex(isEdit ? index : null);
};

console.log("efficacy_experiments", efficacy_experiments);
console.log("units", units);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was left in my mistake

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, already removed


return (
<div style={{ display: "flex", flexDirection: "column" }}>
Expand Down Expand Up @@ -408,7 +408,9 @@ const Drug: FC = () => {
/>
) : (
<Typography>
{getValues(`efficacy_experiments.${index}.c50_unit`) ||
{units.find(
(u) => u.id === getValues(`efficacy_experiments.${index}.c50_unit`),
)?.symbol ||
"-"}
</Typography>
)}
Expand Down
42 changes: 24 additions & 18 deletions frontend-v2/src/features/projects/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ const ProjectRow: FC<Props> = ({
reset,
handleSubmit,
control,
setValue,
register,
formState: { isDirty },
} = useForm<FormData>({
defaultValues: { project, compound: defaultCompound },
Expand Down Expand Up @@ -169,15 +171,16 @@ const ProjectRow: FC<Props> = ({
[handleSubmit, compound, project, updateCompound, updateProject],
);

const [fieldValue, setFieldValue] = useFieldState({
name: "project.description",
control,
});

const onCancel = () => {
setFieldValue(project.description);
setValue("project.description", project.description);
};

const onShareCanel = () => {
setValue("project.user_access", project.user_access);
setUserAccessOpen(false);
setIsEditMode(false);
}

if (isLoading) {
return <div>Loading...</div>;
}
Expand Down Expand Up @@ -343,7 +346,10 @@ const ProjectRow: FC<Props> = ({

<Tooltip title="Share Project">
<IconButton
onClick={() => setUserAccessOpen(true)}
onClick={() => {
setIsEditMode(true);
setUserAccessOpen(true);
}}
disabled={isSharedWithMe}
>
<PersonAdd />
Expand All @@ -354,15 +360,6 @@ const ProjectRow: FC<Props> = ({
<Delete />
</IconButton>
</Tooltip>
<UserAccess
open={userAccessOpen}
onClose={userAccessClose}
control={control}
userAccess={userAccess as ProjectAccess[]}
append={append}
remove={remove}
project={project}
/>
{isSharedWithMe && (
<Tooltip title="This project is shared with me as view-only">
<div>
Expand Down Expand Up @@ -404,6 +401,16 @@ const ProjectRow: FC<Props> = ({
)}
</TableCell>
</TableRow>
<UserAccess
open={userAccessOpen}
onClose={userAccessClose}
onCancel={onShareCanel}
control={control}
userAccess={userAccess as ProjectAccess[]}
append={append}
remove={remove}
project={project}
/>
{isDescriptionModalOpen && (
<DescriptionModal
isOpen={isDescriptionModalOpen}
Expand All @@ -414,8 +421,7 @@ const ProjectRow: FC<Props> = ({
project={project}
>
<MaterialTextField
onChange={(event) => setFieldValue(event.target.value)}
value={fieldValue}
{...register("project.description")}
sx={{ width: "50vw" }}
disabled={!isEditMode}
multiline
Expand Down
10 changes: 9 additions & 1 deletion frontend-v2/src/features/projects/UserAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface Props {
userAccess: ProjectAccess[];
append: (value: ProjectAccess) => void;
remove: (index: number) => void;
onCancel: () => void;
control: Control<FormData>;
onClose: () => void;
}
Expand All @@ -41,7 +42,7 @@ const UserAccess: FC<Props> = ({
userAccess,
append,
remove,
control,
onCancel,
onClose,
}) => {
const { data: users } = useUserListQuery();
Expand Down Expand Up @@ -122,6 +123,13 @@ const UserAccess: FC<Props> = ({
margin: ".5rem",
}}
>
<Button
variant="outlined"
sx={{ marginLeft: "1rem" }}
onClick={onCancel}
>
Cancel
</Button>
<Button
variant="contained"
sx={{ marginLeft: "1rem" }}
Expand Down
1 change: 1 addition & 0 deletions frontend-v2/src/features/trial/Doses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const Doses: FC<Props> = ({ onChange, project, protocol, units }) => {
<TableRow key={dose.id}>
<TableCell>
<FloatField
sx={{ minWidth: '6rem'}}
size="small"
label={"Dose"}
name={`doses.${index}.amount`}
Expand Down