Skip to content

Commit

Permalink
DIGG-494: National dropdown filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Gasperini authored and Alessandro Gasperini committed Dec 13, 2024
1 parent 8dbf961 commit 7430747
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ export function createSearchProviderSettings(env: EnvSettings, lang: string) {
dcatProperty: "dcterms:subject",
indexOrder: 7,
group: "type",
customFilter:
"http://inspire.ec.europa.eu/metadata-codelist/TopicCategory/*",
showInSearchResult: true,
customProperties: [
"http://inspire.ec.europa.eu/metadata-codelist/TopicCategory/",
],
},
{
resource: "http://purl.org/dc/terms/conformsTo",
Expand Down
2 changes: 2 additions & 0 deletions types/search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface FacetSpecificationItem {
dcatFilterEnabled?: boolean;
customFilter?: string;
customSearch?: ESRdfType[];
customProperties?: string[];
showInSearchResult?: boolean;
}

Expand Down Expand Up @@ -92,6 +93,7 @@ export interface SearchFacetValue {
facetValueString: string;
related: boolean;
customFilter?: string;
customProperties?: string[];
customSearch?: ESRdfType[];
}

Expand Down
19 changes: 18 additions & 1 deletion utilities/entrystore/entrystore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,26 @@ export class EntrystoreService {
customSearch: facetSpec.customSearch,
facetValues: f.values
.filter((value: ESFacetFieldValue) => {
if (
facetSpec.customProperties &&
facetSpec.customProperties.length > 0
) {
return facetSpec.customProperties.some((property) =>
value.name.startsWith(property),
);
}
if (!value.name || value.name.trim() === "") return false;
if (!facetSpec?.dcatFilterEnabled) return true;

if (
facetSpec.resource === "http://purl.org/dc/terms/subject" &&
value.name.startsWith(
"http://inspire.ec.europa.eu/metadata-codelist/TopicCategory/",
)
) {
return true;
}

const choices: Choice[] = getTemplateChoices(
dcat,
facetSpec.dcatProperty,
Expand Down Expand Up @@ -680,7 +697,7 @@ export class EntrystoreService {
.startsWith(
facet?.customFilter?.endsWith("*")
? facet?.customFilter?.slice(0, -1)
: facet?.customFilter,
: facet?.customFilter || facet?.customProperties?.[0],
),
);

Expand Down

0 comments on commit 7430747

Please sign in to comment.