diff --git a/assets/controllers/reservations_controller.js b/assets/controllers/reservations_controller.js index 4a94a857..1daf750a 100644 --- a/assets/controllers/reservations_controller.js +++ b/assets/controllers/reservations_controller.js @@ -134,7 +134,11 @@ export default class extends Controller { } this.getLocalTableSetting('interval', 'reservations-intervall', 'int'); this.getLocalTableSetting('holidayCountry', 'reservations-table-holidaycountry'); - this.getLocalTableSetting('apartment', 'reservations-apartment', 'int'); + // Use stored apartment filter only if not explicitly set in URL + const isExplicitYearlyApartmentLink = /\/view\/yearly\/\d+$/.test(window.location.pathname); + if (!isExplicitYearlyApartmentLink) { + this.getLocalTableSetting('apartment', 'reservations-apartment', 'int'); + } this.loadTableSettings(this.tableSettingsUrl, true); } diff --git a/src/Controller/ReservationServiceController.php b/src/Controller/ReservationServiceController.php index 7055d544..5ccffcd7 100644 --- a/src/Controller/ReservationServiceController.php +++ b/src/Controller/ReservationServiceController.php @@ -109,10 +109,14 @@ public function indexAction(ManagerRegistry $doctrine, RequestStack $requestStac /** * Triggered by the buttons to switch reservation view table/yearly. */ - #[Route('/view/{show}', name: 'start.toggle.view', methods: ['GET'])] - public function indexActionToggle(RequestStack $requestStack, string $show): Response + #[Route('/view/{show}/{apartmentId}', name: 'start.toggle.view', defaults: ['apartmentId' => null], requirements: ['show' => 'table|yearly', 'apartmentId' => '\\d+'], methods: ['GET'])] + public function indexActionToggle(RequestStack $requestStack, Request $request, string $show, ?int $apartmentId = null): Response { if ('yearly' === $show) { + if (null !== $apartmentId) { + $requestStack->getSession()->set('reservation-overview-apartment', $apartmentId); + } + $requestStack->getSession()->set('reservation-overview', 'yearly'); } else { $requestStack->getSession()->set('reservation-overview', 'table'); diff --git a/templates/Reservations/reservation_table.html.twig b/templates/Reservations/reservation_table.html.twig index f52130c8..7849bf53 100644 --- a/templates/Reservations/reservation_table.html.twig +++ b/templates/Reservations/reservation_table.html.twig @@ -117,7 +117,14 @@ {{ row.apartment.number }}{% if row.apartment.roomCategory is not null and row.apartment.roomCategory.acronym|length > 0 %} ({{ row.apartment.roomCategory.acronym }}){% endif %} + > + + {{ row.apartment.number }}{% if row.apartment.roomCategory is not null and row.apartment.roomCategory.acronym|length > 0 %} ({{ row.apartment.roomCategory.acronym }}){% endif %} + + {% endif %} {# ── Cells ── #}