Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
DEX-922 implement stickyHeader and add a meaningful maxHeight to ever… (
Browse files Browse the repository at this point in the history
#430)

* DEX-922 implement stickyHeader and add a meaningful maxHeight to every DataDisplay. Also add horizontalScroll

* DEX-922 remove seemingly unnecessary horizontal scroll prop

* DEX-922 respond to code review feedback. Remove default maxHeight for Card component and replaced with optional styles, which was then implemented for ImageCard and StatusCard. Remove maxHeight from Card in relationshipCard, remove unused paperStyles from DataDisplay.

* DEX-922 respond to code review feedback pt 2

* DEX-922 add tableContainerStyles to DataDisplay and remove maxHeight

* DEX-922 remove tableContainerStyles from SightingsDisplay and fix a few little things

* DEX-922 final little fixes
  • Loading branch information
Atticus29 authored Jul 25, 2022
1 parent b691776 commit e7dd5af
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/components/IndividualSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function IndividualSelector({
{canShowTable && (
<DataDisplay
idKey="guid"
paperStyles={{ maxHeight: 360 }}
tableContainerStyles={{ maxHeight: 360 }}
style={{ marginTop: 12 }}
noTitleBar
variant="secondary"
Expand Down
5 changes: 1 addition & 4 deletions src/components/cards/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default function Card({
title,
titleId,
htmlId = null,
maxHeight = 360,
overflow = 'auto',
overflowX = 'auto',
renderActions,
Expand Down Expand Up @@ -35,9 +34,7 @@ export default function Card({
</Text>
{renderActions}
</div>
<div style={{ overflow, maxHeight, overflowX }}>
{children}
</div>
<div style={{ overflow, overflowX }}>{children}</div>
</Paper>
</Grid>
);
Expand Down
15 changes: 10 additions & 5 deletions src/components/cards/CollaborationsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ export default function CollaborationsCard({
htmlId = null,
}) {
const intl = useIntl();
const [activeCollaboration, setActiveCollaboration] =
useState(null);
const [activeCollaboration, setActiveCollaboration] = useState(
null,
);
const [
collabDialogButtonClickLoading,
setCollabDialogButtonClickLoading,
] = useState(false);

const { data, loading } = useGetMe();

useEffect(() => {
setCollabDialogButtonClickLoading(false);
}, [data]);
useEffect(
() => {
setCollabDialogButtonClickLoading(false);
},
[data],
);

const collaborations = get(data, ['collaborations'], []);
const tableData = collaborations.map(collaboration => {
Expand Down Expand Up @@ -139,6 +143,7 @@ export default function CollaborationsCard({
columns={columns}
data={tableData}
idKey="guid"
tableContainerStyles={{ maxHeight: 600 }}
/>
</Card>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/cards/CooccurrenceCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function CooccurrenceCard({
},
]}
data={data}
tableContainerStyles={{ maxHeight: 600 }}
/>
</Card>
);
Expand Down
30 changes: 17 additions & 13 deletions src/components/cards/EncountersCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ export default function EncountersCard({
const mapModeClicked = () => setShowMapView(true);
const listModeClicked = () => setShowMapView(false);

const encountersWithLocationData = useMemo(() => {
// hotfix //
if (!encounters) return [];
// hotfix //
const encountersWithLocationData = useMemo(
() => {
// hotfix //
if (!encounters) return [];
// hotfix //

return encounters.map(encounter => ({
...encounter,
formattedLocation: formatLocationFromSighting(
encounter,
regionOptions,
intl,
),
}));
}, [get(encounters, 'length')]);
return encounters.map(encounter => ({
...encounter,
formattedLocation: formatLocationFromSighting(
encounter,
regionOptions,
intl,
),
}));
},
[get(encounters, 'length')],
);

const tooFewEncounters = encounters.length <= 1;

Expand Down Expand Up @@ -162,6 +165,7 @@ export default function EncountersCard({
columns={filteredColumns}
data={encountersWithLocationData}
tableStyles={{ tableLayout: 'fixed' }}
tableContainerStyles={{ maxHeight: 600 }}
/>
)}
{!noEncounters && showMapView && <div>Map goes here</div>}
Expand Down
2 changes: 1 addition & 1 deletion src/components/cards/RelationshipsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export default function RelationshipsCard({
</div>
</DialogActions>
</StandardDialog>,
<Card title={title} titleId={titleId} maxHeight={600}>
<Card title={title} titleId={titleId}>
{/* // renderActions={
// <div>
// <IconButton
Expand Down
30 changes: 17 additions & 13 deletions src/components/cards/SightingsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ export default function SightingsCard({
const mapModeClicked = () => setShowMapView(true);
const listModeClicked = () => setShowMapView(false);

const sightingsWithLocationData = useMemo(() => {
// hotfix //
if (!sightings) return [];
// hotfix //
const sightingsWithLocationData = useMemo(
() => {
// hotfix //
if (!sightings) return [];
// hotfix //

return sightings.map(sighting => ({
...sighting,
formattedLocation: formatLocationFromSighting(
sighting,
regionOptions,
intl,
),
}));
}, [get(sightings, 'length')]);
return sightings.map(sighting => ({
...sighting,
formattedLocation: formatLocationFromSighting(
sighting,
regionOptions,
intl,
),
}));
},
[get(sightings, 'length')],
);

const allColumns = [
{
Expand Down Expand Up @@ -149,6 +152,7 @@ export default function SightingsCard({
data={sightings}
loading={loading}
noResultsTextId={noSightingsMsg}
tableContainerStyles={{ maxHeight: 400 }}
/>
)}
{!noSightings && showMapView && (
Expand Down
11 changes: 7 additions & 4 deletions src/components/dataDisplays/DataDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ export default function DataDisplay({
sortExternally,
searchParams,
setSearchParams,
paperStyles = {},
tableStyles = {},
cellStyles = {},
stickyHeader = true,
tableContainerStyles = {},
...rest
}) {
const intl = useIntl();
Expand All @@ -80,8 +81,9 @@ export default function DataDisplay({
);
const [filter, setFilter] = useState('');
const [internalSortColumn, setInternalSortColumn] = useState(null);
const [internalSortDirection, setInternalSortDirection] =
useState(null);
const [internalSortDirection, setInternalSortDirection] = useState(
null,
);
const [anchorEl, setAnchorEl] = useState(null);
const filterPopperOpen = Boolean(anchorEl);

Expand Down Expand Up @@ -258,9 +260,10 @@ export default function DataDisplay({
<TableContainer
component={variant === 'secondary' ? Paper : undefined}
elevation={variant === 'secondary' ? 2 : undefined}
style={paperStyles}
style={tableContainerStyles}
>
<Table
stickyHeader={stickyHeader}
style={{ minWidth: 10, ...tableStyles }}
size={tableSize}
aria-label={title}
Expand Down
1 change: 1 addition & 0 deletions src/components/dataDisplays/RelationshipDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function RelationshipDisplay({
columns={relationshipCols}
data={data}
loading={loading}
tableContainerStyles={{ maxHeight: 400 }}
/>
);
}
1 change: 1 addition & 0 deletions src/pages/assetGroup/AGSTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function AGSTable({ assetGroupSightings }) {
data={transformedData}
columns={columns}
style={{ marginTop: 20 }}
tableContainerStyles={{ maxHeight: 600 }}
/>
);
}
1 change: 1 addition & 0 deletions src/pages/fieldManagement/settings/CategoryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export default function FieldSettings() {
variant="secondary"
columns={categoryColumns}
data={categories}
tableContainerStyles={{ maxHeight: 300 }}
/>
</Grid>
);
Expand Down
14 changes: 10 additions & 4 deletions src/pages/fieldManagement/settings/CustomFieldTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export default function CustomFieldTable({
const intl = useIntl();
const [deleteField, setDeleteField] = useState(null);
const [previewField, setPreviewField] = useState(null);
const [previewInitialValue, setPreviewInitialValue] =
useState(null);
const [previewInitialValue, setPreviewInitialValue] = useState(
null,
);
const {
removeCustomField,
needsForce,
Expand Down Expand Up @@ -101,7 +102,9 @@ export default function CustomFieldTable({
/>
<ActionIcon
variant="edit"
href={`/admin/fields/save-custom-field/${fieldTypeName}/${field.id}`}
href={`/admin/fields/save-custom-field/${fieldTypeName}/${
field.id
}`}
/>
<ActionIcon
variant="delete"
Expand Down Expand Up @@ -162,7 +165,9 @@ export default function CustomFieldTable({
<Text variant="h5" component="h5" id={titleId} />
<Tooltip
placement="bottom-end"
title={intl.formatMessage({ id: addButtonTooltipId })}
title={intl.formatMessage({
id: addButtonTooltipId,
})}
>
<span>
<ButtonLink
Expand All @@ -188,6 +193,7 @@ export default function CustomFieldTable({
columns={tableColumns}
data={fieldSchemas}
noResultsTextId={noFieldsTextId}
tableContainerStyles={{ maxHeight: 300 }}
/>
</Grid>
);
Expand Down
1 change: 1 addition & 0 deletions src/pages/fieldManagement/settings/DefaultFieldTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export default function DefaultFieldTable({
variant="secondary"
columns={tableColumns}
data={configurableFields}
tableContainerStyles={{ maxHeight: 300 }}
/>
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ export default function SpeciesEditor({
)}
<DataDisplay
cellStyles={{ padding: '0 8px 0 12px' }}
paperStyles={{ maxHeight: 360 }}
style={{ marginTop: 12 }}
noTitleBar
variant="secondary"
columns={tableColumns}
data={searchResults || suggestedValues}
idKey="itisTsn"
tableContainerStyles={{ maxHeight: 300 }}
/>
<Text
component="p"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/match/ImageCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ImageCard({ titleId, annotation }) {
);

return (
<Card titleId={titleId} maxHeight="unset">
<Card titleId={titleId}>
<AnnotatedPhotograph
assetMetadata={{
alt: 'Selected query annotation',
Expand Down
4 changes: 3 additions & 1 deletion src/pages/match/MatchCandidatesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export default function MatchCandidatesTable({
<DataDisplay
idKey="guid"
titleId="CANDIDATE_ANNOTATIONS"
data={matchCandidates} // variant="secondary"
data={matchCandidates}
columns={columns}
// variant="secondary"
noResultsTextId="NO_MATCH_CANDIDATES"
hideDownloadCsv
hideFilterColumns
Expand All @@ -71,6 +72,7 @@ export default function MatchCandidatesTable({
setSelectedMatchCandidate(nextSelection);
}
}}
tableContainerStyles={{ maxHeight: 300 }}
/>
);
}
1 change: 1 addition & 0 deletions src/pages/match/QueryAnnotationsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function QueryAnnotationsTable({
setSelectedQueryAnnotation(nextSelection);
}
}}
tableContainerStyles={{ maxHeight: 300 }}
/>
);
}
2 changes: 1 addition & 1 deletion src/pages/sighting/statusCard/StatusCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default function StatusCard({ sightingData }) {
}

return (
<Card titleId="IDENTIFICATION_PIPELINE_STATUS" maxHeight={900}>
<Card titleId="IDENTIFICATION_PIPELINE_STATUS">
<Timeline>
<TimelineStep
Icon={ReportIcon}
Expand Down
1 change: 1 addition & 0 deletions src/pages/userManagement/UserEditTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default function UserEditTable() {
columns={tableColumns}
data={activeUsers}
loading={loading}
tableContainerStyles={{ maxHeight: 500 }}
/>
{usersError ? (
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export default function UserManagersCollaborationEditTable({
}) {
const intl = useIntl();

const { data: currentUserData, loading: userDataLoading } =
useGetMe();
const {
data: currentUserData,
loading: userDataLoading,
} = useGetMe();

const {
mutate: revokeCollab,
Expand Down Expand Up @@ -199,6 +201,7 @@ export default function UserManagersCollaborationEditTable({
columns={tableColumns}
data={tableFriendlyData || []}
noResultsTextId="NO_COLLABORATIONS_MESSAGE"
tableContainerStyles={{ maxHeight: 500 }}
/>
{collaborationError ? (
<Text
Expand Down

0 comments on commit e7dd5af

Please sign in to comment.