Skip to content

Commit

Permalink
DIGG-472: Follow specification facet
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 d8cde92 commit 919af67
Show file tree
Hide file tree
Showing 9 changed files with 2,908 additions and 3,635 deletions.
1 change: 1 addition & 0 deletions components/typography/body-variant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const BodyVariant: FC<PropsWithChildren<BodyProps>> = ({
const CustomTag = variant as keyof React.JSX.IntrinsicElements;

return (
// @ts-expect-error
<CustomTag className={cx(bodyVariants({ variant }), className)}>
{variant === "blockquote" && (
<QuoteIcon className="col-start-1 !h-[40px] !w-[40px] flex-shrink-0" />
Expand Down
1 change: 1 addition & 0 deletions components/typography/heading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const Heading: FC<
const CustomTag = `h${level}` as keyof React.JSX.IntrinsicElements;
return (
<CustomTag className={cx(headingVariants({ size }), className)}>
{/* @ts-expect-error - React children type mismatch with custom heading element */}
{children}
</CustomTag>
);
Expand Down
32 changes: 30 additions & 2 deletions features/search/search-filters/index.tsx
Original file line number Diff line number Diff line change
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 @@ -555,7 +569,21 @@ export const SearchFilters: FC<SearchFilterProps> = ({
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
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 @@ -20,6 +20,7 @@
"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
1 change: 1 addition & 0 deletions locales/sv/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"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
1 change: 1 addition & 0 deletions utilities/entryscape/entryscape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ 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",
}

/* eslint-enable no-unused-vars */
Expand Down
Loading

0 comments on commit 919af67

Please sign in to comment.