Commit graph

21 commits

Author SHA1 Message Date
Claude
09b16ebd7f
Refactor: Use proper boolean casting for sharing parameters
- Replace string comparisons ('1', '0') with ActiveModel::Type::Boolean
- More robust handling of truthy/falsy values
- Follows Rails conventions for type coercion
- HTML forms still send string values, but controller properly converts them
2025-11-07 12:52:30 +00:00
Claude
53ec557ec9
Refactor: Nest sharing parameters under trip key
- Follow Rails conventions by nesting sharing params under resource key
- Update form fields: sharing[enabled] → trip[sharing][enabled]
- Update controller to access params[:trip][:sharing]
- Update all request specs to use nested parameters
- Parameters now properly structured as trip[sharing][expiration], etc.
2025-11-07 12:50:39 +00:00
Claude
a0674585d4
Fix: Add early return for sharing-only updates
- When only updating sharing settings, return immediately after handling
- Prevents ParameterMissing error when trip params are not present
- Sharing updates don't require trip model params
- Follows Rails best practice of 'redirect ... and return' pattern
2025-11-07 12:48:14 +00:00
Eugene Burmakin
f37bedb86b Update migration 2025-11-07 13:41:34 +01:00
Claude
b1cbb5555f
Refactor: Apply Rails best practices to trip sharing implementation
- Remove unused @is_public_view variable from controller
- Simplify conditionals by leveraging methods that return [] when empty
- Move public view from trips/public_show to shared/trips/show (Rails conventions)
- Refactor trips#update to be HTML-only (remove JSON responses)
- Convert sharing form to use proper Rails form helpers
- Move JS controller to shared/ subdirectory with proper namespacing
- Create RSpec shared examples for Shareable concern to eliminate duplication
- Update request specs to match HTML-only controller behavior
- Apply 'render/redirect ... and return' pattern for early returns
2025-11-07 12:05:34 +00:00
Claude
429f90e666
Refactor: Apply Rails best practice for early returns
Follow Rails convention of using "render/redirect ... and return"
instead of standalone return statements in controller actions.

## Changes

**Shared::TripsController#show**
Before:
```ruby
unless @trip&.public_accessible?
  return redirect_to root_path, alert: '...'
end
```

After:
```ruby
redirect_to root_path, alert: '...' and return unless @trip&.public_accessible?
```

**TripsController#update**
Before:
```ruby
if params[:sharing]
  return update_sharing
end
```

After:
```ruby
update_sharing and return if params[:sharing]
```

## Benefits
- More idiomatic Rails code
- Clearer intent with single-line guard clauses
- Prevents potential double render issues
- Follows community best practices
2025-11-07 11:49:05 +00:00
Claude
9fba3ce4ca
Refactor: Move trip sharing management to trips#update
Simplifies architecture by using the existing trips#update route for
sharing settings management instead of a separate route.

## Changes

**Routes**
- Removed: PATCH /trips/:id/sharing → shared/trips#update
- Now uses: PATCH /trips/:id (existing route) with sharing params

**Controllers**
- Shared::TripsController: Simplified to only handle public view (show)
- TripsController: Added update_sharing private method to handle
  sharing params when present

**Views**
- Updated JavaScript in _sharing.html.erb to use trip_path with
  nested sharing params

**Tests**
- Updated request specs to use trip_path instead of sharing_trip_path
- All params now nested under sharing key

## Benefits
- Cleaner namespace separation (Shared:: only for public access)
- Follows Rails conventions (one update route handles everything)
- Simpler routing structure
- Reduced code duplication

## Backwards Compatibility
This is a breaking change for the sharing API endpoint, but since
this feature was just implemented and hasn't been released yet,
no migration path is needed.
2025-11-05 15:54:42 +00:00
Eugene Burmakin
57ecda2b1b Extract stats sharing logic to its own controller 2025-09-12 21:08:45 +02:00
Eugene Burmakin
6defd4d8d0 Update distance unit in trip page 2025-05-19 19:10:07 +02:00
Eugene Burmakin
c69d4f45f1 Update views and specs 2025-05-16 19:53:42 +02:00
Eugene Burmakin
96108b12d0 Update tests a bit 2025-05-15 22:58:04 +02:00
Eugene Burmakin
088d8b14c2 Calculate trip data in the background 2025-05-15 21:33:01 +02:00
Eugene Burmakin
6fac14675b Restrict to some functionality access for inactive users 2025-02-19 21:23:11 +01:00
Eugene Burmakin
1e7efbc9af Render trips using precalculated paths instead of list of coordinates 2025-01-24 14:54:10 +01:00
Eugene Burmakin
d6b88ae9cb Move photos fetching for trips to a separate service 2024-12-10 19:31:52 +01:00
Eugene Burmakin
782aeb89af Add distance calculation and trip cards to trips index 2024-11-28 15:29:17 +01:00
Eugene Burmakin
e8842a9476 Implement rendering the route when the dates if the trip are changed 2024-11-28 13:20:03 +01:00
Eugene Burmakin
2cfc485f12 Add Trix editor to trips 2024-11-28 12:00:54 +01:00
Eugene Burmakin
c689051472 Show some photos from the trip 2024-11-28 10:40:08 +01:00
Eugene Burmakin
9522f81abf Move fetchAndDisplayPhotos to maps/helpers.js 2024-11-27 21:37:21 +01:00
Eugene Burmakin
198bf3128a Add trips model and scaffold controller 2024-11-27 20:14:17 +01:00