feat: remove room selection field entirely for single room type

addresses #869axcukn
This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent 38656e73c5
commit 37cda348b0
4 changed files with 56 additions and 13 deletions
+24
View File
@@ -151,6 +151,30 @@ class BookingDto
return null !== $this->booking && 'O' === $this->booking->status;
}
/**
* Gets the label of the single selected room type.
*
* Returns the room label when exactly one room type is selected (auto-assignment scenario).
* Used by templates to display the room assignment when the dropdown is hidden.
*
* @return string|null The room label or null if not a single room type scenario
*/
public function getSingleRoomLabel(): ?string
{
$selectedRooms = $this->getSelectedRooms();
// Only return label when exactly one room type selected
if (1 !== count($selectedRooms)) {
return null;
}
$roomSelection = reset($selectedRooms);
$availableRooms = $this->travel->getAvailableRooms();
$room = $availableRooms[$roomSelection->roomId] ?? null;
return $room?->label;
}
#[Assert\Callback(callback: 'validateRoomSelection', groups: ['booking_create_step_1'])]
public function validateRoomSelection(ExecutionContextInterface $context): void
{
@@ -205,9 +205,9 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
'required' => new ApplicantCondition(),
];
// Make assignedRoomId readonly when only one room type is selected
// Hide assignedRoomId field when only one room type is selected (auto-assigned by RoomAssignmentService)
$this->fieldStateConditions['assignedRoomId'] = [
'readonly' => new SingleRoomTypeCondition(),
'hidden' => new SingleRoomTypeCondition(),
];
// Example field state conditions would be registered here