fix: adapt changes in create mode for edit mode, cleanup

This commit is contained in:
Björn Fromme
2025-10-24 17:30:41 +02:00
parent b63804df88
commit ba0eab9e96
5 changed files with 82 additions and 79 deletions
+30 -1
View File
@@ -8,6 +8,7 @@ use App\BusProNet\Utility\DirectionMapper;
use App\Form\Service\Abstract\AbstractFieldStateProvider;
use App\Form\Service\Condition\AdditionalServicesMutabilityCondition;
use App\Form\Service\Condition\ApplicantCondition;
use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition;
use App\Form\Service\Condition\CompositeCondition;
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
use App\Form\Service\Condition\FieldValueCondition;
@@ -43,7 +44,12 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
$transportationServicesMutabilityCondition = new TransportationServicesMutabilityCondition();
$pickupsMutabilityCondition = new PickupsMutabilityCondition();
// Authenticated user personal data protection
// Hide personal data fields for participants linked to BPN accounts (prevents duplicate records)
$authenticatedUserCondition = new AuthenticatedUserPersonalDataCondition();
// Make all personal data fields readonly if participant not mutable
// OR hidden if participant is linked to BPN account (authenticated user)
// Note: First participant is now treated as independent from applicant and can be edited
$personalDataFields = [
'firstName',
@@ -56,15 +62,38 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
];
foreach ($personalDataFields as $field) {
$this->fieldStateConditions[$field] = [
'hidden' => $authenticatedUserCondition,
'readonly' => CompositeCondition::not(new MutabilityCondition()),
];
}
// Address fields - readonly if participant not mutable
// Address fields - hidden for authenticated users, readonly if participant not mutable
$this->fieldStateConditions['address'] = [
'hidden' => $authenticatedUserCondition,
'readonly' => CompositeCondition::not(new MutabilityCondition()),
];
// Address subfields - must be hidden to prevent creating duplicate BPN records
$this->fieldStateConditions['address.street'] = [
'hidden' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.postCode'] = [
'hidden' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.city'] = [
'hidden' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.country'] = [
'hidden' => $authenticatedUserCondition,
];
$this->fieldStateConditions['address.district'] = [
'hidden' => $authenticatedUserCondition,
];
// Conditional visibility for service fields (same as create flow)
$rentalCondition = new RentalSelectionCondition();
$skiPassCondition = new SkiPassSelectionCondition();