Skip to content

Commit 0ab6693

Browse files
authored
1084 allow selecting multiple ai categories from dropdown (#1092)
* feat: for table filters, open options by default and persist input * feat: removed unused properties and moved chips to top of table
1 parent 1375162 commit 0ab6693

File tree

2 files changed

+62
-49
lines changed

2 files changed

+62
-49
lines changed

compose/neurosynth-frontend/src/pages/Curation/components/CurationBoardAIInterfaceCuratorTable.tsx

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,44 @@ const CurationBoardAIInterfaceCuratorTable: React.FC<ICurationBoardAIInterfaceCu
122122
allowAIColumns={prismaPhase !== 'identification'}
123123
/>
124124
</Box>
125+
<Box
126+
sx={{
127+
maxWidth: '100%',
128+
width: '100%',
129+
overflow: 'hidden',
130+
}}
131+
>
132+
<Box sx={{ display: 'flex', overflowX: 'scroll', scrollbarColor: '#c1c1c1 white' }}>
133+
{columnFilters
134+
.filter((filter) => !!filter.value)
135+
.map((filter) => (
136+
<Chip
137+
onDelete={() =>
138+
table.setColumnFilters((prev) => prev.filter((f) => f.id !== filter.id))
139+
}
140+
key={filter.id}
141+
variant="outlined"
142+
color="secondary"
143+
sx={{ margin: '0px 2px', fontSize: '10px', maxWidth: '200px', height: '18px' }}
144+
label={`Filtering ${filter.id.toUpperCase()}: ${filter.value}`}
145+
size="small"
146+
/>
147+
))}
148+
{sorting.map((sort) => (
149+
<Chip
150+
key={sort.id}
151+
onDelete={() => {
152+
table.setSorting((prev) => prev.filter((f) => f.id !== sort.id));
153+
}}
154+
variant="filled"
155+
color="secondary"
156+
sx={{ margin: '0px 2px', fontSize: '10px', maxWidth: '200px', height: '18px' }}
157+
label={`Sorting by ${sort.id.toUpperCase()}: ${sort.desc ? 'desc' : 'asc'}`}
158+
size="small"
159+
/>
160+
))}
161+
</Box>
162+
</Box>
125163
<TableContainer
126164
ref={tableContainerRef}
127165
id="scroller"
@@ -181,44 +219,6 @@ const CurationBoardAIInterfaceCuratorTable: React.FC<ICurationBoardAIInterfaceCu
181219
</Typography>
182220
)}
183221
</TableContainer>
184-
<Box
185-
sx={{
186-
maxWidth: '100%',
187-
width: '100%',
188-
overflow: 'hidden',
189-
}}
190-
>
191-
<Box sx={{ display: 'flex', overflowX: 'scroll', scrollbarColor: '#c1c1c1 white' }}>
192-
{columnFilters
193-
.filter((filter) => !!filter.value)
194-
.map((filter) => (
195-
<Chip
196-
onDelete={() =>
197-
table.setColumnFilters((prev) => prev.filter((f) => f.id !== filter.id))
198-
}
199-
key={filter.id}
200-
variant="outlined"
201-
color="secondary"
202-
sx={{ margin: '0px 2px', fontSize: '10px', maxWidth: '200px', height: '18px' }}
203-
label={`Filtering ${filter.id.toUpperCase()}: ${filter.value}`}
204-
size="small"
205-
/>
206-
))}
207-
{sorting.map((sort) => (
208-
<Chip
209-
key={sort.id}
210-
onDelete={() => {
211-
table.setSorting((prev) => prev.filter((f) => f.id !== sort.id));
212-
}}
213-
variant="filled"
214-
color="secondary"
215-
sx={{ margin: '0px 2px', fontSize: '10px', maxWidth: '200px', height: '18px' }}
216-
label={`Sorting by ${sort.id.toUpperCase()}: ${sort.desc ? 'desc' : 'asc'}`}
217-
size="small"
218-
/>
219-
))}
220-
</Box>
221-
</Box>
222222
</Box>
223223
);
224224
};

compose/neurosynth-frontend/src/pages/Curation/components/CurationBoardAIInterfaceCuratorTableHeaderFilterNestedAutocomplete.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Autocomplete, Box, ListItem, ListItemText, TextField } from '@mui/material';
1+
import { Autocomplete, Box, Chip, ListItem, ListItemText, TextField } from '@mui/material';
22
import { AccessorFn, Row } from '@tanstack/react-table';
3-
import { useMemo } from 'react';
3+
import { useMemo, useState } from 'react';
44
import { flattenColumnValues } from '../hooks/useCuratorTableState.helpers';
55
import { ICurationTableColumnType, ICurationTableStudy } from '../hooks/useCuratorTableState.types';
66

@@ -10,6 +10,8 @@ const CurationBoardAIInterfaceCuratorTableHeaderFilterNestedAutocomplete: React.
1010
value: string[] | undefined;
1111
onChange: (newVal: string[] | undefined) => void;
1212
}> = ({ rows, onChange, value, accessorFn }) => {
13+
const [inputValue, setInputValue] = useState('');
14+
1315
// note that for this data, we only expect column data to be a string or an object
1416
const uniqueValuesForColumn = useMemo(() => {
1517
if (!accessorFn) return [];
@@ -34,25 +36,36 @@ const CurationBoardAIInterfaceCuratorTableHeaderFilterNestedAutocomplete: React.
3436
}, [accessorFn, rows]);
3537

3638
return (
37-
<Box sx={{ padding: '0.5rem' }}>
39+
<Box>
3840
<Autocomplete
3941
size="small"
42+
open
4043
renderInput={(params) => (
41-
<TextField
42-
{...params}
43-
sx={{
44-
width: '200px',
45-
input: { fontSize: '12px' },
46-
}}
47-
placeholder="filter"
48-
/>
44+
<TextField {...params} sx={{ width: '200px', input: { fontSize: '12px' } }} placeholder="filter" />
4945
)}
5046
onChange={(_event, value) => {
5147
onChange(value.length === 0 ? undefined : value);
5248
}}
5349
value={value || []}
50+
inputValue={inputValue}
51+
onInputChange={(event, value, reason) => {
52+
if (event && event.type === 'blur') {
53+
setInputValue('');
54+
} else if (reason !== 'reset') {
55+
setInputValue(value);
56+
}
57+
}}
5458
options={uniqueValuesForColumn}
5559
multiple
60+
slotProps={{
61+
popper: { disablePortal: true },
62+
paper: { sx: { fontSize: '12px' } },
63+
}}
64+
renderTags={(value, getTagProps) =>
65+
value.map((option, index) => (
66+
<Chip label={option} sx={{ fontSize: '12px' }} size="small" {...getTagProps({ index })} />
67+
))
68+
}
5669
renderOption={(props, option) => (
5770
<ListItem {...props} key={option}>
5871
<ListItemText primary={option} primaryTypographyProps={{ fontSize: '12px' }} />

0 commit comments

Comments
 (0)