fix: prevent updating booked services unless mutable
This commit is contained in:
@@ -21,7 +21,7 @@ label.required:after {
|
||||
@apply border-red-500;
|
||||
}
|
||||
|
||||
input[disabled],
|
||||
input[readonly] {
|
||||
@apply cursor-not-allowed;
|
||||
input[readonly],
|
||||
select[readonly] {
|
||||
@apply pointer-events-none;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class ParticipantType extends AbstractType
|
||||
number_format($price, 2, ',', '.')
|
||||
);
|
||||
},
|
||||
'choice_attr' => function (?Service $service) {
|
||||
'choice_attr' => function (?Service $service) use ($options) {
|
||||
$attributes = [
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'booking#toggle',
|
||||
@@ -158,24 +158,28 @@ class ParticipantType extends AbstractType
|
||||
// forcibly select mandatory services
|
||||
if (true === $service->mandatory) {
|
||||
$attributes['checked'] = true;
|
||||
$attributes['disabled'] = true;
|
||||
$attributes['readonly'] = true;
|
||||
$attributes['class'] = 'text-pink';
|
||||
$attributes['tooltip'] = 'Diese Leistung ist nicht abwählbar';
|
||||
}
|
||||
|
||||
// disable selection of services only available in booking data
|
||||
if (Service::SOURCE_BOOKING === $service->source) {
|
||||
$attributes['disabled'] = true;
|
||||
$attributes['class'] = 'text-pink';
|
||||
}
|
||||
|
||||
// disable selection of services that are unavailable according to their status
|
||||
if (Service::STATUS_BLOCKED === $service->status) {
|
||||
$attributes['checked'] = false;
|
||||
$attributes['disabled'] = true;
|
||||
$attributes['readonly'] = true;
|
||||
$attributes['tooltip'] = 'Diese Leistung ist derzeit leider nicht buchbar';
|
||||
}
|
||||
|
||||
if (false === $options['additional_services_mutable']) {
|
||||
$attributes['readonly'] = true;
|
||||
$attributes['tooltip'] = 'Diese Leistung kann nicht mehr geändert werden';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
},
|
||||
'choice_filter' => function (?Service $service) use ($participantData) {
|
||||
@@ -233,6 +237,19 @@ class ParticipantType extends AbstractType
|
||||
}
|
||||
|
||||
// Transportation
|
||||
$transportationChoiceAttributes = function (?Service $service) use ($options) {
|
||||
$attributes = [
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'select-toggle#toggle booking#toggle',
|
||||
'data-select-toggle-value' => $service->subType,
|
||||
];
|
||||
if (false === $options['transportation_services_mutable']) {
|
||||
$attributes['readonly'] = true;
|
||||
$attributes['tooltip'] = 'Diese Leistung kann nicht mehr geändert werden';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
};
|
||||
$form
|
||||
->add('transportationServiceTo', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
@@ -240,13 +257,7 @@ class ParticipantType extends AbstractType
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_to'],
|
||||
'choice_attr' => function (?Service $service) {
|
||||
return [
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'select-toggle#toggle booking#toggle',
|
||||
'data-select-toggle-value' => $service->subType,
|
||||
];
|
||||
},
|
||||
'choice_attr' => $transportationChoiceAttributes,
|
||||
])
|
||||
->add('transportationServiceFro', ChoiceType::class, [
|
||||
...$commonChoiceFieldOptions,
|
||||
@@ -254,13 +265,7 @@ class ParticipantType extends AbstractType
|
||||
'required' => true,
|
||||
'multiple' => false,
|
||||
'choices' => $options['selectable_transportation_services_fro'],
|
||||
'choice_attr' => function (?Service $service) {
|
||||
return [
|
||||
'data-booking-target' => 'field',
|
||||
'data-action' => 'select-toggle#toggle booking#toggle',
|
||||
'data-select-toggle-value' => $service->subType,
|
||||
];
|
||||
},
|
||||
'choice_attr' => $transportationChoiceAttributes,
|
||||
])
|
||||
;
|
||||
|
||||
@@ -287,6 +292,17 @@ class ParticipantType extends AbstractType
|
||||
number_format($price, 2, ',', '.')
|
||||
);
|
||||
},
|
||||
'choice_attr' => function (?Pickup $pickup) use ($options) {
|
||||
$attributes = [];
|
||||
if (false === $options['pickups_mutable']) {
|
||||
$attributes['readonly'] = true;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
},
|
||||
'attr' => [
|
||||
'readonly' => false === $options['pickups_mutable'],
|
||||
]
|
||||
]);
|
||||
})
|
||||
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options) {
|
||||
|
||||
@@ -69,9 +69,6 @@
|
||||
{%- if errors|length -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' form-checkbox--has-error' }) -%}
|
||||
{%- endif -%}
|
||||
{%- if attr.disabled is defined and attr.disabled == true -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
||||
{%- endif -%}
|
||||
{%- set tooltip = null -%}
|
||||
{%- if attr.tooltip is defined -%}
|
||||
{%- set tooltip = attr.tooltip -%}
|
||||
@@ -87,9 +84,6 @@
|
||||
{%- if errors|length -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' form-radio--has-error' }) -%}
|
||||
{%- endif -%}
|
||||
{%- if attr.disabled is defined and attr.disabled == true -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
||||
{%- endif -%}
|
||||
{%- set tooltip = null -%}
|
||||
{%- if attr.tooltip is defined -%}
|
||||
{%- set tooltip = attr.tooltip -%}
|
||||
@@ -101,7 +95,7 @@
|
||||
{%- endblock radio_widget -%}
|
||||
|
||||
{% block checkbox_row %}
|
||||
<div class="relative flex items-start">
|
||||
<div class="{{ html_classes('relative flex items-start', { 'cursor-not-allowed': form.vars.attr.readonly is defined }) }}">
|
||||
<div class="flex h-6 items-center">
|
||||
{{ form_widget(form) }}
|
||||
</div>
|
||||
@@ -129,9 +123,6 @@
|
||||
{% else %}
|
||||
{{ parent() }}
|
||||
{% endif %}
|
||||
{%- if disabled is defined and disabled == true -%}
|
||||
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ form.vars.value }}">
|
||||
{%- endif -%}
|
||||
{%- endblock choice_widget_collapsed -%}
|
||||
|
||||
{%- block choice_widget_expanded -%}
|
||||
|
||||
Reference in New Issue
Block a user