fix: show pickup select field for outbound bus travel only

This commit is contained in:
Björn Fromme
2026-02-19 08:22:52 +01:00
parent 0884a39f3d
commit 08aaff1e2d
3 changed files with 10 additions and 22 deletions
@@ -250,13 +250,10 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
),
];
// Show pickup only when either outbound or inbound transportation is BUS (hidden by default)
// Pickup field - shown only when outbound transportation is BUS (pickup is for outbound journey)
$this->fieldStateConditions['pickup'] = [
'hidden' => CompositeCondition::not(
CompositeCondition::or(
ServiceSubTypeCondition::equals('transportationOutbound', DirectionMapper::SUBTYPE_BUS_API),
ServiceSubTypeCondition::equals('transportationInbound', DirectionMapper::SUBTYPE_BUS_API)
)
ServiceSubTypeCondition::equals('transportationOutbound', DirectionMapper::SUBTYPE_BUS_API)
),
];
+2 -5
View File
@@ -186,13 +186,10 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
'readonly' => $transportationServicesMutabilityCondition,
];
// Pickup field (unified) - shown only when either transportation direction is BUS, readonly if pickups not mutable
// Pickup field - shown only when outbound transportation is BUS (pickup is for outbound journey), readonly if pickups not mutable
$this->fieldStateConditions['pickup'] = [
'hidden' => CompositeCondition::not(
CompositeCondition::or(
ServiceSubTypeCondition::equals('transportationOutbound', DirectionMapper::SUBTYPE_BUS_API),
ServiceSubTypeCondition::equals('transportationInbound', DirectionMapper::SUBTYPE_BUS_API)
)
ServiceSubTypeCondition::equals('transportationOutbound', DirectionMapper::SUBTYPE_BUS_API)
),
'readonly' => $pickupsMutabilityCondition,
];
@@ -9,13 +9,10 @@ use App\Form\Model\BookingDto;
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
/**
* Handles unified pickup location selection.
* Handles pickup location selection for the outbound bus journey.
*
* Pickup selection is only processed when either outbound or inbound
* transportation is bus type. Automatically clears pickup when both
* transportation services change to self-organized (PKW).
*
* The pickup applies to both directions and uses the outbound pickup list.
* Pickup is only processed when outbound transportation is bus type.
* Automatically clears pickup when outbound changes to self-organized (PKW).
*/
class ParticipantPickupFieldHandler extends AbstractParticipantFieldHandler
{
@@ -41,15 +38,12 @@ class ParticipantPickupFieldHandler extends AbstractParticipantFieldHandler
return;
}
// Check if either outbound or inbound transportation is bus
// Pickup applies only to outbound bus journey - clear when outbound is not bus
$hasOutboundBus = null !== $participant->transportationOutbound
&& DirectionMapper::SUBTYPE_BUS_API === $participant->transportationOutbound->subType;
$hasInboundBus = null !== $participant->transportationInbound
&& DirectionMapper::SUBTYPE_BUS_API === $participant->transportationInbound->subType;
// Only process pickup if at least one direction has bus transport
if (false === $hasOutboundBus && false === $hasInboundBus) {
$participant->pickup = null; // Clear pickup for non-bus transport
if (false === $hasOutboundBus) {
$participant->pickup = null;
return;
}