-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added server-side text search for curated lists on data lists page (#18)
- Loading branch information
Showing
7 changed files
with
112 additions
and
43 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
export default async (self, args, ctx) => { | ||
export default async (self, { filter: $search }, ctx) => { | ||
const filter = $search ? { $text: { $search, $caseSensitive: false } } : {} | ||
const { Lists } = await ctx.mongo.collections | ||
const lists = Lists.find({ type: 'curated' }).sort({ title: 1 }) | ||
const lists = Lists.find({ type: 'curated', ...filter }).sort({ | ||
title: 1, | ||
}) | ||
return await lists.toArray() | ||
} |
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
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,56 @@ | ||
import { useContext } from 'react' | ||
import { context as filterContext } from '../../context' | ||
import TextField from '@mui/material/TextField' | ||
import InputAdornment from '@mui/material/InputAdornment' | ||
import { Magnify as SearchIcon } from '../../../../components/icons' | ||
import QuickForm from '../../../../components/quick-form' | ||
import debounce from '../../../../lib/fns/debounce' | ||
import useMediaQuery from '@mui/material/useMediaQuery' | ||
|
||
export default () => { | ||
const smUp = useMediaQuery(theme => theme.breakpoints.up('sm')) | ||
const { filter, setFilter } = useContext(filterContext) | ||
|
||
return ( | ||
<QuickForm text={filter} effects={[debounce(({ text }) => setFilter(text), 500)]}> | ||
{(update, { text }) => { | ||
return ( | ||
<TextField | ||
autoComplete="off" | ||
fullWidth | ||
id="saeon-data-search" | ||
size="small" | ||
onChange={e => update({ text: e.target.value })} | ||
variant="standard" | ||
InputProps={{ | ||
startAdornment: ( | ||
<InputAdornment position="start"> | ||
<SearchIcon fontSize="small" /> | ||
</InputAdornment> | ||
), | ||
inputProps: { | ||
'aria-label': 'Enter search text and press enter', | ||
sx: { | ||
p: 0, | ||
lineHeight: '100%', | ||
}, | ||
}, | ||
}} | ||
value={text} | ||
margin="none" | ||
placeholder={smUp ? 'Filter lists ...' : ''} | ||
sx={{ | ||
backgroundColor: theme => theme.palette.grey[200], | ||
p: theme => theme.spacing(0.5), | ||
'& .MuiInput-root': { | ||
'&:before, :after, :hover:not(.Mui-disabled):before': { | ||
borderBottom: 0, | ||
}, | ||
}, | ||
}} | ||
/> | ||
) | ||
}} | ||
</QuickForm> | ||
) | ||
} |
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
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