Dynamic filter on existing field values #25502
rikwilbrink
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When configuring a Collection Item Dropdown field, i want to configure a filter that uses data from a different field.
Basic Example
Motivation
I'm doing this for configuring the language switcher on each frontend page. It allows content managers to configure items that can be switched too. The build-in language module doesn't really work for me: Some components have no language, and others must be managed separately.
Detailed Design
For a User:
When configuring a filter for any field interface that allows filtering, a user should be able to provide a value like: "{{ fieldKey }}" as value for a equality check.
For a dev:
When opening a detail view of an item:
When opening a
<collection-drawer>the filter in the query, should be parsed to check for{{ xyz }}and replace that with existing data from a field. This can even be done with a string.replace and a regex check for"{{/w+}}"If field 'xyz' is not found with, it should consider {{ xyz }} as a string and actual value to query for.
Requirements List
Must Have:
Should Have:
Won't Have:
Drawbacks
It might cause an unexpected behavior if anyone already ever configured something like a dropdown with values that use the {{ xyz }} format. Unlikely though, and it's easy to fall back to the original situation if no related field is found.
Implementation is not that hard if you find the correct location to do so. It might affect multiple interfaces, so it's not a light change.
Alternatives
Content editors can still do the same by manually selecting the required language. But it's a tedious task to create a filter every time you wish to select a filtered version
Adoption Strategy
This is a feature in the app, that is handled in frontend of directus. Since it's a convenience feature, there is nothing that functionally breaks this for an implementation or data quality.
Unresolved Questions
No response
All reactions