Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/controllers/reservations_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I would change is to not have a hard coded url path here. If you change the url in ReservationServiceController some will forget this place here probably.
Maybe you can pass a variable to twig in the ReservationServiceController, if direct access is detected and set a data-* attribut on the select element which is checked in the stimulus controller?

if (!isExplicitYearlyApartmentLink) {
this.getLocalTableSetting('apartment', 'reservations-apartment', 'int');
}
this.loadTableSettings(this.tableSettingsUrl, true);
}

Expand Down
8 changes: 6 additions & 2 deletions src/Controller/ReservationServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 8 additions & 1 deletion templates/Reservations/reservation_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@
<td class="text-center room-info"
data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right"
data-bs-content="{{ roomInfo }}" data-bs-trigger="hover"
>{{ row.apartment.number }}{% if row.apartment.roomCategory is not null and row.apartment.roomCategory.acronym|length > 0 %} ({{ row.apartment.roomCategory.acronym }}){% endif %}</td>
>
<a href="{{ path('start.toggle.view', {
show: 'yearly',
apartmentId: row.apartment.id
}) }}" title="{{ 'reservation.table.view.yearly'|trans }}">
{{ row.apartment.number }}{% if row.apartment.roomCategory is not null and row.apartment.roomCategory.acronym|length > 0 %} ({{ row.apartment.roomCategory.acronym }}){% endif %}
</a>
</td>
{% endif %}

{# ── Cells ── #}
Expand Down