Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digg 472: Follow specification facet #527

Merged
merged 6 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 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 @@ -281,6 +281,7 @@ export const SearchFilters: FC<SearchFilterProps> = ({

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 = [];
Expand Down Expand Up @@ -315,6 +316,19 @@ export const SearchFilters: FC<SearchFilterProps> = ({
});
}

// 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" &&
Expand Down Expand Up @@ -409,7 +423,7 @@ export const SearchFilters: FC<SearchFilterProps> = ({
)
: value?.facetValues.slice(0, show);

if (key !== hvd && key !== national) {
if (key !== hvd && key !== national && key !== spec) {
return (
<li
key={`${value.title}-${idx}`}
Expand Down Expand Up @@ -527,28 +541,15 @@ export const SearchFilters: FC<SearchFilterProps> = ({
</SearchFilter>
</li>
);
} else if (key === hvd) {
return (
<SearchCheckboxFilter
key={key}
id="hvd_only"
name="hvd"
checked={activeCheckboxFilters.some(
(filter) => filter.id === "hvd_only",
)}
onChange={() => doSearch(key, facetValues[0])}
label={t(`resources|${key}`)}
iconSize={iconSize}
/>
);
} else if (key === national) {
} else {
const filterConfig = checkBoxFilterConfigs[key];
return (
<SearchCheckboxFilter
key={key}
id="national_only"
name="National"
id={filterConfig.id}
name={filterConfig.name}
checked={activeCheckboxFilters.some(
(filter) => filter.id === "national_only",
(filter) => filter.id === filterConfig.id,
)}
onChange={() => doSearch(key, facetValues[0])}
label={t(`resources|${key}`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" && (
<Button
variant="filter"
size="xs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ export function createSearchProviderSettings(env: EnvSettings, lang: string) {
indexOrder: 7,
group: "type",
},
{
resource: "http://purl.org/dc/terms/conformsTo",
type: ESType.uri,
dcatProperty: "dcterms:conformsTo",
dcatType: "choice",
dcatFilterEnabled: false,
indexOrder: 8,
group: "type",
},
],
},
initRequest: {
Expand Down
1 change: 1 addition & 0 deletions locales/en/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions locales/sv/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"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",
Expand Down
19 changes: 19 additions & 0 deletions utilities/entryscape/entryscape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,27 @@ export enum ESRdfType {
hvd = "http://data.europa.eu/eli/reg_impl/2023/138/oj",
agent = "http://xmlns.com/foaf/0.1/Agent",
national_data = "http://purl.org/dc/terms/subject",
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
Loading
Loading