diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index f9f9392b8..530776bb6 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -8,13 +8,46 @@ import ListItemText from '@mui/material/ListItemText'; import Divider from '@mui/material/Divider'; import { Typography } from '@mui/material'; import { Checkbox } from '@mui/material'; -import { flatten, uniq, compact, capitalize } from 'lodash'; +import { flatten, uniq, compact, capitalize, orderBy } from 'lodash'; + +export const FilterItemHeader = (props) => { + const { title, headerStyle = { fontFamily: 'Montserrat', fontWeight: '600', marginTop: '1em' } } = props; + return ( + + {title} + + ); +} + +export const FilterItemList = (props) => { + const { category, datasets, filter, filterHandler, isFiltered, filterNameFn } = props; + return ( + + { + filter.map((filter) => { + const filterName = filterNameFn(filter); + return ( + + filterHandler(event, datasets, category, filter)}> + + + + + + + ); + }) + } + + ); +}; export const DatasetFilterList = (props) => { const { datasets, filters, filterHandler, isFiltered } = props; const accessManagementFilters = uniq(compact(datasets.map((dataset) => dataset.accessManagement))); const dataUseFilters = uniq(compact(flatten(datasets.map((dataset) => dataset.dataUse?.primary))).map((dataUse) => dataUse.code)); + const dacFilters = orderBy(uniq(compact(datasets.map((dataset) => dataset.dac?.dacName))), (dac) => dac.toLowerCase(), 'asc'); return ( @@ -22,48 +55,35 @@ export const DatasetFilterList = (props) => { Filters - - Access Type - - - { - accessManagementFilters.map((filter) => { - const filterName = capitalize(filter); - const category = 'accessManagement'; - return ( - - filterHandler(event, datasets, category, filter)}> - - - - - - - ); - }) - } - - - Primary Data Use - - - { - dataUseFilters.map((filter) => { - const filterName = filter.toUpperCase(); - const category = 'dataUse'; - return ( - - filterHandler(event, datasets, category, filter)}> - - - - - - - ); - }) - } - + + + + filter.toUpperCase()} + /> + Data Access Committee (DACs)} + headerStyle={{ fontFamily: 'Montserrat', marginTop: '1em' }} + /> + filter} + /> ); }; diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index 0cccff174..a67f29e57 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -35,6 +35,7 @@ const styles = { const defaultFilters = { accessManagement: [], dataUse: [], + dac: [], search: [] }; @@ -131,6 +132,17 @@ export const DatasetSearchTable = (props) => { } }); + filterTerms.push({ + 'bool': { + 'should': + filters.dac.map(term => ({ + 'match_phrase': { + 'dac.dacName': term + } + })) + } + }); + if (filterTerms.length > 0) { filterQuery = [ {