Skip to content

feat: let the caller supply the pivot table filter line text - #1861

Merged
HendrikThePendric merged 5 commits into
masterfrom
feat/pivot-table-filter-text
Sep 24, 2026
Merged

HendrikThePendric merged 5 commits into
masterfrom
feat/pivot-table-filter-text

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Implements DHIS2-22147

Relates to https://github.com/dhis2/data-visualizer-app/pull/XXX


Key features

  1. PivotTable accepts an optional filterText prop, which lets a caller opt out of the filter line the lib derives and supply its own.

Description

PivotTableTitleRows builds the filter row from visualization.filters and rawData.metaData via getFilterText. Sometimes it is easier to work that line out in the app or plugin instead, so this PR adds a filterText prop to PivotTable which can be used instead of the internally computed string.

The prop is passed from PivotTable to PivotTableEngine and its constructor already accepted 3 positional argument and adding a 4th one is not allowed according to our ESLint rules. The engine is internal to the lib, so we could easily change this: the constructor now accepts a single options object.

Whether there is a filter row keeps being determined by visualization.filters?.length and if filterText is an empty string we fall back to the internally generated text, so we never render an empty filter row.


TODO

  • Tests added
  • Storybook added
  • PRs for all affected apps created N/A

HendrikThePendric and others added 3 commits September 24, 2026 10:37
The engine is about to gain a fourth argument, and a fourth positional one
would be both unreadable at the call site and over the lint threshold.

The class is internal - it is not re-exported from `src/index.js`, and the
`exports` map in `package.json` blocks deep imports of the built files - so
the signature can change outright rather than growing an options argument
alongside the positional ones.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`PivotTableTitleRows` derives the filter row from `visualization.filters`
and `rawData.metaData` via `getFilterText`. Sometimes it is easier for the
consuming app to work that line out itself - Event Visualizer filters are
often value conditions such as `GE:5:LE:10`, which need option sets and
value types this package has no access to - so let the caller opt out of
the derived text and pass its own in.

`PivotTable` takes an optional `filterText` prop, passed through to the
engine and kept on `engine.options` alongside `title` and `subtitle`. It
deliberately does not travel on `visualization`, which should stay a
partial of the saved visualization rather than a bag of render options.

The prop picks the text and nothing else. Whether there is a filter row at
all remains gated on `visualization.filters?.length`, exactly as before, so
a supplied string cannot conjure a row the layout has no filters for, and
an empty one renders an empty row rather than suppressing it. Hence `??`
rather than `||`: the empty string is a supplied text like any other, and
must not fall back to the derived line.

`getFilterText` itself is untouched, as are its six other consumers in the
Highcharts title and subtitle adapters.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Toggles the `deep - filter` layout between the line the lib derives from
the layout ("Eastern Area") and one supplied by the caller, with a third
mode showing that an empty `filters` layout has no row for either.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@HendrikThePendric
HendrikThePendric force-pushed the feat/pivot-table-filter-text branch from 41860b1 to 098bbdb Compare September 24, 2026 09:34
@sonarqubecloud

Copy link
Copy Markdown

@HendrikThePendric
HendrikThePendric merged commit 877c8d5 into master Sep 24, 2026
13 checks passed
@HendrikThePendric
HendrikThePendric deleted the feat/pivot-table-filter-text branch September 24, 2026 14:26
dhis2-bot added a commit that referenced this pull request Sep 24, 2026
# [29.8.0](v29.7.1...v29.8.0) (2026-09-24)

### Features

* let the caller supply the pivot table filter line text ([#1861](#1861)) ([877c8d5](877c8d5))
@dhis2-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 29.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants