Skip to content

Age ranges: single primary like sectors + visibility toggle#1747

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/rebase-main
Draft

Age ranges: single primary like sectors + visibility toggle#1747
maebeale wants to merge 1 commit into
mainfrom
maebeale/rebase-main

Conversation

@maebeale

@maebeale maebeale commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

What is the goal of this PR and why is this important?

  • Builds on Populate Additional Ages Served from age range categories #1717's primary/additional age groups, reshaping them to match sectors exactly and adding a per-profile visibility toggle.
  • On the registration form a respondent now picks one primary age range from a dropdown and many additional ones from a multi-select — same shape as the primary/additional sector questions.

How did you approach the change?

Registration form

  • "Primary age range" is now a single-select dropdown (one primary); "Additional ages served" stays multi-select.
  • A data migration converts existing forms' primary_age_group field to a dropdown and renames both questions.

Single primary (sector parity)

  • AgeGroupTaggable#tag_age_groups and #apply_primary_age_groups! keep exactly one primary — choosing a new primary demotes the previous one — backed by an at_most_one_primary_age_group validation.
  • A migration normalizes any existing data that marked several primaries down to one.
  • Edit forms keep a single "Primary" toggle checked at a time via a new single-select-checkbox Stimulus controller (allows zero or one, like the star toggle on sectors).

Visibility toggle

  • profile_show_age_ranges on people + organizations gates the "Age ranges served" section, mirroring profile_show_sectors. Added a "Show age ranges" checkbox to both edit forms.

Reporting

  • The event dashboard age breakdown now reads both the primary and additional age-range answers (previously only the primary question), so the chart reflects every age range served.

Anything else to add?

🤖 Generated with Claude Code

@maebeale maebeale force-pushed the maebeale/rebase-main branch from 4a6dcb3 to e32d01a Compare June 18, 2026 18:32
@maebeale

Copy link
Copy Markdown
Collaborator Author

🤖 From Claude: Rebased onto latest main (33 commits). Conflicts resolved: form_builder_service.rb (main renamed hint:subtitle: in add_field, so the new age-range fields use subtitle:), db/schema.rb version line, and the AGENTS.md controller count.

Heads-up on the backfill migration (20260617150000): it's backdated relative to main's hint_textsubtitle rename (20260618014554), so it runs before the rename on a fresh in-order DB but after it on production (where the rename is already applied). It detects column_exists?(:form_fields, :subtitle) and writes to whichever column exists, so the descriptive text lands correctly in both orderings. On a fresh DB there are no forms yet, so the loop is a no-op anyway.

@maebeale maebeale force-pushed the maebeale/rebase-main branch from e32d01a to f9f2d56 Compare June 18, 2026 19:27
@maebeale maebeale changed the title Model age ranges like sectors (primary + additional) Age ranges: single primary like sectors + visibility toggle Jun 18, 2026
@maebeale maebeale force-pushed the maebeale/rebase-main branch from f9f2d56 to 6ff3233 Compare June 18, 2026 20:00
Builds on #1717's primary/additional age groups, reshaping them to match
sectors exactly and adding a per-profile visibility toggle.

- Registration: "Primary age range" is now a single-select dropdown (one
  primary) and "Additional ages served" stays multi-select; a data migration
  converts existing forms' field type + labels.
- Enforce a single primary: AgeGroupTaggable's tag_age_groups and
  apply_primary_age_groups! keep exactly one primary (a new primary demotes the
  old), backed by an at-most-one-primary validation. A migration normalizes any
  existing data that marked several primaries down to one.
- Edit forms keep one "Primary" toggle checked at a time via a new
  single-select-checkbox Stimulus controller.
- profile_show_age_ranges toggle (people + orgs) gates the "Age ranges served"
  section, mirroring profile_show_sectors.
- Event dashboard age breakdown now reads both the primary and additional
  age-range answers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/rebase-main branch from 6ff3233 to 0e4f260 Compare June 18, 2026 20:08
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.

1 participant