Skip to content

Commit

Permalink
DIGG-472: filter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Gasperini authored and Alessandro Gasperini committed Dec 5, 2024
1 parent 33e1d24 commit 90f5d8e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
41 changes: 7 additions & 34 deletions features/search/search-filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -541,49 +541,22 @@ export const SearchFilters: FC<SearchFilterProps> = ({
</SearchFilter>
</li>
);
} else if (key === hvd) {
} else {
const filterConfig = checkBoxFilterConfigs[key];
return (
<SearchCheckboxFilter
key={key}
id="hvd_only"
name="hvd"
id={filterConfig.id}
name={filterConfig.name}
checked={activeCheckboxFilters.some(
(filter) => 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 (
<SearchCheckboxFilter
key={key}
id="national_only"
name="National"
checked={activeCheckboxFilters.some(
(filter) => filter.id === "national_only",
)}
onChange={() => doSearch(key, facetValues[0])}
label={t(`resources|${key}`)}
iconSize={iconSize}
/>
);
} else if (key === spec) {
return (
<SearchCheckboxFilter
key={key}
id="spec_only"
name="Specification"
checked={activeCheckboxFilters.some(
(filter) => filter.id === "spec_only",
)}
onChange={() => doSearch(key, facetValues[0])}
label={t(`resources|${key}`)}
iconSize={iconSize}
/>
);
}
}
})}

{searchMode == "datasets" && groupName == "distribution" && (
Expand Down
2 changes: 1 addition & 1 deletion locales/en/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion locales/sv/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions utilities/entryscape/entryscape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 90f5d8e

Please sign in to comment.