Skip to content

Replace org Windows-audience dropdown with age-range chip picker - #2039

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/org-age-range-chips
Draft

Replace org Windows-audience dropdown with age-range chip picker#2039
maebeale wants to merge 1 commit into
mainfrom
maebeale/org-age-range-chips

Conversation

@maebeale

@maebeale maebeale commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 contained UI swap + a small shared-concern extraction, all covered by specs

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

  • The organization edit form’s "Windows audience" dropdown (set windows_type_id) is replaced by the same cocoon age-range chip picker the person form already uses.
  • No other org flow writes windows_type_id, so its permitted param is dropped too (the column/reads elsewhere are untouched).

How did you approach the change?

  • Moved the shared chip mechanics (age_range_categorizable_items nested association, dedupe, ordering) into AgeGroupTaggable, which both Person and Organization already include — Person now inherits them instead of defining its own.
  • The single-primary validation stays Person-only, per the existing note that orgs aggregate several members’ primary age groups.
  • Controller now sets @age_ranges_collection / @managed_category_type_ids and the form emits the category_ids/managed_category_type_ids keys so saving preserves age ranges (and other unmanaged category types) via assign_associations.

Anything else to add?

  • New request spec organizations_age_ranges_spec.rb; person age-range + org edit-view specs still green.

The Windows-audience select edited windows_type_id, which no other org flow
sets and which duplicated concepts already captured by age ranges. Swap it for
the same cocoon age-range chip picker the person form uses, sharing the chip
mechanics through AgeGroupTaggable so both models stay in step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 1, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the Organization edit form’s “Windows audience” (windows_type_id) dropdown with the existing cocoon-based age-range chip picker used on the Person form, and moves the shared age-range nested-association mechanics (ordering + dedupe) into AgeGroupTaggable so both models share the same behavior.

Changes:

  • Swap org form UI from windows_type_id select to age-range chip picker (nested age_range_categorizable_items).
  • Extract Person’s age-range nested association + dedupe + ordering into AgeGroupTaggable.
  • Add/adjust specs to assert the new UI and verify age-range saving behavior for organizations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
spec/views/organizations/edit.html.erb_spec.rb Updates view spec to assert the windows dropdown is gone and chip picker markup is present.
spec/requests/organizations_age_ranges_spec.rb Adds request coverage for org edit UI and saving/deduping age ranges while preserving other category taggings.
app/views/organizations/_form.html.erb Replaces the windows dropdown with the age-range cocoon chip picker; adds hidden keys to support assign_associations behavior.
app/models/person.rb Removes duplicated age-range nested-association logic now provided by AgeGroupTaggable.
app/models/concerns/age_group_taggable.rb Adds shared age-range nested association + ordering + dedupe used by both Person and Organization.
app/controllers/organizations_controller.rb Provides age-range collections for the form and permits age-range nested attributes; removes windows_type_id from permitted params.
Suppressed comments (1)

app/controllers/organizations_controller.rb:243

  • blocker: Because the form now always submits organization[category_ids] (blank key), permitting category_ids here causes assign_attributes to replace the organization’s categories during update before the age-range nested attributes and before assign_associations can preserve non-managed types; this can drop age-range taggings and can also break nested updates that submit existing age_range_categorizable_items ids.
      :profile_show_sectors, :profile_show_email, :profile_show_phone,
      :profile_show_website, :profile_show_description, :profile_show_workshops,
      :profile_show_stories, :profile_show_events_registered, :profile_show_workshop_logs,
      category_ids: [],
      sectorable_items_attributes: [

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.

2 participants