feat: htmx powered requests, improved loading indicator

feat: loading indicator and htmx form submit
This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 023ecdebc9
commit 83589ee677
20 changed files with 658 additions and 197 deletions
+32 -12
View File
@@ -86,14 +86,17 @@ class BookingService
/**
* Saves the booking DTO to the session.
*
* @param Request $request The HTTP request with session
* @param object $bookingDto The booking DTO to persist
* @param string $mode The booking mode (create/edit)
* @param Request $request The HTTP request with session
* @param BookingDto $bookingDto The booking DTO to persist
* @param string $mode The booking mode (create/edit)
*/
public function saveBookingDto(Request $request, object $bookingDto, string $mode): void
public function saveBookingDto(Request $request, BookingDto $bookingDto, string $mode): void
{
$key = BookingDto::MODE_CREATE === $mode ? self::BOOKING_CREATE_KEY : self::BOOKING_EDIT_KEY;
$request->getSession()->set($key, $bookingDto);
// Track last session update for staleness detection
$bookingDto->lastSessionUpdate = new \DateTimeImmutable();
$sessionKey = $this->getSessionKey($mode);
$request->getSession()->set($sessionKey, $bookingDto);
}
/**
@@ -102,13 +105,18 @@ class BookingService
* @param Request $request The HTTP request containing session data
* @param string $mode The booking mode (create/edit)
*
* @return object|null The booking DTO from session or null if not found
* @return BookingDto|null The booking DTO from session or null if not found
*/
public function getBookingDto(Request $request, string $mode): ?object
public function getBookingDto(Request $request, string $mode): ?BookingDto
{
$key = BookingDto::MODE_CREATE === $mode ? self::BOOKING_CREATE_KEY : self::BOOKING_EDIT_KEY;
$sessionKey = $this->getSessionKey($mode);
$session = $request->getSession();
return $request->getSession()->get($key);
if (false === $session->has($sessionKey)) {
return null;
}
return $session->get($sessionKey);
}
/**
@@ -119,8 +127,20 @@ class BookingService
*/
public function clearBookingDto(Request $request, string $mode): void
{
$key = BookingDto::MODE_CREATE === $mode ? self::BOOKING_CREATE_KEY : self::BOOKING_EDIT_KEY;
$request->getSession()->remove($key);
$sessionKey = $this->getSessionKey($mode);
$request->getSession()->remove($sessionKey);
}
/**
* Generates session key based on mode.
*
* @param string $mode 'create' or 'edit'
*
* @return string The session key
*/
private function getSessionKey(string $mode): string
{
return BookingDto::MODE_EDIT === $mode ? self::BOOKING_EDIT_KEY : self::BOOKING_CREATE_KEY;
}
/**