feat: always load fresh api data when starting to edit booking
This commit is contained in:
@@ -233,7 +233,8 @@ class BookingDataProcessor
|
||||
$participant->transportationInbound = $travel->transportationServices[$participant->transportationInbound->id];
|
||||
}
|
||||
|
||||
// Enrich pickup
|
||||
// Enrich pickup (only outbound - API limitation: pickups are only supported when
|
||||
// outbound transportation is bus; inbound-only bus bookings cannot have pickups)
|
||||
if (null !== $participant->pickup && isset($travel->pickupsOutbound[$participant->pickup->id])) {
|
||||
$participant->pickup = $travel->pickupsOutbound[$participant->pickup->id];
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ class Booking
|
||||
* Retrieves pickup service for a specific participant.
|
||||
*
|
||||
* Finds the pickup service assigned to the specified participant
|
||||
* from the outbound pickup services.
|
||||
* from the outbound pickup services. The API only supports pickups
|
||||
* when outbound transportation is bus.
|
||||
*
|
||||
* @param int $participantIndex The participant index to search for
|
||||
*
|
||||
|
||||
@@ -59,6 +59,22 @@ class IndexController extends AbstractController
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for editing a booking from the booking list.
|
||||
*
|
||||
* Clears any existing session data and API cache to ensure fresh data
|
||||
* is loaded, then redirects to the main edit page.
|
||||
*/
|
||||
#[Route('/bookings/{id}/edit/start', name: 'app_booking_edit_start', requirements: ['id' => '\d+'])]
|
||||
#[IsGranted('ROLE_USER')]
|
||||
public function start(int $id, Request $request): Response
|
||||
{
|
||||
$this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT);
|
||||
$this->dataLoader->invalidateBookingCache($id);
|
||||
|
||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display participant cards overview.
|
||||
*/
|
||||
|
||||
@@ -54,11 +54,14 @@ class BookingEditDataLoaderService
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads booking data from session or initializes from API on first load.
|
||||
* Loads booking data from session or initializes from API.
|
||||
*
|
||||
* Validates that any cached session data matches the requested booking ID.
|
||||
* If a different booking is in session, it is cleared and fresh data is loaded.
|
||||
* If a draft exists for this user and booking, it is automatically applied.
|
||||
* Uses session data if available and valid (same booking ID). This preserves
|
||||
* participant edits between form submissions within the same edit session.
|
||||
*
|
||||
* If no session data exists, loads fresh data from API. If a draft exists,
|
||||
* it is automatically applied on top of the fresh API data to restore
|
||||
* pending user edits.
|
||||
*
|
||||
* @param Request $request The HTTP request
|
||||
* @param int $bookingId The booking ID to load
|
||||
|
||||
Reference in New Issue
Block a user