diff --git a/src/BusProNet/DataProcessor/BookingDataProcessor.php b/src/BusProNet/DataProcessor/BookingDataProcessor.php index 2551e60..d9a5bb8 100644 --- a/src/BusProNet/DataProcessor/BookingDataProcessor.php +++ b/src/BusProNet/DataProcessor/BookingDataProcessor.php @@ -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]; } diff --git a/src/BusProNet/Model/Booking.php b/src/BusProNet/Model/Booking.php index a9ea3dd..16c3dae 100644 --- a/src/BusProNet/Model/Booking.php +++ b/src/BusProNet/Model/Booking.php @@ -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 * diff --git a/src/Controller/Booking/Edit/IndexController.php b/src/Controller/Booking/Edit/IndexController.php index d4eda3a..31297b9 100644 --- a/src/Controller/Booking/Edit/IndexController.php +++ b/src/Controller/Booking/Edit/IndexController.php @@ -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. */ diff --git a/src/Service/BookingEditDataLoaderService.php b/src/Service/BookingEditDataLoaderService.php index 9ceb557..23ce880 100644 --- a/src/Service/BookingEditDataLoaderService.php +++ b/src/Service/BookingEditDataLoaderService.php @@ -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 diff --git a/templates/booking/index.html.twig b/templates/booking/index.html.twig index 9f115a1..e41b47f 100644 --- a/templates/booking/index.html.twig +++ b/templates/booking/index.html.twig @@ -73,7 +73,7 @@