diff --git a/src/components/explore/explore-tools.js b/src/components/explore/explore-tools.js index 51d385b7..c7fd5b03 100644 --- a/src/components/explore/explore-tools.js +++ b/src/components/explore/explore-tools.js @@ -290,6 +290,14 @@ const ExploreTools = React.forwardRef( label="Measurement Type" options={getFilterOptionsById("type")} /> + + )} diff --git a/src/pages/explore/instruments.js b/src/pages/explore/instruments.js index 9dd1d197..6bbc1338 100644 --- a/src/pages/explore/instruments.js +++ b/src/pages/explore/instruments.js @@ -19,6 +19,7 @@ export default function ExploreInstruments({ data, location }) { const { allInstrument, allMeasurementType, + allMeasurementStyle, allMeasurementRegion, allCampaign, allPlatform, @@ -64,7 +65,9 @@ export default function ExploreInstruments({ data, location }) { const { getFilterLabelById, getFilterOptionsById } = selector({ type: allMeasurementType, + style: allMeasurementStyle, vertical: allMeasurementRegion, + platform: allPlatform, }) return ( @@ -145,6 +148,20 @@ export const query = graphql` longname: long_name } } + allMeasurementStyle { + options: nodes { + id + shortname: short_name + longname: long_name + } + } + allPlatform { + options: nodes { + id + shortname: short_name + longname: long_name + } + } allMeasurementRegion { options: nodes { id @@ -170,6 +187,12 @@ export const query = graphql` measurementType: measurement_type { id # required for filter } + measurementStyle: measurement_style { + id # required for filter + } + platforms: platforms { + id + } measurementRegions: measurement_regions { id # required for filter } @@ -185,6 +208,14 @@ const instrumentShape = PropTypes.shape({ measurementType: PropTypes.shape({ id: PropTypes.string.isRequired, }), + measurementStyle: PropTypes.shape({ + id: PropTypes.string.isRequired, + }), + platforms: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + }).isRequired + ), measurementRegions: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string.isRequired, @@ -214,6 +245,7 @@ ExploreInstruments.propTypes = { list: PropTypes.arrayOf(instrumentShape).isRequired, }), allMeasurementType: filterOptionShape, + allMeasurementStyle: filterOptionShape, allMeasurementRegion: filterOptionShape, allCampaign: PropTypes.shape({ totalCount: PropTypes.number.isRequired, diff --git a/src/pages/explore/products.js b/src/pages/explore/products.js index 18a5d0f1..d280dcf8 100644 --- a/src/pages/explore/products.js +++ b/src/pages/explore/products.js @@ -246,7 +246,7 @@ export default function ExploreProducts({ data, location }) { }, { values: [], set: new Set() } ).values - console.log({ allCampaignPlatformInstruments }) + const { getFilterLabelById, getFilterOptionsById } = selector({ measurement: { options: allMeasurementTypes }, style: { options: allMeasurementStyles }, diff --git a/src/utils/filter-utils.js b/src/utils/filter-utils.js index 2994fa2f..31e37e54 100644 --- a/src/utils/filter-utils.js +++ b/src/utils/filter-utils.js @@ -215,15 +215,18 @@ export function platformFilter(selectedFilterIds) { } export function instrumentFilter(selectedFilterIds) { - return instrument => - selectedFilterIds.length === 0 + return instrument => { + return selectedFilterIds.length === 0 ? true : selectedFilterIds.every( filterId => (instrument.measurementType && instrument.measurementType.id === filterId) || + (instrument.measurementStyle?.id ?? 0) === filterId || + instrument.platforms.map(x => x.id).includes(filterId) || instrument.measurementRegions.map(x => x.id).includes(filterId) ) + } } export function doiFilter(selectedFilterIds) {