You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add technical architecture and user journey diagrams for events system, enhance user guide with detailed event creation and management instructions
-**Geocoding Integration**: Background jobs for address geocoding
337
+
338
+
#### Location Selector Deep Dive
339
+
340
+
The location selector provides a sophisticated, user-friendly interface for managing event locations with three distinct types: Simple, Address, and Building. This system uses Stimulus controllers for dynamic UI management and custom backend processing for polymorphic location creation.
341
+
342
+
**Location Types Overview**
343
+
344
+
**Simple Location**
345
+
- Text-only location description (e.g., "Community Center", "Online via Zoom")
346
+
- Stored directly on the `LocatableLocation` model in the `name` field
347
+
- Best for virtual events, TBA locations, or simple venue references
348
+
- No geocoding or mapping features
349
+
350
+
**Address Location**
351
+
- Full postal address with geocoding capabilities
352
+
- Uses existing `Address` records or creates new ones inline
353
+
- Includes geocoding for mapping and directions
354
+
- Fields: line1, line2, city, state, postal_code, country, physical/postal flags
355
+
- Supports primary address designation
356
+
357
+
**Building Location**
358
+
- Named venues/facilities with associated addresses
359
+
- Uses existing `Building` records or creates new ones inline
360
+
- Buildings have their own address through association
361
+
- Perfect for institutions, community centers, schools
362
+
- Provides both building name and full address context
-**State Management**: Shows/hides location sections based on user selection
370
+
-**Form Clearing**: Clears irrelevant fields when switching location types
371
+
-**Accessibility**: Focuses first field in new forms, maintains keyboard navigation
372
+
373
+
**Key Methods:**
374
+
-`connect()`: Initialize form state based on existing data
375
+
-`toggleLocationType(event)`: Show appropriate location section
376
+
-`hideAllLocationTypes()`: Reset all location sections
377
+
-`showNewAddress(event)` / `showNewBuilding(event)`: Toggle inline creation forms
378
+
-`clearSimpleLocationFields()` / `clearStructuredLocationFields()`: Field cleanup
379
+
380
+
**Backend Processing**
381
+
382
+
The system uses a custom `location_attributes=` setter on `LocatableLocation` instead of Rails' standard `accepts_nested_attributes_for` due to polymorphic association complexity.
383
+
384
+
**Polymorphic Location Creation Flow:**
385
+
1. Form submission includes `location_attributes` nested in event params
386
+
2.`location_attributes=` setter determines location type from submitted data
387
+
3. For Address: Creates `Address` record with geocoding job scheduling
388
+
4. For Building: Creates `Building` with nested `Address`, handles attribute normalization
389
+
5.`LocatableLocation` polymorphic association points to appropriate location record
390
+
6. Geocoding jobs run in background for address-based locations
391
+
392
+
**Form Integration & UI**
393
+
394
+
**Inline Creation Features:**
395
+
- "New" buttons reveal inline forms without page navigation
396
+
- Address and Building forms use consistent partial rendering
397
+
- Form validation shows errors inline without losing user input
398
+
- Progressive enhancement: works without JavaScript (graceful degradation)
399
+
400
+
**Validation & Error Handling:**
401
+
- Model validations for Event, Address, Building, and LocatableLocation
402
+
- Form error display within respective location sections
403
+
- JavaScript preserves form state during error correction
404
+
- Backend error handling with graceful rollback protection
405
+
406
+
**Integration Points:**
407
+
- Authorization via policies for Address/Building creation
408
+
- Geocoding integration with background job processing
409
+
- Performance optimizations with efficient queries and selective loading
0 commit comments