fix: streamlined single room selection handling
This commit is contained in:
@@ -14,6 +14,7 @@ use App\BusProNet\Utility\DirectionMapper;
|
|||||||
use App\Form\Model\BankAccountDto;
|
use App\Form\Model\BankAccountDto;
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
|
use App\Form\Model\RoomSelectionDto;
|
||||||
use App\Service\BookingPriceCalculatorService;
|
use App\Service\BookingPriceCalculatorService;
|
||||||
use App\Service\InsuranceService;
|
use App\Service\InsuranceService;
|
||||||
|
|
||||||
@@ -132,6 +133,22 @@ class BookingDataProcessor
|
|||||||
$dto->participants[$index] = $participantData;
|
$dto->participants[$index] = $participantData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rebuild roomSelections array from booking room data
|
||||||
|
// This is needed for conditions like SingleRoomTypeCondition that rely on roomSelections
|
||||||
|
// The booking already contains rooms with actual quantities (anzahl from XML)
|
||||||
|
$availableRooms = $travel->getAvailableRooms();
|
||||||
|
foreach ($booking->rooms as $bookingRoom) {
|
||||||
|
$room = $availableRooms[$bookingRoom->id] ?? null;
|
||||||
|
if (null !== $room && null !== $bookingRoom->totalCount && $bookingRoom->totalCount > 0) {
|
||||||
|
$roomSelection = new RoomSelectionDto();
|
||||||
|
$roomSelection->roomId = $bookingRoom->id;
|
||||||
|
$roomSelection->roomLabel = $room->label;
|
||||||
|
$roomSelection->roomPrice = $room->price;
|
||||||
|
$roomSelection->quantity = $bookingRoom->totalCount; // Actual quantity from booking XML (anzahl)
|
||||||
|
$dto->roomSelections[] = $roomSelection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $dto;
|
return $dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,9 +262,9 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
|||||||
'required' => new ApplicantCondition(),
|
'required' => new ApplicantCondition(),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Hide assignedRoomId field when only one room type is selected (auto-assigned by RoomAssignmentService)
|
// Render assignedRoomId field as static text when only one room type is selected (auto-assigned by RoomAssignmentService)
|
||||||
$this->fieldStateConditions['assignedRoomId'] = [
|
$this->fieldStateConditions['assignedRoomId'] = [
|
||||||
'hidden' => new SingleRoomTypeCondition(),
|
'static_text' => new SingleRoomTypeCondition(),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Example field state conditions would be registered here
|
// Example field state conditions would be registered here
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Form\Service\Condition\PersonalDataMutabilityCondition;
|
|||||||
use App\Form\Service\Condition\PickupsMutabilityCondition;
|
use App\Form\Service\Condition\PickupsMutabilityCondition;
|
||||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||||
use App\Form\Service\Condition\ServiceSubTypeCondition;
|
use App\Form\Service\Condition\ServiceSubTypeCondition;
|
||||||
|
use App\Form\Service\Condition\SingleRoomTypeCondition;
|
||||||
use App\Form\Service\Condition\SkiPassSelectionCondition;
|
use App\Form\Service\Condition\SkiPassSelectionCondition;
|
||||||
use App\Form\Service\Condition\TransportationServicesMutabilityCondition;
|
use App\Form\Service\Condition\TransportationServicesMutabilityCondition;
|
||||||
|
|
||||||
@@ -96,6 +97,12 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
|||||||
'static_text' => $personalDataHiddenCondition,
|
'static_text' => $personalDataHiddenCondition,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Render assignedRoomId field as static text when only one room type is selected (auto-assigned by RoomAssignmentService)
|
||||||
|
// Same logic as create mode - render as static text when only one room type available
|
||||||
|
$this->fieldStateConditions['assignedRoomId'] = [
|
||||||
|
'static_text' => new SingleRoomTypeCondition(),
|
||||||
|
];
|
||||||
|
|
||||||
// Conditional visibility for service fields (same as create flow)
|
// Conditional visibility for service fields (same as create flow)
|
||||||
$rentalCondition = new RentalSelectionCondition();
|
$rentalCondition = new RentalSelectionCondition();
|
||||||
$skiPassCondition = new SkiPassSelectionCondition();
|
$skiPassCondition = new SkiPassSelectionCondition();
|
||||||
|
|||||||
@@ -136,22 +136,16 @@
|
|||||||
|
|
||||||
{# Room assignment #}
|
{# Room assignment #}
|
||||||
<div class="grid grid-cols-2 gap-4">
|
<div class="grid grid-cols-2 gap-4">
|
||||||
{% if form.assignedRoomId is defined %}
|
{% set assignedRoom = bookingDto.travel.getRoomById(form.vars.data.participant.assignedRoomId) %}
|
||||||
{{ form_row(form.assignedRoomId, {
|
{% set roomLabel = assignedRoom ? assignedRoom.label : 'Kein Zimmer zugewiesen' %}
|
||||||
'attr': {
|
{{ macros.field_or_static(form, 'assignedRoomId', 'Zimmer', roomLabel, bookingDto, participantIndex, {
|
||||||
'hx-trigger': 'change',
|
'attr': {
|
||||||
'hx-post': path(refreshRouteName, refreshRouteParams|default({index: participantIndex})),
|
'hx-trigger': 'change',
|
||||||
'hx-target': '#main-content',
|
'hx-post': path(refreshRouteName, refreshRouteParams|default({index: participantIndex})),
|
||||||
'hx-swap': 'innerHTML'
|
'hx-target': '#main-content',
|
||||||
}
|
'hx-swap': 'innerHTML'
|
||||||
}) }}
|
}
|
||||||
{% else %}
|
}) }}
|
||||||
{# Display room label directly when only one room type selected (auto-assigned) #}
|
|
||||||
<div>
|
|
||||||
<label class="font-semibold mb-1 block">Zimmer</label>
|
|
||||||
<div class="text-sm text-gray-600">{{ bookingDto.singleRoomLabel }}</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if form.remarksRoom is defined %}
|
{% if form.remarksRoom is defined %}
|
||||||
{{ form_row(form.remarksRoom) }}
|
{{ form_row(form.remarksRoom) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user