diff --git a/src/common/api/collectionsApi.ts b/src/common/api/collectionsApi.ts index bc5129f8..b0ade21e 100644 --- a/src/common/api/collectionsApi.ts +++ b/src/common/api/collectionsApi.ts @@ -197,6 +197,13 @@ export type ColumnMeta = { max_value: undefined; enum_values: string[]; } + | { + type: 'bool'; + filter_strategy: undefined; + min_value: undefined; + max_value: undefined; + enum_values: undefined; + } ); interface CollectionsResults { diff --git a/src/common/components/FilterChip.tsx b/src/common/components/FilterChip.tsx index 521017e0..f6a89365 100644 --- a/src/common/components/FilterChip.tsx +++ b/src/common/components/FilterChip.tsx @@ -18,7 +18,7 @@ export const FilterChip = ({ ...chipProps }: FilterChipProps) => { let filterString = ''; - if (filter.value) { + if (filter.value !== undefined && filter.value !== null) { if ( filter.type === 'date' || filter.type === 'int' || @@ -30,6 +30,8 @@ export const FilterChip = ({ }) .map((val) => val.toLocaleString()); filterString = `${minString} to ${maxString}`; + } else if (filter.type === 'bool') { + filterString = Boolean(filter.value).toString(); } else { const val = filter.value; if (typeof val === 'string') { diff --git a/src/features/collections/CollectionDetail.tsx b/src/features/collections/CollectionDetail.tsx index 2dde7f64..19d194ee 100644 --- a/src/features/collections/CollectionDetail.tsx +++ b/src/features/collections/CollectionDetail.tsx @@ -41,11 +41,15 @@ import { Accordion, AccordionSummary, AccordionDetails, + FormControl, + Select, + MenuItem, + SelectChangeEvent, } from '@mui/material'; import { useForm } from 'react-hook-form'; import { CollectionOverview } from './CollectionOverview'; import { FilterChip } from '../../common/components/FilterChip'; -import { FilterContextTabs } from './Filters'; +import { filterContextScope, FilterContextTabs } from './Filters'; export const detailPath = ':id'; export const detailDataProductPath = ':id/:data_product'; @@ -63,8 +67,8 @@ const pageConfig: Record< } > = { samples: { features: ['filter'] }, - biolog: { features: [] }, - microtrait: { features: [] }, + biolog: { features: ['filter'] }, + microtrait: { features: ['filter'] }, genome_attribs: { features: ['filter', 'match', 'search'], }, @@ -178,7 +182,8 @@ export const CollectionDetail = () => { !filter || filter.type === 'int' || filter.type === 'float' || - filter.type === 'date' + filter.type === 'date' || + filter.type === 'bool' ) return; if (e.target.value === filter.value) return; @@ -401,6 +406,7 @@ const useFilterEntries = (collectionId: string) => { }; const FilterChips = ({ collectionId }: { collectionId: string }) => { + const { columnMeta } = useFilters(collectionId); const { filterEntries, clearFilterState, context } = useFilterEntries(collectionId); if (filterEntries.length === 0) return <>; @@ -411,7 +417,7 @@ const FilterChips = ({ collectionId }: { collectionId: string }) => { clearFilterState(column)} /> ); @@ -451,11 +457,19 @@ const FilterMenu = ({ setExpandedCategory(expanded ? category : ''); }; + const menuLabel = { + DEFAULT: 'Filters', + genomes: 'Genome Filters', + samples: 'Sample Filters', + biolog: 'Biolog Filters', + microtrait: 'Microtrait Filters', + }[filterContextScope(context) || 'DEFAULT']; + if (open) { return (
-

Genome Filters

+

{menuLabel}