Skip to content

fix: compute suffixes for the entire layout not per axis and refactor#306

Open
HendrikThePendric wants to merge 1 commit into
masterfrom
fix/dimension-suffixes-DHIS2-21682
Open

fix: compute suffixes for the entire layout not per axis and refactor#306
HendrikThePendric wants to merge 1 commit into
masterfrom
fix/dimension-suffixes-DHIS2-21682

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Implements DHIS2-21682

Description

Summary

Dimension chip suffixes were computed per axis, so two same-named dimensions on different axes (e.g. the same data element from two stages, one in Columns and one in Filters) showed no disambiguating suffix. Suffixes now consider the whole layout.

The fix exposed that the suffix mechanism and the layout helpers it leans on had grown awkward, so this also reshapes them.

Changes

Suffix bug fix

  • Chip suffixes are derived from every dimension in the layout, not just same-axis ones. The line-list table headers already behaved this way; the chips now match.

Suffix mechanism modules/dimension/suffix.ts

  • Replaced the callback-based getDimensionSuffixes(dimensions, getName) with two pure building blocks: buildSuffixContext({ programs, programStages }) (counts, name maps, stage-name collisions — computed once) and getDimensionSuffix(dimension, context) (pure per-dimension lookup). The rules are unchanged.

Layout hooks use-layout-dimensions.ts

  • useLayoutDimensions() returns dimensions grouped per axis ({ columns, rows, filters }), so Axes no longer regroups. Axis takes finished dimensions instead of ids.
  • useDimensionSuffix(id) provides the modal's single title suffix.

Layout context consolidation modules/layout.ts + hooks/

  • Replaced resolveProgramIds / resolveProgramStageIds / resolveTetId and their useProgramIds / useProgramStageIds / useTetId hooks with a single resolveLayoutContext(ids, store){ programIds, programStageIds, tetId } and a useLayoutContext() hook. Migrated all call sites (action buttons, custom value, cross-TET, drag-and-drop, plugin).
  • useLayoutContext recomputes only when the layout changes. resolveLayoutContext throws on a dimension missing from the store rather than silently skipping.

Plugin (line-list headers)

  • buildHeaders uses the new suffix API and resolveLayoutContext. Program/stage names come from the metadata store (populated by setVisualizationMetadata in both app and plugin).

Quality checklist

  • Dashboard tested N/A
  • Cypress and/or Jest tests added/updated
  • Docs added N/A
  • d2-ci dependency replaced N/A

Screenshots

Cross axis comparison in action
Screenshot 2026-07-02 at 18 30 40

@dhis2-bot

Copy link
Copy Markdown

🚀 Deployed on https://pr-306.event-visualizer.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify July 2, 2026 16:32 Inactive
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants