feat: prevent editing of applicant's personal data in booking

This commit is contained in:
Björn Fromme
2025-01-27 18:21:47 +01:00
parent 7fe0734dec
commit c75f069ce0
5 changed files with 108 additions and 53 deletions
+2 -1
View File
@@ -21,6 +21,7 @@ label.required:after {
@apply border-red-500;
}
input[disabled] {
input[disabled],
input[readonly] {
@apply cursor-not-allowed;
}
+1
View File
@@ -38,6 +38,7 @@ final class BookingType extends AbstractType
'additional_services_mutable' => $travelData->additionalServicesMutable,
'transportation_services_mutable' => $travelData->transportationServicesMutable,
'pickups_mutable' => $travelData->pickupsMutable,
'applicant_id' => $data->booking->applicant->personId,
],
'allow_add' => false,
+85 -48
View File
@@ -21,54 +21,6 @@ class ParticipantType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName', TextType::class, [
'label' => 'Vorname',
])
->add('lastName', TextType::class, [
'label' => 'Nachname',
])
->add('dateOfBirth', BirthdayType::class, [
'label' => 'Geburtsdatum',
'html5' => true,
'widget' => 'single_text',
'input' => 'datetime_immutable',
])
->add('gender', ChoiceType::class, [
'label' => 'Geschlecht',
'required' => false,
'placeholder' => 'keine Angabe',
'choices' => [
'männlich' => 'M',
'weiblich' => 'W',
'divers' => 'D',
],
])
->add('nationality', CountryType::class, [
'label' => 'Nationalität',
'property' => 'nationality',
'preferred_choices' => ['D', 'A', 'CH'],
])
->add('email', EmailType::class, [
'label' => 'E-Mail',
])
->add('mobile', TextType::class, [
'label' => 'Telefon (mobil)',
])
->add('height', IntegerType::class, [
'label' => 'Körpergröße [cm]',
'required' => false,
])
->add('shoeSize', IntegerType::class, [
'label' => 'Schuhgröße',
'required' => false,
])
->add('weight', IntegerType::class, [
'label' => 'Gewicht [kg]',
'required' => false,
])
;
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
/** @var ParticipantData $participantData */
$participantData = $event->getData();
@@ -76,6 +28,90 @@ class ParticipantType extends AbstractType
$form = $event->getForm();
// $personalDataMutable = $options['personal_data_mutable']
// && $participantData->personId !== $options['applicant_id'];
$personalDataMutable = $options['personal_data_mutable'];
$form
->add('firstName', TextType::class, [
'label' => 'Vorname',
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('lastName', TextType::class, [
'label' => 'Nachname',
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('dateOfBirth', BirthdayType::class, [
'label' => 'Geburtsdatum',
'html5' => true,
'widget' => 'single_text',
'input' => 'datetime_immutable',
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('gender', ChoiceType::class, [
'label' => 'Geschlecht',
'required' => false,
'placeholder' => 'keine Angabe',
'choices' => [
'männlich' => 'M',
'weiblich' => 'W',
'divers' => 'D',
],
'attr' => [
'readonly' => false === $personalDataMutable,
'style' => false === $personalDataMutable ? 'pointer-events: none' : null,
]
])
->add('nationality', CountryType::class, [
'label' => 'Nationalität',
'property' => 'nationality',
'preferred_choices' => ['D', 'A', 'CH'],
'attr' => [
'readonly' => false === $personalDataMutable,
'style' => false === $personalDataMutable ? 'pointer-events: none' : null,
]
])
->add('email', EmailType::class, [
'label' => 'E-Mail',
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('mobile', TextType::class, [
'label' => 'Telefon (mobil)',
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('height', IntegerType::class, [
'label' => 'Körpergröße [cm]',
'required' => false,
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('shoeSize', IntegerType::class, [
'label' => 'Schuhgröße',
'required' => false,
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
->add('weight', IntegerType::class, [
'label' => 'Gewicht [kg]',
'required' => false,
'attr' => [
'readonly' => false === $personalDataMutable,
]
])
;
$commonChoiceFieldOptions = [
'required' => false,
'multiple' => true,
@@ -268,6 +304,7 @@ class ParticipantType extends AbstractType
'additional_services_mutable' => true,
'transportation_services_mutable' => true,
'pickups_mutable' => true,
'applicant_id' => null,
'anti_xss' => true,
]);
}
+13 -3
View File
@@ -37,13 +37,13 @@
</div>
<div>
<h3 class="text-lg font-semibold">
Anmelder
Anmelder:in
</h3>
{{ bookingData.applicant.firstName }} {{ bookingData.applicant.name }}
</div>
<div>
<h3 class="text-lg font-semibold">
Anzahl Teilnehmer
Anzahl Teilnehmer:innen
</h3>
{{ bookingData.participants|length }}
</div>
@@ -76,7 +76,7 @@
Unterkunft: {{ mutableData.items['accommodation'].mutableBefore|date('d.m.Y') }}
</li>
<li>
Teilnehmer: {{ mutableData.items['participant_data'].mutableBefore|date('d.m.Y') }}
Teilnehmer:innen: {{ mutableData.items['participant_data'].mutableBefore|date('d.m.Y') }}
</li>
<li>
Zusatzleistungen: {{ mutableData.items['additional_services'].mutableBefore|date('d.m.Y') }}
@@ -102,6 +102,16 @@
</svg>
</div>
<div class="hidden" {{ stimulus_target('toggle', 'toggle') }}>
{#
{% if child.vars.data.personId == bookingData.applicant.personId %}
<div class="pt-4">
{% include '_partials/_alert.html.twig' with {
'level': 'info',
'messages': ['Bitte die persönlichen Daten über den Reiter \'Meine Daten\' bearbeiten']
} %}
</div>
{% endif %}
#}
<div class="flex flex-col space-y-4 pt-4">
<div class="relative">
<h3 class="text-xl font-semibold">
+7 -1
View File
@@ -108,7 +108,13 @@
{%- if disabled is defined and disabled == true -%}
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
{%- endif -%}
{{ parent() }}
{%- if attr.readonly is defined %}
<div class="cursor-not-allowed">
{{ parent() }}
</div>
{% else %}
{{ parent() }}
{% endif %}
{%- if disabled is defined and disabled == true -%}
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
{%- endif -%}