feat: allow selecting multiple categories in demographic filters#609
Open
Joe-Heffer-Shef wants to merge 2 commits into
Open
feat: allow selecting multiple categories in demographic filters#609Joe-Heffer-Shef wants to merge 2 commits into
Joe-Heffer-Shef wants to merge 2 commits into
Conversation
The survey report's demographic data filters used single-value dropdowns, so users could only filter to one category at a time. Convert categorical filters to checkbox lists so multiple categories can be selected at once (e.g. several hospital sites within a Trust). Categorical filter state now holds a string[] of selected options (empty = "All") instead of a single value. A response is kept if its value is in the selected set; an empty selection applies no filtering. Multiple selections render comma-joined in the active filters display. Numeric range filters are unchanged. Replace the <select> with an accessible checkbox group using <fieldset>/<legend> and for/id-linked labels per the repo's WCAG focus. Adds tests covering checkbox rendering, multi-select union, and the empty-selection pass-through. Filtering remains client-side, so no backend changes are needed. Closes #605 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
This comment was marked as resolved.
This comment was marked as resolved.
…rendering Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closes #605 |
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.
Summary
The survey report's demographic data filters used single-value dropdowns, so users could only filter to one category at a time. This converts categorical filters to checkbox lists, so multiple categories can be selected at once (e.g. several hospital sites within a Trust).
Screenshots
Each demographics field has a multi-checkbox option like this:
The selected categories are shown below the filter panel
The charts are all filtered based on the selected categories
Changes —
SurveyDemographicFilters.sveltestring[]of selected options (empty = "All") instead of a single value. Types andonMountinitialisation updated accordingly.includes); an empty selection applies no filtering. Numeric range filters are unchanged.Royal Hallamshire, Northern General).FilterAlert.sveltealready renders this as free text, so it needed no change.<select>with an accessible checkbox group —<fieldset>/<legend>for grouping andfor/id-linked labels (per the repo's WCAG focus), using Bootstrapform-checkclasses. Added atoggleOptionhelper that reassigns the array so Svelte 5 runes reactivity fires.Tests
Added three tests: checkboxes render (no
<select>), ticking two options keeps the union and shows both in the active filter, and an empty selection passes all responses through. The existing disabled-field regression test still passes.Verification
npx vitest runon the suite: 4 passed.npx eslinton both changed files: clean.The backend (
survey/views.py,survey/models.py) needed no changes since all filtering is client-side, and exports operate on the filtered set already passed through these components.Closes #605
🤖 Generated with Claude Code