dpc-sdp / ripple-framework

Ripple is the presentation layer for building websites on the DPC Single Digital Presence platform.
Apache License 2.0
18 stars 13 forks source link

Tide Custom Collection - Provide filter values to child components. #1114

Open alan-cole opened 2 months ago

alan-cole commented 2 months ago

Describe the feature

Allow the values of filters in a Custom Collection to be accessible to children (particularly results).

Motivation

In some cases a result component may require a value from the applied filters.

For example:

Screenshot 2024-04-15 at 11 40 12 AM

An "Open in google maps" link on on a result. This requires an origin and destination to correctly fill the link:

https://www.google.com/maps/dir/?api=1&origin=[ORIGIN]&destination=[DESTINATION]

While the destination can be found from the result's address field, the origin would be the the user defined address in the search form, which is not passed through to the results.

Proposal

Using the provide / inject method, we could provide the necessary fields to any child of the custom collection, e.g.:

provide('rplTideCustomCollectionFilters', {
  searchTerm,
  locationQuery,
  filterForm
})

in here:

https://github.com/dpc-sdp/ripple-framework/blob/develop/packages/ripple-tide-search/components/global/TideCustomCollection.vue#L386

Note it doesn't need to be limited to these, and could include other useful variables as well.

Benefits

Solves the issue outlined in motivation, and could be useful for other cases (e.g. showing all terms of a field and highlighting the ones being filtered upon).

Drawbacks

This may open a pathway to unwanted workarounds to other limitations, as additional scope is now exposed.

Adoption strategy

Could be documented in an example, a test, or other developer documentation.

Additional information

Final checks

alan-cole commented 2 months ago

This feature is no longer required for the particular project I was working on and can be closed if deemed unnecessary.