From 919af675178640b7e99d38c381185f315dd29064 Mon Sep 17 00:00:00 2001 From: Alessandro Gasperini Date: Thu, 5 Dec 2024 15:39:25 +0100 Subject: [PATCH 1/5] DIGG-472: Follow specification facet --- components/typography/body-variant/index.tsx | 1 + components/typography/heading/index.tsx | 1 + features/search/search-filters/index.tsx | 32 +- .../search-active-filters/index.tsx | 3 +- .../search-page-provider-settings.ts | 9 + locales/en/resources.json | 1 + locales/sv/resources.json | 1 + utilities/entryscape/entryscape.ts | 1 + yarn.lock | 6494 ++++++++--------- 9 files changed, 2908 insertions(+), 3635 deletions(-) diff --git a/components/typography/body-variant/index.tsx b/components/typography/body-variant/index.tsx index d7dc9d70..43e9cd78 100644 --- a/components/typography/body-variant/index.tsx +++ b/components/typography/body-variant/index.tsx @@ -64,6 +64,7 @@ const BodyVariant: FC> = ({ const CustomTag = variant as keyof React.JSX.IntrinsicElements; return ( + // @ts-expect-error {variant === "blockquote" && ( diff --git a/components/typography/heading/index.tsx b/components/typography/heading/index.tsx index 822089c0..81f8fbf8 100644 --- a/components/typography/heading/index.tsx +++ b/components/typography/heading/index.tsx @@ -26,6 +26,7 @@ export const Heading: FC< const CustomTag = `h${level}` as keyof React.JSX.IntrinsicElements; return ( + {/* @ts-expect-error - React children type mismatch with custom heading element */} {children} ); diff --git a/features/search/search-filters/index.tsx b/features/search/search-filters/index.tsx index 73da9166..e34d5d28 100644 --- a/features/search/search-filters/index.tsx +++ b/features/search/search-filters/index.tsx @@ -281,6 +281,7 @@ export const SearchFilters: FC = ({ const hvd = "http://data.europa.eu/r5r/applicableLegislation"; const national = "http://purl.org/dc/terms/subject"; + const spec = "http://purl.org/dc/terms/conformsTo"; const activeCheckboxFilters = useMemo(() => { const filters = []; @@ -315,6 +316,19 @@ export const SearchFilters: FC = ({ }); } + // Specification filter + if ( + search.request.facetValues?.some((t: SearchFacetValue) => t.facet === ESRdfType.spec) + ) { + filters.push({ + id: "spec_only", + label: t(`resources|${spec}`), + facetValue: search.request.facetValues.find( + (t) => t.facet === ESRdfType.spec, + ), + }); + } + // API only filter if ( searchMode === "datasets" && @@ -409,7 +423,7 @@ export const SearchFilters: FC = ({ ) : value?.facetValues.slice(0, show); - if (key !== hvd && key !== national) { + if (key !== hvd && key !== national && key !== spec) { return (
  • = ({ 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/features/search/search-filters/search-active-filters/index.tsx b/features/search/search-filters/search-active-filters/index.tsx index 99c8b097..ffcd8b9a 100644 --- a/features/search/search-filters/search-active-filters/index.tsx +++ b/features/search/search-filters/search-active-filters/index.tsx @@ -54,7 +54,8 @@ export function SearchActiveFilters({ (facetValue: SearchFacetValue, index: number) => facetValue.facet !== "http://data.europa.eu/r5r/applicableLegislation" && - facetValue.facet !== "http://purl.org/dc/terms/subject" && ( + facetValue.facet !== "http://purl.org/dc/terms/subject" && + facetValue.facet !== "http://purl.org/dc/terms/conformsTo" && (
  • ); - } 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 { From e07bf222966686d20306caad2f3ca7aebe97d0d1 Mon Sep 17 00:00:00 2001 From: Alessandro Gasperini Date: Fri, 6 Dec 2024 09:11:37 +0100 Subject: [PATCH 4/5] DIGG-472 ts ignore remove --- components/typography/body-variant/index.tsx | 1 - components/typography/heading/index.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/components/typography/body-variant/index.tsx b/components/typography/body-variant/index.tsx index 3f6564a8..d7dc9d70 100644 --- a/components/typography/body-variant/index.tsx +++ b/components/typography/body-variant/index.tsx @@ -64,7 +64,6 @@ const BodyVariant: FC> = ({ const CustomTag = variant as keyof React.JSX.IntrinsicElements; return ( - // @ts-expect-error - React children type mismatch with custom body element {variant === "blockquote" && ( diff --git a/components/typography/heading/index.tsx b/components/typography/heading/index.tsx index 81f8fbf8..822089c0 100644 --- a/components/typography/heading/index.tsx +++ b/components/typography/heading/index.tsx @@ -26,7 +26,6 @@ export const Heading: FC< const CustomTag = `h${level}` as keyof React.JSX.IntrinsicElements; return ( - {/* @ts-expect-error - React children type mismatch with custom heading element */} {children} ); From d4b5c8bf067bec6438901ae19d4ed156eadd324f Mon Sep 17 00:00:00 2001 From: Alessandro Gasperini Date: Mon, 9 Dec 2024 12:55:52 +0100 Subject: [PATCH 5/5] DIGG-472: Filter dropdown national --- features/search/search-filters/index.tsx | 22 +-- .../search-active-filters/index.tsx | 1 - .../search-page-provider-settings.ts | 149 +++++++++--------- utilities/entryscape/entryscape.ts | 30 ++-- utilities/entrystore-utils.ts | 2 + 5 files changed, 93 insertions(+), 111 deletions(-) diff --git a/features/search/search-filters/index.tsx b/features/search/search-filters/index.tsx index 913562cd..a24349ac 100644 --- a/features/search/search-filters/index.tsx +++ b/features/search/search-filters/index.tsx @@ -151,7 +151,7 @@ const FindFilters = ( ) => { if (!checkedFilters) return ""; - const allTitles = categoryFilters.map((item) => item.title); + const allTitles = categoryFilters.map((item) => item.title); const checkedTitles = checkedFilters.map((item) => item.title); const union = allTitles.filter((x) => checkedTitles.includes(x)); @@ -280,7 +280,6 @@ export const SearchFilters: FC = ({ }, [search.allFacets]); const hvd = "http://data.europa.eu/r5r/applicableLegislation"; - const national = "http://purl.org/dc/terms/subject"; const spec = "http://purl.org/dc/terms/conformsTo"; const activeCheckboxFilters = useMemo(() => { @@ -301,21 +300,6 @@ export const SearchFilters: FC = ({ }); } - // National filter - if ( - search.request.facetValues?.some( - (t: SearchFacetValue) => t.facet === ESRdfType.national_data, - ) - ) { - filters.push({ - id: "national_only", - label: t(`resources|${national}`), - facetValue: search.request.facetValues.find( - (t: SearchFacetValue) => t.facet === ESRdfType.national_data, - ), - }); - } - // Specification filter if ( search.request.facetValues?.some((t: SearchFacetValue) => t.facet === ESRdfType.spec) @@ -423,7 +407,7 @@ export const SearchFilters: FC = ({ ) : value?.facetValues.slice(0, show); - if (key !== hvd && key !== national && key !== spec) { + if (key !== hvd && key !== spec) { return (
  • = ({ /> )} - )} + )} {/* List of filter options within this category */}
      {facetValues diff --git a/features/search/search-filters/search-active-filters/index.tsx b/features/search/search-filters/search-active-filters/index.tsx index ffcd8b9a..b906ee81 100644 --- a/features/search/search-filters/search-active-filters/index.tsx +++ b/features/search/search-filters/search-active-filters/index.tsx @@ -54,7 +54,6 @@ export function SearchActiveFilters({ (facetValue: SearchFacetValue, index: number) => facetValue.facet !== "http://data.europa.eu/r5r/applicableLegislation" && - facetValue.facet !== "http://purl.org/dc/terms/subject" && facetValue.facet !== "http://purl.org/dc/terms/conformsTo" && (