feat: selectable drop-offs for inbound bus travel

This commit is contained in:
Björn Fromme
2026-02-17 11:53:39 +01:00
parent 41b0f56b5b
commit 0884a39f3d
31 changed files with 701 additions and 200 deletions
@@ -547,14 +547,14 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
// Uses outbound pickups list, applies to both directions
// Returns empty array when no pickup options available
$this->fieldOptionProviders['pickup'] = function (BookingDto $bookingDto, int $participantIndex, array $options = []): array {
$choices = $bookingDto->travel->pickupsOutbound;
$choices = $bookingDto->travel->pickups;
if (true === empty($choices)) {
return [];
}
return [
'label' => 'Zu- und Ausstieg',
'label' => 'Zustieg',
'choices' => $choices,
'choice_label' => fn (?Pickup $pickup) => $pickup?->getLabel(),
'choice_value' => 'id',
@@ -564,6 +564,43 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
];
};
// "Different drop-off" checkbox (BUS+BUS only)
$this->fieldOptionProviders['differentDropOff'] = fn (BookingDto $bookingDto, int $participantIndex, array $options = []) => [
'label' => 'abweichender Ausstieg',
'required' => false,
];
// Drop-off location (inbound direction)
// In BUS+BUS mode, gated by the differentDropOff checkbox state
// In PKW+BUS mode, shown directly (no checkbox involved)
$this->fieldOptionProviders['dropOff'] = function (BookingDto $bookingDto, int $participantIndex, array $options = []): array {
$choices = $bookingDto->travel->dropOffs;
if (true === empty($choices)) {
return [];
}
$participant = $bookingDto->getParticipant($participantIndex);
// In BUS+BUS mode: only show drop-off choices when checkbox is checked
$hasOutboundBus = null !== $participant?->transportationOutbound
&& DirectionMapper::SUBTYPE_BUS_API === $participant->transportationOutbound->subType;
if ($hasOutboundBus && false === ($participant->differentDropOff ?? false)) {
return [];
}
return [
'label' => 'Ausstieg',
'choices' => $choices,
'choice_label' => fn (?Pickup $pickup) => $pickup?->getLabel(),
'choice_value' => 'id',
'expanded' => true,
'multiple' => false,
'required' => true,
];
};
// Parking (conditional - only shown when outbound transportation is PKW)
// Simple checkbox since there's only ever one parking type
// Returns empty array when no parking services exist to prevent field from rendering