From eff371bf8cc293125d613cdad2d89259ebc77bf7 Mon Sep 17 00:00:00 2001 From: francesco Date: Tue, 25 May 2021 20:03:43 +0200 Subject: [PATCH] Fix for broken homepage additional views. Layout updates --- src/CMSRouterSwitch.tsx | 20 +++++---- src/collection/CollectionTableToolbar.tsx | 15 ++++--- src/collection/EntityCollectionTable.tsx | 21 ++++++--- src/collection/FilterPopup.tsx | 44 +++++++++++++------ src/routes/HomeRoute.tsx | 52 ++++++++++++----------- 5 files changed, 96 insertions(+), 56 deletions(-) diff --git a/src/CMSRouterSwitch.tsx b/src/CMSRouterSwitch.tsx index c4da0cb..9c961ce 100644 --- a/src/CMSRouterSwitch.tsx +++ b/src/CMSRouterSwitch.tsx @@ -16,13 +16,23 @@ export function CMSRouterSwitch({ collections, views }: { function buildCMSViewRoute(path: string, cmsView: CMSView) { return ; } + let customRoutes: JSX.Element[] = []; + if (views) { + views.forEach((cmsView) => { + if (Array.isArray(cmsView.path)) + customRoutes.push(...cmsView.path.map(path => buildCMSViewRoute(path, cmsView))); + else + customRoutes.push(buildCMSViewRoute(cmsView.path, cmsView)); + }); + } + return ( {[...collections] @@ -40,13 +50,7 @@ export function CMSRouterSwitch({ collections, views }: { ) )} - {views && - views.map(cmsView => { - if (Array.isArray(cmsView.path)) - return <>{cmsView.path.map(path => buildCMSViewRoute(path, cmsView))}; - return buildCMSViewRoute(cmsView.path, cmsView); - })} - + {customRoutes} diff --git a/src/collection/CollectionTableToolbar.tsx b/src/collection/CollectionTableToolbar.tsx index bc953df..9fec84a 100644 --- a/src/collection/CollectionTableToolbar.tsx +++ b/src/collection/CollectionTableToolbar.tsx @@ -18,7 +18,11 @@ const useStyles = makeStyles((theme: Theme) => createStyles({ toolbar: { minHeight: 56, - paddingLeft: theme.spacing(2), + [theme.breakpoints.down("md")]: { + paddingLeft: theme.spacing(.5), + paddingRight: theme.spacing(.5) + }, + paddingLeft: theme.spacing(1), paddingRight: theme.spacing(1), zIndex: 100, backgroundColor: theme.palette.background.paper, @@ -33,6 +37,9 @@ const useStyles = makeStyles((theme: Theme) => display: "flex", alignItems: "center", "& > *": { + [theme.breakpoints.down("md")]: { + marginRight: theme.spacing(.5) + }, marginRight: theme.spacing(1) } } @@ -169,10 +176,8 @@ export function CollectionTableToolbar, Key extends
- - {props.loading && - } - + {props.loading && + } {props.actions} diff --git a/src/collection/EntityCollectionTable.tsx b/src/collection/EntityCollectionTable.tsx index 4328d9e..b70be2a 100644 --- a/src/collection/EntityCollectionTable.tsx +++ b/src/collection/EntityCollectionTable.tsx @@ -312,22 +312,31 @@ export default function EntityCollectionTable, Key e ); const multipleDeleteEnabled = selectedEntities.every((entity) => canDelete(collectionConfig.permissions, authController.loggedUser, entity)); + const onMultipleDeleteClick = (event: React.MouseEvent) => { + event.stopPropagation(); + setDeleteEntityClicked(selectedEntities); + }; const multipleDeleteButton = selectionEnabled && - + } + + {!largeLayout && + + + } ; diff --git a/src/collection/FilterPopup.tsx b/src/collection/FilterPopup.tsx index 1355e24..42481c3 100644 --- a/src/collection/FilterPopup.tsx +++ b/src/collection/FilterPopup.tsx @@ -8,15 +8,12 @@ import PopupState, { bindPopover, bindTrigger } from "material-ui-popup-state"; import { Box, Button, - createStyles, IconButton, - makeStyles, Popover, Table, TableBody, TableCell as MuiTableCell, TableRow, - Theme, Tooltip, withStyles } from "@material-ui/core"; @@ -47,7 +44,12 @@ interface FilterPopupProps, Key extends string> { onFilterUpdate(filterValues?: FilterValues): void; } -export default function FilterPopup, Key extends string>({ schema, filterValues, onFilterUpdate, filterableProperties }: FilterPopupProps) { +export default function FilterPopup, Key extends string>({ + schema, + filterValues, + onFilterUpdate, + filterableProperties + }: FilterPopupProps) { function createFilterFields() { @@ -99,16 +101,23 @@ export default function FilterPopup, Key extends str popupState.close(); } - const clearSetFiltersView = - onFilterUpdate(undefined)}> - - - ; + const clearSetFiltersView = ( + + onFilterUpdate(undefined)}> + + + + ); return ( - + , Key extends str initialValues={cleanedInitialValues} onSubmit={setFilters} > - {({ values, resetForm, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting }) => { + {({ + values, + resetForm, + errors, + touched, + handleChange, + handleBlur, + handleSubmit, + isSubmitting + }) => { const reset = (e: any) => { resetForm(); setFilters(undefined); diff --git a/src/routes/HomeRoute.tsx b/src/routes/HomeRoute.tsx index 8354b90..396d7e7 100644 --- a/src/routes/HomeRoute.tsx +++ b/src/routes/HomeRoute.tsx @@ -119,31 +119,35 @@ function HomeRoute({ ; } - const groupViews - = allGroups.map((group, index) => ( - - - {group?.toUpperCase() ?? "Ungrouped".toUpperCase()} - - - - - {group && navigationEntries - .filter((entry) => entry.group === group) - .map((entry) => buildNavigationCard(entry)) - } - {!group && navigationEntries - .filter((entry) => !entry.group) - .map((entry) => buildNavigationCard(entry)) - } - - - - )); - return - {groupViews} - ; + return ( + + {allGroups.map((group, index) => ( + + {allGroups.length > 0 && <> + + {group?.toUpperCase() ?? "Ungrouped".toUpperCase()} + + + } + + + + {group && navigationEntries + .filter((entry) => entry.group === group) + .map((entry) => buildNavigationCard(entry)) + } + {!group && navigationEntries + .filter((entry) => !entry.group) + .map((entry) => buildNavigationCard(entry)) + } + + + + ))} + + ); } export default HomeRoute;