Skip to content

GlobalSearch: support tag-based predefined-value filters (tagFilters) #1011

@abulte

Description

@abulte

Problem

Some use cases require multiple user-facing select filters that all contribute values to the tag API param simultaneously. For example, the indicators page has theme, enjeu, and secteur filters — each a predefined-value select — that must each independently add a tag value to the API call without overriding each other or the hidden tag universe filter.

Currently this is impossible to express in GlobalSearchConfig. The #filters slot offers custom UI but slot components have no way to inject additional API params into GlobalSearch's query. The native tag filter is facet-based and doesn't support predefined values.

Ref: opendatateam/udata-front-kit#1153

Why tag-specific

tag is architecturally special in the data.gouv.fr API — it's the designated multi-value classification mechanism. Other filter params (organization, format, license…) are single-select and map 1:1 with their URL params. A generic urlParam → apiParam mapping system would be YAGNI.

Proposed config

{
  class: 'datasets',
  hiddenFilters: [{ key: 'tag', value: 'ecospheres-indicateurs' }],
  tagFilters: [
    { urlParam: 'theme', label: 'Thématique', defaultLabel: 'Toutes les thématiques', values: [
      { value: 'ecospheres-indicateurs-theme-mieux-consommer', label: 'Mieux consommer' },
      ...
    ]},
    { urlParam: 'enjeu', label: 'Enjeu', defaultLabel: 'Tous les enjeux', values: [
      { value: 'ecospheres-indicateurs-enjeu-adaptation-climat', label: 'Adaptation climat' },
      ...
    ]},
  ]
}
  • Each tagFilter has its own URL param, isolated from others
  • Selected values are pre-baked tag strings (prefix handling is the caller's responsibility)
  • GlobalSearch renders the select UI, manages URL state, and merges all selected values with hiddenFilters and the native tag filter when building the API call

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions