From 79c4402aee59047e7431ec15989faccb527e7ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Mummert?= Date: Mon, 8 Jun 2026 20:14:57 +0200 Subject: [PATCH] Fix survey reader back flow --- .../frontend/_survey_assets.html.twig | 77 +++++++++++++++++++ .../templates/frontend/show_survey.html.twig | 41 +++++----- src/Repository/SurveyAnswerRepository.php | 3 +- 3 files changed, 101 insertions(+), 20 deletions(-) diff --git a/contao/templates/frontend/_survey_assets.html.twig b/contao/templates/frontend/_survey_assets.html.twig index 9cc79de..25d9910 100644 --- a/contao/templates/frontend/_survey_assets.html.twig +++ b/contao/templates/frontend/_survey_assets.html.twig @@ -466,6 +466,29 @@ align-items: center; } + .survey-button-row--navigation { + width: 100%; + justify-content: flex-end; + align-items: center; + margin-top: 1rem; + } + + .survey-button-row--navigation.has-back { + justify-content: space-between; + } + + .survey-navigation-form { + margin: 0; + } + + .survey-navigation-form--back { + margin: 0; + } + + .survey-navigation-submit { + margin-left: auto; + } + .survey-publish-toggle-form { margin: 0; } @@ -843,6 +866,56 @@ color: var(--survey-green); } + .survey-range-block { + gap: 1rem; + } + + .survey-range-value-card { + display: grid; + place-items: center; + gap: 0.2rem; + width: min(100%, 8.5rem); + min-height: 8.5rem; + margin-inline: auto; + padding: 1rem; + border-radius: 50%; + background: radial-gradient(circle at top left, rgba(0, 100, 173, 0.12), rgba(255, 255, 255, 0.96) 62%, rgba(236, 124, 50, 0.16) 100%); + border: 1px solid rgba(0, 100, 173, 0.16); + box-shadow: 0 10px 24px rgba(34, 34, 34, 0.08); + text-align: center; + } + + .survey-range-value-label { + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--survey-gray-dark); + } + + .survey-range-scale { + display: flex; + justify-content: space-between; + align-items: center; + gap: 1rem; + width: 100%; + } + + .survey-range-boundary { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 2.75rem; + min-height: 2.75rem; + padding: 0.45rem 0.7rem; + border-radius: 999px; + background: rgba(255, 255, 255, 0.82); + border: 1px solid rgba(0, 100, 173, 0.14); + color: var(--survey-blue); + font-weight: 700; + box-shadow: 0 6px 16px rgba(34, 34, 34, 0.05); + } + @media (min-width: 960px) { .survey-grid-columns { grid-template-columns: 0.95fr 1.05fr; @@ -880,6 +953,10 @@ align-items: flex-start; } + .survey-button-row--navigation.has-back { + justify-content: space-between; + } + .survey-list-publish-help { left: 0; right: auto; diff --git a/contao/templates/frontend/show_survey.html.twig b/contao/templates/frontend/show_survey.html.twig index 43e053a..12219e8 100644 --- a/contao/templates/frontend/show_survey.html.twig +++ b/contao/templates/frontend/show_survey.html.twig @@ -52,20 +52,7 @@

{{ question.question|striptags|trim }}

{% if question.description|striptags|trim %}

{{ question.description|striptags|trim }}

{% endif %} - {% if canGoBack %} -
- - - - {% if isPreview %} - - - {% endif %} - -
- {% endif %} - - {{ form_start(surveyForm, {attr: {class: 'survey-form-grid'}}) }} + {{ form_start(surveyForm, {attr: {class: 'survey-form-grid', id: 'survey-answer-form-' ~ question.id}}) }} {% if isPreview %} @@ -89,21 +76,37 @@ {% endfor %} {% elseif question.type == 'range' %} -
-
-
{{ 'survey.survey.current_value'|trans }}
+
+
+
{{ 'survey.survey.current_value'|trans }}
{{ question.rangeMin }}
{{ form_widget(surveyForm.answer, {attr: {'data-survey-range': '1', 'data-survey-range-target': 'survey-range-output-' ~ question.id}}) }} -
{{ question.rangeMin }}{{ question.rangeMax }}
+
{{ question.rangeMin }}{{ question.rangeMax }}
{% else %} {{ form_widget(surveyForm.answer) }} {% endif %} {{ form_errors(surveyForm.answer) }} -
{{ form_end(surveyForm) }} + +
+ {% if canGoBack %} +
+ + + + {% if isPreview %} + + + {% endif %} + +
+ {% endif %} + + +
{% endif %} {% endif %} diff --git a/src/Repository/SurveyAnswerRepository.php b/src/Repository/SurveyAnswerRepository.php index 9b8aa23..f849732 100644 --- a/src/Repository/SurveyAnswerRepository.php +++ b/src/Repository/SurveyAnswerRepository.php @@ -6,6 +6,7 @@ namespace Mummert\SurveyBundle\Repository; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\ParameterType; final class SurveyAnswerRepository { @@ -92,7 +93,7 @@ final class SurveyAnswerRepository $this->connection->executeStatement( 'DELETE FROM tl_survey_answer WHERE submission = ? AND question NOT IN (?)', [$submissionId, array_values(array_unique(array_map('intval', $questionIds)))], - [\PDO::PARAM_INT, ArrayParameterType::INTEGER], + [ParameterType::INTEGER, ArrayParameterType::INTEGER], ); }