Sync registration "Other" organization type onto the linked org#1875
Sync registration "Other" organization type onto the linked org#1875maebeale wants to merge 1 commit into
Conversation
| # wins; AhoyTrackable records the before/after on the update. | ||
| def update_agency_type(organization) | ||
| raw = field_value("agency_type").to_s.strip | ||
| label, _separator, specified = raw.partition(":") |
There was a problem hiding this comment.
🤖 From Claude: partition(":") is safe here because none of the agency-type option labels contain a colon, so the split always yields the option label and (for "Other") the typed free text. agency_type_other is cleared for non-"Other" choices to avoid leaving stale text behind.
Why: a registrant who picked "Other" for organization type had nowhere to record what that "other" was, and the org's agency_type_other column was only ever set from the admin edit form. Make the registration "Other" choice behave like every other specify option (reveals a box, stores "Other: <text>") and mirror the answer onto the linked organization so the free text isn't lost. Latest registration wins; AhoyTrackable records the before/after on each update. No data migration — new behavior applies to forms built after this change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0a523db to
791ff63
Compare
| # agency_type_other, which is cleared for the non-"Other" classifications so | ||
| # no stale free text lingers. Follows the same latest-wins / never-clobber-on- | ||
| # blank contract as apply_value. | ||
| def sync_agency_type(organization) |
There was a problem hiding this comment.
🤖 From Claude: Folded into sync_organization_profile on rebase: partition(":") splits the option label from the "Other" free text (safe — no agency-type label contains a colon). agency_type_other is cleared for the non-"Other" classifications so no stale text lingers.
There was a problem hiding this comment.
Pull request overview
This PR updates public event registration and the organization edit UI so that selecting “Other” for Organization Type behaves like a standard “specify” option and syncs cleanly onto the linked Organization (agency_type + agency_type_other), instead of dropping or mis-storing the free-text detail.
Changes:
- Change the registration form’s agency type option to bare
"Other"so it qualifies as a specify option (stored as"Other: <text>"). - Update org admin edit select options to include
"Other"so synced values render correctly. - Replace the org sync write with
sync_agency_type, splitting"Other: <text>"intoagency_type="Other"andagency_type_other="<text>", with added specs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
app/services/event_registration_services/public_registration.rb |
Introduces sync_agency_type to parse/sync "Other: <text>" into structured org fields. |
app/services/form_builder_service.rb |
Updates the “Organization Type” options so "Other" triggers specify-option behavior. |
app/views/organizations/_form.html.erb |
Updates the admin org form select options to match the new "Other" value. |
spec/services/event_registration_services/public_registration_spec.rb |
Adds coverage for syncing agency_type/agency_type_other across “Other” and non-“Other” cases. |
spec/services/form_builder_service_spec.rb |
Updates expected agency type options and asserts "Other" is treated as a specify option. |
Comments suppressed due to low confidence (1)
app/views/organizations/_form.html.erb:120
- blocker: If an Organization already has a legacy agency_type value (e.g. the previous "Other (please specify below)" string), it won’t match any option in this select. In that case the browser will default to the first option and saving the form can silently change agency_type to "501c3/nonprofit". Consider normalizing any stored "Other…" value to "Other" for the selected/value so existing records don’t get clobbered on edit.
"Other"
],
selected: f.object.agency_type,
input_html: {
value: f.object.agency_type,
| raw = field_value("agency_type") | ||
| return if raw.blank? | ||
|
|
||
| label, _separator, specified = raw.strip.partition(":") | ||
| label = label.strip | ||
| other_text = FormField.other_option?(label) ? specified.strip.presence : nil | ||
| organization.update!(agency_type: label, agency_type_other: other_text) |
🤖 PR, suggested 👤 review level: 📖 Read — light-logic: refines the existing org-profile sync plus a small form-option change
What is the goal of this PR and why is this important?
agency_type_otherwas only ever set from the admin edit form."Other: <text>"), and the answer is split onto the linked organization: option label →agency_type, stripped free text →agency_type_other.How did you approach the change?
form_builder_service.rb: the agency-type option is now bare"Other", which auto-qualifies as a generic specify option (reveals the box, folds to"Other: <text>").organizations/_form.html.erb: org edit select now offers"Other"so the synced value renders selected.public_registration.rb:sync_organization_profilealready wroteagency_type(latest-wins) after the recent org-sync work on main; this replaces the plain write withsync_agency_type, which splits the label from the free text and fills/clearsagency_type_other. Same latest-wins / never-clobber-on-blank contract asapply_value;AhoyTrackablerecords before/after.Anything else to add?
"Other (please specify below)"option until re-seeded.sync_organization_profile); folded the "Other" split into that method rather than adding a parallel path.