Skip to content

feat: add group address book and modal location pickers#108

Merged
mwoods79 merged 7 commits intomainfrom
feat/group-address-book
Mar 25, 2026
Merged

feat: add group address book and modal location pickers#108
mwoods79 merged 7 commits intomainfrom
feat/group-address-book

Conversation

@mwoods79
Copy link
Copy Markdown
Contributor

@mwoods79 mwoods79 commented Mar 15, 2026

Summary

  • Group Address Book: Add GroupLocation resource for saving reusable locations per group, with full CRUD management page at /groups/:slug/locations
  • Saved Location Picker: New SavedLocationPicker LiveComponent for selecting from a group's saved locations when creating/editing huddlz, with modal flow to add new addresses
  • Modal City Picker for Groups: Group create and edit forms use a route-based modal with LocationAutocomplete filtered to city/region types (locality, sublocality, administrative_area_level_2)
  • Coordinate Bypass: ApplyProvidedCoordinates change skips geocoding API calls when frontend provides lat/lng directly from Google Places autocomplete
  • Huddl Location Integration: Huddl create/edit forms use SavedLocationPicker to choose from group address book, with modal to add new addresses that save to the group

Key changes

  • New GroupLocation Ash resource with PostgreSQL migration
  • SavedLocationPicker and LocationAutocomplete LiveComponents with modal integration
  • ApplyProvidedCoordinates change for both Group and Huddl resources
  • Route-based modal pattern (live_action: :new_location) for location selection
  • 36 files changed, ~3100 insertions

Test plan

  • All 616 tests pass (mix precommit green)
  • Group address book CRUD (create, list, edit, delete locations)
  • Group create: modal city picker selects location, coordinates saved to DB
  • Group edit: modal city picker consistent with create form (no SavedLocationPicker regression)
  • Huddl create/edit: SavedLocationPicker shows group's saved locations
  • Huddl create/edit: modal adds new address to group address book
  • Cucumber feature scenarios for group management with location flow
  • Unit tests for ApplyProvidedCoordinates, GroupLocation resource, geocoding changes

- Add GroupLocation Ash resource with CRUD actions and policies
- Add SavedLocationPicker LiveComponent for huddl form integration
- Add routed modal for creating new addresses via Google Places
- Add group locations management page (/groups/:slug/locations)
- Add ApplyProvidedCoordinates change to skip geocoding for saved locations
- Add modal/1 component to core_components
- Update huddl form to use saved locations instead of inline autocomplete
- Wrap modal LocationAutocomplete in form element (fixes phx-change error)

New files:
- GroupLocation resource, SavedLocationPicker, Locations LiveView
- ApplyProvidedCoordinates change, migration

Tests: 608 passing (15 new covering locations page, modal, and resource)
- Show all saved locations immediately when clicking "Change location"
- Add cancel button (X) to restore previous selection
- Click-away also restores previous selection (safe default)
- Hide "Add new address" link when a location is already selected
…bypass

The geocode_if_changed function was checking changeset.attributes
for existing coordinates, which includes ALL attributes (defaults,
prior values) not just explicitly provided ones. This caused flaky
test failures when concurrent tests set latitude/longitude.

Now checks for :provided_latitude/:provided_longitude arguments,
which are the explicit signal from ApplyProvidedCoordinates.
… flaky tests

Root cause: provided_latitude/provided_longitude were public arguments
on the huddl create/update actions. Ash.Generator auto-generates random
float values for public arguments, so concurrent tests randomly populated
these coordinates, causing ApplyProvidedCoordinates to bypass geocoding
unexpectedly.

- Mark provided_latitude/longitude as public?: false on both actions
- Use before_submit + force_set_argument to pass coordinates from
  the LiveView form (private args can't be set via form params)
- Add deterministic unit test for geocode_if_changed that catches the
  bug: constructs a changeset with pre-existing lat/lng attributes and
  verifies geocoding still runs when provided_* arguments are absent
- Update existing tests to set private arguments before for_create
- Replace inline LocationAutocomplete with route-based modal pattern
  on both group create and edit forms
- Modal filters to city/region types (locality, sublocality,
  administrative_area_level_2) for consistent UX
- Add ApplyProvidedCoordinates change to bypass geocoding when
  coordinates are provided from the frontend
- Add provided_latitude/longitude arguments to create_group and
  update_details actions
- Use force_change_attribute in before_submit to set coordinates
  directly (before_submit runs after action changes)
- Add tests verifying city picker UI, modal content, and
  clear/set/save flow on the edit page
…helpers

- Extract ApplyProvidedCoordinates to shared Huddlz.Geocoding module,
  removing duplicate Group and Huddl versions
- Move load_group_locations/2 to FormHelpers, removing duplicates from
  Edit, New, and Locations LiveViews
- Add missing @impl true annotations on handle_event/handle_info callbacks
- Extract reset_modal_state/1 helper in Locations LiveView
- Skip redundant group reload in Locations handle_params when slug unchanged
…licate group helpers

- Fix prepare_source_with_coordinates to use force_change_attribute
  instead of force_set_argument, since before_submit runs after
  for_create (Ash changes have already executed by that point)
- Extract inject_group_location_param and apply_group_location_to_form
  to FormHelpers, removing duplicates from GroupLive.New and Edit
@mwoods79 mwoods79 merged commit d364e68 into main Mar 25, 2026
1 check passed
@mwoods79 mwoods79 deleted the feat/group-address-book branch March 25, 2026 02:21
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