From 90f5d8ee1fd4fcdf2852a27398db2d75363c1da8 Mon Sep 17 00:00:00 2001 From: Alessandro Gasperini Date: Thu, 5 Dec 2024 17:54:56 +0100 Subject: [PATCH] DIGG-472: filter fix --- features/search/search-filters/index.tsx | 41 ++++-------------------- locales/en/resources.json | 2 +- locales/sv/resources.json | 2 +- utilities/entryscape/entryscape.ts | 18 +++++++++++ 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/features/search/search-filters/index.tsx b/features/search/search-filters/index.tsx index e34d5d28..913562cd 100644 --- a/features/search/search-filters/index.tsx +++ b/features/search/search-filters/index.tsx @@ -22,7 +22,7 @@ import { SearchFilter } from "@/features/search/search-filters/search-filter"; import { SearchContextData } from "@/providers/search-provider"; import { SettingsContext } from "@/providers/settings-provider"; import { SearchFacet, SearchFacetValue } from "@/types/search"; -import { ESRdfType, ESType } from "@/utilities/entryscape/entryscape"; +import { ESRdfType, ESType, checkBoxFilterConfigs } from "@/utilities/entryscape/entryscape"; import { SearchActiveFilters } from "./search-active-filters"; import { @@ -541,49 +541,22 @@ export const SearchFilters: FC = ({ ); - } else if (key === hvd) { + } else { + const filterConfig = checkBoxFilterConfigs[key]; return ( filter.id === "hvd_only", + (filter) => filter.id === filterConfig.id, )} onChange={() => doSearch(key, facetValues[0])} label={t(`resources|${key}`)} iconSize={iconSize} /> ); - } else if (key === national) { - return ( - filter.id === "national_only", - )} - onChange={() => doSearch(key, facetValues[0])} - label={t(`resources|${key}`)} - iconSize={iconSize} - /> - ); - } else if (key === spec) { - return ( - filter.id === "spec_only", - )} - onChange={() => doSearch(key, facetValues[0])} - label={t(`resources|${key}`)} - iconSize={iconSize} - /> - ); - } + } })} {searchMode == "datasets" && groupName == "distribution" && ( diff --git a/locales/en/resources.json b/locales/en/resources.json index 245a98ee..0af54288 100644 --- a/locales/en/resources.json +++ b/locales/en/resources.json @@ -16,11 +16,11 @@ "http://publications.europa.eu/resource/authority/data-theme/TRAN": "Transport", "http://purl.org/dc/terms/accessRights": "Access", "http://purl.org/dc/terms/accrualPeriodicity": "Update frequency", + "http://purl.org/dc/terms/conformsTo": "Follows specification", "http://purl.org/dc/terms/format": "Format", "http://purl.org/dc/terms/license": "License", "http://purl.org/dc/terms/publisher": "Organisation", "http://purl.org/dc/terms/subject": "National basic data", - "http://purl.org/dc/terms/conformsTo": "Follows specification", "http://purl.org/dc/terms/type": "Organisation type", "http://www.w3.org/2004/02/skos/core#inScheme": "Terminologies", "http://www.w3.org/ns/dcat#theme": "Theme", diff --git a/locales/sv/resources.json b/locales/sv/resources.json index 19f98c9b..90a0f5d6 100644 --- a/locales/sv/resources.json +++ b/locales/sv/resources.json @@ -16,11 +16,11 @@ "http://publications.europa.eu/resource/authority/data-theme/TRAN": "Transport", "http://purl.org/dc/terms/accessRights": "Åtkomsträttigheter", "http://purl.org/dc/terms/accrualPeriodicity": "Uppdateringsfrekvens", + "http://purl.org/dc/terms/conformsTo": "Följer specifikation", "http://purl.org/dc/terms/format": "Format", "http://purl.org/dc/terms/license": "Licens", "http://purl.org/dc/terms/publisher": "Organisation", "http://purl.org/dc/terms/subject": "Nationella grunddata", - "http://purl.org/dc/terms/conformsTo": "Följer specifikation", "http://purl.org/dc/terms/type": "Organisationstyp", "http://www.w3.org/2004/02/skos/core#inScheme": "Terminologier", "http://www.w3.org/ns/dcat#theme": "Kategori", diff --git a/utilities/entryscape/entryscape.ts b/utilities/entryscape/entryscape.ts index 09fc98bb..667864f8 100644 --- a/utilities/entryscape/entryscape.ts +++ b/utilities/entryscape/entryscape.ts @@ -56,6 +56,24 @@ export enum ESRdfType { spec = "http://purl.org/dc/terms/conformsTo", } +export const checkBoxFilterConfigs: Record< + string, + { id: string; name: string } +> = { + "http://data.europa.eu/r5r/applicableLegislation": { + id: "hvd_only", + name: "hvd", + }, + "http://purl.org/dc/terms/subject": { + id: "national_only", + name: "National", + }, + "http://purl.org/dc/terms/conformsTo": { + id: "spec_only", + name: "Specification", + }, +}; + /* eslint-enable no-unused-vars */ export interface ESEntryField {