Skip to content

Commit

Permalink
feat: add data type filter
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Nov 15, 2024
1 parent 79aac19 commit e0074a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/data_search/DatasetFilterList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const DatasetFilterList = (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 dataTypeFilters = uniq(flatten(datasets.map((dataset) => dataset.study.dataTypes)));
const dacFilters = orderBy(uniq(compact(datasets.map((dataset) => dataset.dac?.dacName))), (dac) => dac.toLowerCase(), 'asc');

return (
Expand Down Expand Up @@ -84,6 +85,15 @@ export const DatasetFilterList = (props) => {
isFiltered={isFiltered}
filterNameFn={(filter) => filter}
/>
<FilterItemHeader title="Data Type" />
<FilterItemList
category="dataType"
datasets={datasets}
filter={dataTypeFilters}
filterHandler={filterHandler}
isFiltered={isFiltered}
filterNameFn={(filter) => filter}
/>
</Box>
);
};
Expand Down
12 changes: 12 additions & 0 deletions src/components/data_search/DatasetSearchTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const styles = {
const defaultFilters = {
accessManagement: [],
dataUse: [],
dataType: [],
dac: [],
search: []
};
Expand Down Expand Up @@ -133,6 +134,17 @@ export const DatasetSearchTable = (props) => {
}
});

filterTerms.push({
'bool': {
'should':
filters.dataType.map(term => ({
'match': {
'study.dataTypes': term
}
}))
}
});

filterTerms.push({
'bool': {
'should':
Expand Down

0 comments on commit e0074a3

Please sign in to comment.