feat: improved mutability checks for personal data in edit or create mode
This commit is contained in:
@@ -12,7 +12,7 @@ use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
use App\Form\Service\Condition\MutabilityCondition;
|
||||
use App\Form\Service\Condition\PersonalDataMutabilityCondition;
|
||||
use App\Form\Service\Condition\PickupsMutabilityCondition;
|
||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
use App\Form\Service\Condition\ServiceSubTypeCondition;
|
||||
@@ -44,13 +44,21 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
$transportationServicesMutabilityCondition = new TransportationServicesMutabilityCondition();
|
||||
$pickupsMutabilityCondition = new PickupsMutabilityCondition();
|
||||
|
||||
// Authenticated user personal data protection
|
||||
// Render personal data fields as static text for participants linked to BPN accounts (prevents duplicate records)
|
||||
// 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();
|
||||
$authenticatedUserCondition = new AuthenticatedUserPersonalDataCondition();
|
||||
$personalDataMutabilityCondition = new PersonalDataMutabilityCondition();
|
||||
$personalDataHiddenCondition = CompositeCondition::or(
|
||||
CompositeCondition::and($applicantCondition, $authenticatedUserCondition),
|
||||
$personalDataMutabilityCondition
|
||||
);
|
||||
|
||||
// Make all personal data fields readonly if participant not mutable
|
||||
// OR static text if participant is linked to BPN account (authenticated user)
|
||||
// Note: First participant is now treated as independent from applicant and can be edited
|
||||
// Render all personal data fields as static text if authenticated user OR BPN indicates not mutable
|
||||
// Using 'static_text' state (not 'hidden') so template renders values as static text
|
||||
$personalDataFields = [
|
||||
'firstName',
|
||||
'lastName',
|
||||
@@ -62,36 +70,30 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
];
|
||||
foreach ($personalDataFields as $field) {
|
||||
$this->fieldStateConditions[$field] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'readonly' => CompositeCondition::not(new MutabilityCondition()),
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
}
|
||||
|
||||
// Address fields - static text for authenticated users, readonly if participant not mutable
|
||||
// Address fields - render as static text if authenticated user OR participant not mutable
|
||||
$this->fieldStateConditions['address'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'readonly' => CompositeCondition::not(new MutabilityCondition()),
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
// Address subfields - must render as static text to prevent creating duplicate BPN records
|
||||
// Address subfields - render as static text if authenticated user OR participant not mutable
|
||||
$this->fieldStateConditions['address.street'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['address.postCode'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['address.city'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['address.country'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['address.district'] = [
|
||||
'static_text' => $authenticatedUserCondition,
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
// Conditional visibility for service fields (same as create flow)
|
||||
|
||||
Reference in New Issue
Block a user