Skip to content
New issue

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

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

Already on GitHub? # to your account

CRDCDH-493 Org Management studies list tooltip fixes #187

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Changes from all 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
75 changes: 48 additions & 27 deletions src/content/organizations/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ const StyledTablePagination = styled(TablePagination)<{ component: React.Element
background: "#F5F7F8",
});

const StyledStudyCount = styled(Typography)<{ component: ElementType }>(({ theme }) => ({
textDecoration: "underline",
cursor: "pointer",
color: theme.palette.primary.main,
}));

const columns: Column[] = [
{
label: "Name",
Expand All @@ -174,33 +180,34 @@ const columns: Column[] = [
},
{
label: "Studies",
value: ({ _id, studies }) => (
<Stack direction="row">
<Typography variant="body1">
{studies?.slice(0, 2).map((s) => s.studyAbbreviation).join(", ")}
{studies?.length > 2 && ", ..."}
</Typography>
{studies?.length > 0 && (
<Tooltip
title={(
<Typography variant="body1">
{studies.map(({ studyName, studyAbbreviation }) => (
<React.Fragment key={`${_id}_study_${studyName}`}>
{studyName}
{" ("}
{studyAbbreviation}
{") "}
<br />
</React.Fragment>
))}
</Typography>
)}
placement="top"
arrow
/>
)}
</Stack>
),
value: ({ _id, studies }) => {
if (!studies || studies?.length < 1) {
return "";
}

return (
<>
{studies[0].studyAbbreviation}
{studies.length > 1 && " and "}
{studies.length > 1 && (
<Tooltip
title={<StudyContent _id={_id} studies={studies} />}
placement="top"
open={undefined}
onBlur={undefined}
disableHoverListener={false}
arrow
>
<StyledStudyCount variant="body2" component="span">
other
{" "}
{studies.length - 1}
</StyledStudyCount>
</Tooltip>
)}
</>
);
},
},
{
label: "Status",
Expand All @@ -219,6 +226,20 @@ const columns: Column[] = [
},
];

const StudyContent: FC<{ _id: Organization["_id"], studies: Organization["studies"] }> = ({ _id, studies }) => (
<Typography variant="body1">
{studies?.map(({ studyName, studyAbbreviation }) => (
<React.Fragment key={`${_id}_study_${studyName}`}>
{studyName}
{" ("}
{studyAbbreviation}
{") "}
<br />
</React.Fragment>
))}
</Typography>
);

/**
* View for List of Organizations
*
Expand Down