feat: multi-select filters, global search, and richer selection filtering for data table [PR3]#3721
Draft
BRaimbault wants to merge 30 commits into
Draft
Conversation
Needed so the multi-select column filter can distinguish option-set-backed columns (which need code->name resolution) from plain categorical columns.
Adds a columnOptions memo to useTableData, allowlisted to the legend/type built-in columns plus any optionSet-backed event column, capped at 30 distinct values before falling back to free text. A blanket "any string column with few distinct values" check would wrongly turn name/id/parentName into dropdowns on small datasets.
Adds an Array.isArray short-circuit before the existing numeric/string dispatch so a multi-select column filter (built from user checkbox selections) OR-matches exactly against the raw stored value, without touching stringFilter/numericFilter's existing behavior.
…h useTableData Applies the global search after column filters and before selection filtering/sorting in the rows memo, matching case-insensitively across all string-typed columns.
Adds a Popover + checkbox-list path (reusing the pattern already established by TableContextMenu.jsx) rendered when an `options` prop is passed in. Option-set-backed columns get a separate wrapper component (OptionSetMultiSelectFilter) so useOptionSet/useDataQuery is only ever mounted when an optionSetId actually exists - legend/type columns never have one, and no test in the repo mocks useDataQuery.
Replaces the cryptic '2,>3&<8' placeholder with a simpler '> 5, < 8' and adds an info icon + Tooltip explaining the AND/OR/comparison syntax, consistent with Tooltip's existing use throughout DataTable.jsx/BottomPanel.jsx.
Table now forwards globalSearch into useTableData and threads columnOptions[dataKey]/optionSet.id from the header objects into FilterInput so it can pick between free-text and multi-select rendering.
Adds a dense Input between the "Clear filters" button and the show-only toggles, sized to shrink before the layer name has to truncate further. "Clear filters" now also resets the search box, and hasActiveFilters accounts for both column filters and the search string.
Threads an optional onItemClick/activeLegendNames pair through Legend -> LegendItem, scoped to THEMATIC_LAYER in OverlayCard (the only layer type with a legend data-table column). Clicking a legend class adds/removes it from the legend filter array and opens the data table for that layer if it isn't already showing. Other Legend call sites (plugin, download, edit preview, classification) never pass the new props, so they're unaffected.
Import order in FilterInput.spec.jsx and Prettier formatting across the files touched by the filtering changes.
Contributor
|
🚀 Deployed on https://pr-3721.maps.netlify.dhis2.org |
…ble-pr3-filtering
…filtered, and a richer selection filter
…ble-pr3-filtering
Reverts c2b5aac. The thematic-only implementation is being pulled out of this PR - the feature should work across bubble, event, facility, and org-unit layers too, which needs its own investigation and belongs in a separate PR rather than this one.
…ble-pr3-filtering
…ble-pr3-filtering
…ble-pr3-filtering
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Part of DHIS2-21456
Description
Redesigns the data table's per-column filters into one unified multi-select widget, adds a global search box, and replaces the boolean "show only selected" toggle with a richer selected/not-selected filter. Third in the data table improvement series, building on PR1's toolbar and PR2's selection sync.
Column filters (
FilterInput)>/>=/</<=/,/&syntax); a help tooltip explains the numeric syntaxconstants/dataTable.js(SENTINEL_NO_VALUE,SENTINEL_ANY_VALUE,SENTINEL_SELECTED_ROW)Global search
filterByGlobalSearch), combined with column filters and the selection filterSelection filter (replaces the boolean "show only selected" toggle)
Layer.js'sgetVisibleIds)"Clear filters"
Toolbar polish
Resize handle
Context menu
Removed
indexfilter never matched any real feature)Refactors (no behavior change)
FilterInput.jsxsplit: dropdown-positioning logic →FilterDropdownPopover.jsx(also removes a cross-component dependency, sinceDataTable.jsxwas reaching intoFilterInput.jsx's internals for it); the sentinel-value toggle/reverse logic →util/filterSelection.js, now directly unit-testedDataTable.jsxsplit: column-width measurement/resize logic →useColumnWidths.js; row-selection bookkeeping →useRowSelection.jsuseTableData.js's sort/compare logic →util/tableSort.js, now directly unit-tested instead of only covered indirectly through the hookSORT_ASCENDING/SORT_DESCENDINGinconstants/dataTable.js;--colors-white/--elevations-popovercustom properties instead of hardcoded values in the datatable stylesheets)Bug fixes
data-testrenamed from-input-to-search-)mapStateToPropswhen no context menu is openQuality checklist
Add N/A to items that are not applicable.
Screenshots
supporting images