Conversation
|
CI output, failures seem unrelated? https://github.com/ecolabdata/cdata/actions/runs/24194727780 |
|
@maudetes @ThibaudDauce @nicolaskempf57 don't know why it's not assigning you as reviewers 🤷 And I can't do it myself, hence the ping. Thanks! |
|
Interesting feature! Before merging, I'd like to suggest an alternative approach that avoids adding a parallel filter system inside GlobalSearch. The core need is: let consumers add custom filter UI that maps to API params. Right now, Simpler alternative: a slot + reactive hiddenFilters
The consumer would then do: <GlobalSearch :config="searchConfig">
<template #extra-filters>
<MyThemeDropdown v-model="selectedTheme" />
<MyEnjeuDropdown v-model="selectedEnjeu" />
</template>
</GlobalSearch>const searchConfig = computed(() => [{
class: 'datasets',
hiddenFilters: [
{ key: 'tag', value: 'ecospheres-indicateurs' },
...(selectedTheme.value ? [{ key: 'tag', value: selectedTheme.value }] : []),
...(selectedEnjeu.value ? [{ key: 'tag', value: selectedEnjeu.value }] : []),
],
}])Benefits:
The only work needed inside GlobalSearch/useStableQueryParams is making the config reactive (watch That said, if this approach ends up being more complex on your side or doesn't fit your constraints, we can absolutely merge this PR as-is — it works and solves the problem. I'm just wondering if having full control via a slot might actually be simpler and more flexible for you? |
|
@ThibaudDauce Thanks for the review and the suggestion! I agree that the new codepath to handle tag filters is suboptimal, especially since it's not used (yet?) in cdata. But I feel your proposal would push a lot of complexity on downstream projects that use the component. Today, the whole filter lifecycle (url sync, reset, page invalidation, type-switch cleanup) is centralised in GlobalSearch, which make it easy to integrate. If I understand your proposal correctly, this lifecycle would need to be managed partly in downstream apps (for custom filters) and leave the rest to GlobalSearch (for native filters). This feels hard, especially the URL sync stuff which is tricky. This is all based on my assumptions and "static" analysis, I didn't implement your solution. But I feel like the current solution is good enough given the challenges of the alternative. |
|
What do you think of this solution? #1048 |
Close ecolabdata/ecospheres#1011
Adds a
tagFiltersoption toGlobalSearchConfigthat renders select dropdowns whose values map to thetagAPI param.This enables multiple independent predefined-value tag filters (e.g. theme, enjeu, secteur like on https://ecologie.data.gouv.fr/indicators) that merge correctly with
hiddenFiltersand the native tag filter.The URL is two-way synced with the dropdowns. Query param name is filter's name.
Example usage:
Selecting "Mieux consommer" in Thème dropdown →
theme=ecospheres-indicateurs-theme-mieux-consommerin the URL → API receivestag=ecospheres-indicateurs&tag=ecospheres-indicateurs-theme-mieux-consommer.Bonus
.inputstyle that need to be used by consuming projects