fix: correctly distinguish between first participant and applicant
This commit is contained in:
@@ -9,12 +9,12 @@ use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
||||
use App\Form\Service\Condition\AdditionalServicesMutabilityCondition;
|
||||
use App\Form\Service\Condition\AgeRangeCondition;
|
||||
use App\Form\Service\Condition\ApplicantCondition;
|
||||
use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition;
|
||||
use App\Form\Service\Condition\BookingModeCondition;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
use App\Form\Service\Condition\FirstParticipantCondition;
|
||||
use App\Form\Service\Condition\PersonalDataMutabilityCondition;
|
||||
use App\Form\Service\Condition\PickupsMutabilityCondition;
|
||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
@@ -48,16 +48,14 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
$transportationServicesMutabilityCondition = new TransportationServicesMutabilityCondition();
|
||||
$pickupsMutabilityCondition = new PickupsMutabilityCondition();
|
||||
|
||||
// Personal data protection in edit mode has TWO rules:
|
||||
// 1. Applicant with personId (authenticated user) - prevents editing master personal data
|
||||
// Only applies to applicant (index 0), not other participants with personId
|
||||
// 2. BPN mutability flag (mutable=false) - respects BPN business rules for any participant
|
||||
// Hide fields if EITHER condition is true
|
||||
$applicantCondition = new ApplicantCondition();
|
||||
// Personal data protection in edit mode:
|
||||
// 1. Participant with personId (linked to BPN account) - edit via personal data form instead
|
||||
// 2. BPN mutability flag (mutable=false) - respects BPN business rules
|
||||
// Show fields as static text if EITHER condition is true
|
||||
$authenticatedUserCondition = new AuthenticatedUserPersonalDataCondition();
|
||||
$personalDataMutabilityCondition = new PersonalDataMutabilityCondition();
|
||||
$personalDataHiddenCondition = CompositeCondition::or(
|
||||
CompositeCondition::and($applicantCondition, $authenticatedUserCondition),
|
||||
$authenticatedUserCondition,
|
||||
$personalDataMutabilityCondition
|
||||
);
|
||||
|
||||
@@ -122,12 +120,12 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'hidden' => CompositeCondition::not($rentalCondition),
|
||||
];
|
||||
|
||||
// Age-dependent service fields - hidden until birth date provided (except for applicant who always has DOB)
|
||||
// Age-dependent service fields - hidden until birth date provided (except for first participant who always has DOB)
|
||||
// Also readonly if services not mutable
|
||||
// For applicant in edit mode: DOB is always available (patched from booking), so never hide
|
||||
// For first participant in edit mode: DOB is always available (patched from booking), so never hide
|
||||
$hideUntilDobCondition = CompositeCondition::and(
|
||||
CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
CompositeCondition::not(new ApplicantCondition()) // Don't hide for applicant
|
||||
CompositeCondition::not(new FirstParticipantCondition()) // Don't hide for first participant
|
||||
);
|
||||
|
||||
$this->fieldStateConditions['courses'] = [
|
||||
@@ -145,14 +143,14 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Skipass - hidden until birth date (except applicant), readonly if services not mutable
|
||||
// Skipass - hidden until birth date (except first participant), readonly if services not mutable
|
||||
$this->fieldStateConditions['skiPass'] = [
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Rentals - shown only when skipass selected, readonly if services not mutable
|
||||
// For applicant: only check skipass, not DOB
|
||||
// For first participant: only check skipass, not DOB
|
||||
$this->fieldStateConditions['rentals'] = [
|
||||
'hidden' => CompositeCondition::or(
|
||||
$hideUntilDobCondition,
|
||||
@@ -167,7 +165,7 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Transportation fields - hidden until birth date (except applicant), readonly if transportation not mutable
|
||||
// Transportation fields - hidden until birth date (except first participant), readonly if transportation not mutable
|
||||
$this->fieldStateConditions['transportationOutbound'] = [
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $transportationServicesMutabilityCondition,
|
||||
|
||||
Reference in New Issue
Block a user