wip: modernized edit flow
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Form\Service\Condition\ApplicantCondition;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
use App\Form\Service\Condition\InsuranceMutabilityCondition;
|
||||
use App\Form\Service\Condition\MutabilityCondition;
|
||||
use App\Form\Service\Condition\PickupsMutabilityCondition;
|
||||
use App\Form\Service\Condition\RentalSelectionCondition;
|
||||
@@ -43,7 +44,8 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
$transportationServicesMutabilityCondition = new TransportationServicesMutabilityCondition();
|
||||
$pickupsMutabilityCondition = new PickupsMutabilityCondition();
|
||||
|
||||
// Make all personal data fields readonly if not mutable OR if applicant
|
||||
// Make all personal data fields readonly if participant not mutable
|
||||
// Note: First participant is now treated as independent from applicant and can be edited
|
||||
$personalDataFields = [
|
||||
'firstName',
|
||||
'lastName',
|
||||
@@ -55,13 +57,15 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
];
|
||||
foreach ($personalDataFields as $field) {
|
||||
$this->fieldStateConditions[$field] = [
|
||||
'readonly' => CompositeCondition::or(
|
||||
new ApplicantCondition(),
|
||||
new MutabilityCondition()
|
||||
),
|
||||
'readonly' => CompositeCondition::not(new MutabilityCondition()),
|
||||
];
|
||||
}
|
||||
|
||||
// Address fields - readonly if participant not mutable
|
||||
$this->fieldStateConditions['address'] = [
|
||||
'readonly' => CompositeCondition::not(new MutabilityCondition()),
|
||||
];
|
||||
|
||||
// Conditional visibility for service fields (same as create flow)
|
||||
$rentalCondition = new RentalSelectionCondition();
|
||||
$skiPassCondition = new SkiPassSelectionCondition();
|
||||
@@ -72,33 +76,40 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'hidden' => CompositeCondition::not($rentalCondition),
|
||||
];
|
||||
|
||||
// Age-dependent service fields - hidden until birth date provided
|
||||
// Age-dependent service fields - hidden until birth date provided (except for applicant 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
|
||||
$hideUntilDobCondition = CompositeCondition::and(
|
||||
CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
CompositeCondition::not(new ApplicantCondition()) // Don't hide for applicant
|
||||
);
|
||||
|
||||
$this->fieldStateConditions['courses'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['additionalServices'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['board'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Skipass - hidden until birth date, readonly if services not mutable
|
||||
// Skipass - hidden until birth date (except applicant), readonly if services not mutable
|
||||
$this->fieldStateConditions['skiPass'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Rentals - shown only when skipass selected, readonly if services not mutable
|
||||
// For applicant: only check skipass, not DOB
|
||||
$this->fieldStateConditions['rentals'] = [
|
||||
'hidden' => CompositeCondition::or(
|
||||
CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
$hideUntilDobCondition,
|
||||
CompositeCondition::not($skiPassCondition)
|
||||
),
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
@@ -110,14 +121,14 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'readonly' => $additionalServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
// Transportation fields - hidden until birth date, readonly if transportation not mutable
|
||||
// Transportation fields - hidden until birth date (except applicant), readonly if transportation not mutable
|
||||
$this->fieldStateConditions['transportationOutbound'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $transportationServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
$this->fieldStateConditions['transportationInbound'] = [
|
||||
'hidden' => CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
'hidden' => $hideUntilDobCondition,
|
||||
'readonly' => $transportationServicesMutabilityCondition,
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user