diff --git a/src/bundle/Resources/public/js/scenarios-edit.js b/src/bundle/Resources/public/js/scenarios-edit.js
index c3508fad..311c8b2e 100644
--- a/src/bundle/Resources/public/js/scenarios-edit.js
+++ b/src/bundle/Resources/public/js/scenarios-edit.js
@@ -8,9 +8,13 @@
const container = event.currentTarget.closest('.ez-field-edit__data-group-items--action-checkbox-container');
const inputs = container.querySelectorAll('.ez-personalization-base-item__input-field');
- if (dataset.hasOwnProperty('relatedId')) {
- doc.querySelectorAll(`[related="${dataset.relatedId}"]`).forEach((relatedCheckbox) => {
+ if (dataset.relatedId) {
+ doc.querySelectorAll(`[data-related="${dataset.relatedId}"]`).forEach((relatedCheckbox) => {
relatedCheckbox.disabled = !checked;
+
+ if (!checked) {
+ relatedCheckbox.checked = false;
+ }
});
}
diff --git a/src/bundle/Resources/public/scss/_base-item.scss b/src/bundle/Resources/public/scss/_base-item.scss
index ed84f07a..468ea228 100644
--- a/src/bundle/Resources/public/scss/_base-item.scss
+++ b/src/bundle/Resources/public/scss/_base-item.scss
@@ -67,6 +67,10 @@
}
}
+ .ez-field-edit__error {
+ margin-top: 0;
+ }
+
&--edit {
.ez-field-edit {
padding: calculateRem(24px) 0;
diff --git a/src/bundle/Resources/views/themes/admin/personalization/scenarios/create.html.twig b/src/bundle/Resources/views/themes/admin/personalization/scenarios/create.html.twig
index 1ca760c1..5650d585 100644
--- a/src/bundle/Resources/views/themes/admin/personalization/scenarios/create.html.twig
+++ b/src/bundle/Resources/views/themes/admin/personalization/scenarios/create.html.twig
@@ -68,3 +68,8 @@
{{ form_end(scenario_form) }}
{% endblock %}
+
+{% block javascripts %}
+ {{ parent() }}
+ {{ encore_entry_script_tags('ezplatform-personalization-scenarios-edit-js', null, 'ezplatform') }}
+{% endblock %}
diff --git a/src/bundle/Resources/views/themes/admin/personalization/scenarios/form_fields/edit.html.twig b/src/bundle/Resources/views/themes/admin/personalization/scenarios/form_fields/edit.html.twig
index 0be4bf1c..27cb61e5 100644
--- a/src/bundle/Resources/views/themes/admin/personalization/scenarios/form_fields/edit.html.twig
+++ b/src/bundle/Resources/views/themes/admin/personalization/scenarios/form_fields/edit.html.twig
@@ -1,12 +1,14 @@
{% use 'bootstrap_4_layout.html.twig' %}
-{%- block form_errors -%}
+{% block form_errors %}
{%- if errors|length > 0 -%}
{%- for error in errors -%}
{{ error.message }}
{%- endfor -%}
{%- endif -%}
-{%- endblock -%}
+{% endblock form_errors %}
+
+{% block form_label_errors %}{% endblock form_label_errors %}
{% block form_row -%}
{% set wrapper_class = 'ez-field-edit' %}
@@ -23,17 +25,20 @@
{% set label_wrapper_attr = label_wrapper_attr|default({})|merge({'class': (label_wrapper_attr.class|default('') ~ 'ez-field-edit__label-wrapper')|trim}) %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' ez-field-edit__label')|trim}) %}
{% set widget_wrapper_attr = widget_wrapper_attr|default({})|merge({'class': (widget_wrapper_attr.class|default('') ~ ' ez-field-edit__data')|trim}) %}
+ {% set attr = attr|merge({'class': (attr.class|default('') ~ ' ez-personalization-base-item__input-field ez-data-source__input')|trim}) %}
{{ block('form_label') }}
- {{ block('form_errors') }}
- {{- form_widget(form, {'attr': attr}) -}}
+
+ {{- form_widget(form, {'attr': attr}) -}}
+ {{ block('form_errors') }}
+
-{%- endblock %}
+{% endblock %}
{% block _scenario_user_profile_settings_widget %}
{% for child in form.children %}
@@ -95,8 +100,8 @@
{% endblock %}
-{% block _scenario_user_profile_settings_user_attribute_name_widget %}
- {% set relatedTo = form.parent.exclude_repeated_recommendations.children.enabled %}
+{% block _scenario_user_profile_settings_user_attribute_name_widget %}
+ {% set relatedTo = form.parent.boost_item.children.enabled %}
{{ form_widget(form.enabled, {
diff --git a/src/lib/Form/Type/OptionalTextType.php b/src/lib/Form/Type/OptionalTextType.php
index 1d6547cc..9d1ae9cc 100644
--- a/src/lib/Form/Type/OptionalTextType.php
+++ b/src/lib/Form/Type/OptionalTextType.php
@@ -24,7 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('enabled', CheckboxType::class, [
'label' => false,
'attr' => [
- 'related' => $builder->getOption('data-related'),
+ 'data-related' => $builder->getOption('data-related'),
'class' => $builder->getOption('class'),
],
])
@@ -40,11 +40,11 @@ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => OptionalTextData::class,
- 'related' => null,
+ 'data-related' => null,
'class' => null,
'value_label' => null,
])
- ->setAllowedTypes('related', ['null', 'string'])
+ ->setAllowedTypes('data-related', ['null', 'string'])
->setAllowedTypes('class', ['null', 'string'])
->setAllowedTypes('value_label', ['null', 'string']);
}
diff --git a/src/lib/Form/Type/Scenario/ScenarioCommerceSettingsType.php b/src/lib/Form/Type/Scenario/ScenarioCommerceSettingsType.php
index c955ed20..eb59126d 100644
--- a/src/lib/Form/Type/Scenario/ScenarioCommerceSettingsType.php
+++ b/src/lib/Form/Type/Scenario/ScenarioCommerceSettingsType.php
@@ -49,7 +49,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => false,
'label' => $this->translator->trans(/** @Desc("Do not recommend if price unknown") */ 'scenario.commerce_settings.do_not_recommend_if_price_unknown', [], 'ibexa_personalization'),
'attr' => [
- 'related' => self::HTML_CLASS_EXCLUDE_MINIMAL_ITEM_PRICE,
+ 'data-related' => self::HTML_CLASS_EXCLUDE_MINIMAL_ITEM_PRICE,
],
])
->add('exclude_already_purchased', CheckboxType::class, [
diff --git a/src/lib/Form/Type/Scenario/ScenarioUserProfileSettingsType.php b/src/lib/Form/Type/Scenario/ScenarioUserProfileSettingsType.php
index 5c826a15..ebaa7723 100644
--- a/src/lib/Form/Type/Scenario/ScenarioUserProfileSettingsType.php
+++ b/src/lib/Form/Type/Scenario/ScenarioUserProfileSettingsType.php
@@ -51,7 +51,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add('user_attribute_name', OptionalTextType::class, [
'required' => false,
- 'related' => self::HTML_CLASS_BOOST_ITEM,
+ 'data-related' => self::HTML_CLASS_BOOST_ITEM,
'value_label' => $this->translator->trans(/** @Desc("User attribute has different name") */ 'scenario.user_profile_settings.user_attribute_has_different_name', [], 'ibexa_personalization'),
])
->addEventSubscriber(new ScenarioUserSettingsSubscriber())