-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic Post + Problem search and filter
- Loading branch information
1 parent
63e91ac
commit a8d58c3
Showing
5 changed files
with
93 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {FilterList as FilterListIcon} from '@mui/icons-material' | ||
import {IconButton, Stack} from '@mui/material' | ||
import {FC, PropsWithChildren, useState} from 'react' | ||
import {FilterLiveSearch} from 'react-admin' | ||
|
||
export const FilterSidebar: FC<PropsWithChildren> = ({children}) => { | ||
const [filterOpen, setFilterOpen] = useState(true) | ||
const toggleFilter = () => setFilterOpen((prev) => !prev) | ||
|
||
return ( | ||
// TODO: fix collapsed state | ||
<Stack sx={{order: -1, mr: 2, alignItems: 'start'}}> | ||
<IconButton onClick={toggleFilter} sx={{m: 0.5}}> | ||
<FilterListIcon /> | ||
</IconButton> | ||
|
||
<Stack | ||
sx={{ | ||
width: 200, | ||
color: 'unset', | ||
bgcolor: 'unset', | ||
display: filterOpen ? 'block' : 'none', | ||
}} | ||
> | ||
<FilterLiveSearch /> | ||
{children} | ||
</Stack> | ||
</Stack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
import {FC} from 'react' | ||
import {Datagrid, FunctionField, List, RaRecord, TextField} from 'react-admin' | ||
import {Datagrid, FilterList, FilterListItem, FunctionField, List, RaRecord, TextField} from 'react-admin' | ||
|
||
import {DateTimeField} from '@/components/Admin/custom/DateTimeField' | ||
import {FilterSidebar} from '@/components/Admin/custom/FilterSidebar' | ||
import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' | ||
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' | ||
import {seminarIds, seminarIdToName} from '@/utils/useSeminarInfo' | ||
|
||
export const PostList: FC = () => ( | ||
<List> | ||
<List aside={<PostListFilters />}> | ||
<Datagrid> | ||
<TextField source="caption" /> | ||
<TruncatedTextField source="short_text" maxTextWidth={50} /> | ||
<TruncatedTextField source="details" maxTextWidth={50} /> | ||
<TextField source="caption" sortable={false} /> | ||
<TruncatedTextField source="short_text" maxTextWidth={50} sortable={false} /> | ||
<TruncatedTextField source="details" maxTextWidth={50} sortable={false} /> | ||
<DateTimeField source="added_at" /> | ||
<DateTimeField source="visible_after" /> | ||
<DateTimeField source="visible_until" /> | ||
<SitesArrayField source="sites" /> | ||
<SitesArrayField source="sites" sortable={false} /> | ||
<FunctionField<RaRecord> | ||
source="links" | ||
label="Link count" | ||
render={(record) => record && <span>{record['links'].length}</span>} | ||
sortable={false} | ||
/> | ||
</Datagrid> | ||
</List> | ||
) | ||
|
||
const PostListFilters: FC = () => ( | ||
<FilterSidebar> | ||
<FilterList label="Seminár" icon={null}> | ||
{seminarIds.map((seminarId) => ( | ||
<FilterListItem key={seminarId} label={seminarIdToName[seminarId]} value={{sites: seminarId}} /> | ||
))} | ||
</FilterList> | ||
</FilterSidebar> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters