-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@dpc-sdp/ripple-tide-search): added support for function filters…
…, grantStatus function filter
- Loading branch information
1 parent
f6c02a2
commit 33f42b2
Showing
8 changed files
with
284 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
examples/nuxt-app/test/fixtures/search-listing/filters/request-function-filter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"query": { | ||
"bool": { | ||
"must": [ | ||
{ | ||
"match_all": {} | ||
} | ||
], | ||
"filter": [ | ||
{ | ||
"terms": { | ||
"type": ["grant"] | ||
} | ||
}, | ||
{ | ||
"terms": { | ||
"field_node_site": [8888] | ||
} | ||
}, | ||
{ | ||
"providedFilterConfig": { | ||
"id": "functionFilter", | ||
"component": "TideSearchFilterDropdown", | ||
"filter": { | ||
"type": "function", | ||
"value": "dummyFunctionFilter" | ||
}, | ||
"props": { | ||
"id": "functionFilter", | ||
"label": "Custom function filter example", | ||
"placeholder": "Select a grant status", | ||
"multiple": true, | ||
"options": [ | ||
{ | ||
"id": "open", | ||
"label": "Open", | ||
"value": "open" | ||
}, | ||
{ | ||
"id": "closed", | ||
"label": "Closed", | ||
"value": "closed" | ||
} | ||
] | ||
} | ||
}, | ||
"providedValues": ["closed", "open"] | ||
} | ||
] | ||
} | ||
}, | ||
"size": 10, | ||
"from": 0, | ||
"sort": [ | ||
{ | ||
"_score": "desc" | ||
}, | ||
{ | ||
"_doc": "desc" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
export default defineAppConfig({ | ||
ripple: { | ||
search: { | ||
filterFunctions: { | ||
grantStatus: (filterConfig: string, statuses: unknown) => { | ||
const mapStatusToFilterDSL = (status) => { | ||
switch (status) { | ||
case 'open': | ||
return { | ||
bool: { | ||
must: [ | ||
{ | ||
range: { | ||
field_node_dates_start_value: { | ||
lte: 'now' | ||
} | ||
} | ||
}, | ||
{ | ||
range: { | ||
field_node_dates_end_value: { | ||
gte: 'now' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
case 'closed': | ||
return { | ||
range: { | ||
field_node_dates_end_value: { | ||
lte: 'now' | ||
} | ||
} | ||
} | ||
|
||
case 'ongoing': | ||
return { | ||
term: { | ||
field_node_on_going: 'true' | ||
} | ||
} | ||
|
||
case 'opening_soon': | ||
return { | ||
range: { | ||
field_node_dates_start_value: { | ||
gte: 'now' | ||
} | ||
} | ||
} | ||
default: | ||
return null | ||
} | ||
} | ||
|
||
const filters = statuses | ||
.map(mapStatusToFilterDSL) | ||
.filter((query) => !!query) // filter null values | ||
|
||
return { | ||
bool: { | ||
should: filters | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters