feat: prevent editing of applicant's personal data in booking
This commit is contained in:
@@ -21,6 +21,7 @@ label.required:after {
|
|||||||
@apply border-red-500;
|
@apply border-red-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[disabled] {
|
input[disabled],
|
||||||
|
input[readonly] {
|
||||||
@apply cursor-not-allowed;
|
@apply cursor-not-allowed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ final class BookingType extends AbstractType
|
|||||||
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
||||||
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
||||||
'pickups_mutable' => $travelData->pickupsMutable,
|
'pickups_mutable' => $travelData->pickupsMutable,
|
||||||
|
'applicant_id' => $data->booking->applicant->personId,
|
||||||
|
|
||||||
],
|
],
|
||||||
'allow_add' => false,
|
'allow_add' => false,
|
||||||
|
|||||||
@@ -21,54 +21,6 @@ class ParticipantType extends AbstractType
|
|||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
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) {
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||||
/** @var ParticipantData $participantData */
|
/** @var ParticipantData $participantData */
|
||||||
$participantData = $event->getData();
|
$participantData = $event->getData();
|
||||||
@@ -76,6 +28,90 @@ class ParticipantType extends AbstractType
|
|||||||
|
|
||||||
$form = $event->getForm();
|
$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 = [
|
$commonChoiceFieldOptions = [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
@@ -268,6 +304,7 @@ class ParticipantType extends AbstractType
|
|||||||
'additional_services_mutable' => true,
|
'additional_services_mutable' => true,
|
||||||
'transportation_services_mutable' => true,
|
'transportation_services_mutable' => true,
|
||||||
'pickups_mutable' => true,
|
'pickups_mutable' => true,
|
||||||
|
'applicant_id' => null,
|
||||||
'anti_xss' => true,
|
'anti_xss' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text-lg font-semibold">
|
<h3 class="text-lg font-semibold">
|
||||||
Anmelder
|
Anmelder:in
|
||||||
</h3>
|
</h3>
|
||||||
{{ bookingData.applicant.firstName }} {{ bookingData.applicant.name }}
|
{{ bookingData.applicant.firstName }} {{ bookingData.applicant.name }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text-lg font-semibold">
|
<h3 class="text-lg font-semibold">
|
||||||
Anzahl Teilnehmer
|
Anzahl Teilnehmer:innen
|
||||||
</h3>
|
</h3>
|
||||||
{{ bookingData.participants|length }}
|
{{ bookingData.participants|length }}
|
||||||
</div>
|
</div>
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
Unterkunft: {{ mutableData.items['accommodation'].mutableBefore|date('d.m.Y') }}
|
Unterkunft: {{ mutableData.items['accommodation'].mutableBefore|date('d.m.Y') }}
|
||||||
</li>
|
</li>
|
||||||
<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>
|
||||||
<li>
|
<li>
|
||||||
Zusatzleistungen: {{ mutableData.items['additional_services'].mutableBefore|date('d.m.Y') }}
|
Zusatzleistungen: {{ mutableData.items['additional_services'].mutableBefore|date('d.m.Y') }}
|
||||||
@@ -102,6 +102,16 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden" {{ stimulus_target('toggle', 'toggle') }}>
|
<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="flex flex-col space-y-4 pt-4">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<h3 class="text-xl font-semibold">
|
<h3 class="text-xl font-semibold">
|
||||||
|
|||||||
@@ -108,7 +108,13 @@
|
|||||||
{%- if disabled is defined and disabled == true -%}
|
{%- if disabled is defined and disabled == true -%}
|
||||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{ parent() }}
|
{%- if attr.readonly is defined %}
|
||||||
|
<div class="cursor-not-allowed">
|
||||||
|
{{ parent() }}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ parent() }}
|
||||||
|
{% endif %}
|
||||||
{%- if disabled is defined and disabled == true -%}
|
{%- if disabled is defined and disabled == true -%}
|
||||||
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|||||||
Reference in New Issue
Block a user