From cb0980c40c31dfa2271a13d2766e9f0a6cd01965 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Fri, 12 Jan 2018 10:02:20 +0000 Subject: [PATCH] Render error summary on cya (in case a developer overrides the statement of truth) --- templates/look-and-feel/components/errors.njk | 14 ++++++++++++++ .../look-and-feel/layouts/check_your_answers.html | 3 +++ templates/look-and-feel/layouts/question.html | 14 ++------------ 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 templates/look-and-feel/components/errors.njk diff --git a/templates/look-and-feel/components/errors.njk b/templates/look-and-feel/components/errors.njk new file mode 100644 index 0000000..119fc8f --- /dev/null +++ b/templates/look-and-feel/components/errors.njk @@ -0,0 +1,14 @@ +{% macro errorSummary(fields, title='There was a problem') -%} + {%- if fields.validated and not fields.valid -%} +
+

+ {{ title }} +

+ +
+ {%- endif -%} +{%- endmacro %} diff --git a/templates/look-and-feel/layouts/check_your_answers.html b/templates/look-and-feel/layouts/check_your_answers.html index a5bed96..7da62fb 100644 --- a/templates/look-and-feel/layouts/check_your_answers.html +++ b/templates/look-and-feel/layouts/check_your_answers.html @@ -3,6 +3,7 @@ {% from "look-and-feel/components/check-your-answers.njk" import answer %} {% from "look-and-feel/components/phase_banner.njk" import phaseBanner %} {% from "look-and-feel/components/fields.njk" import hiddenInput %} +{% from "look-and-feel/components/errors.njk" import errorSummary %} {% set defaultContent = { title: 'Check your answers', @@ -24,6 +25,8 @@ {{ header(pageContent.title | default(defaultContent.title)) }} + {{ errorSummary(fields) }} + {% for section in _sections %} {% if section.atLeast1Completed %} diff --git a/templates/look-and-feel/layouts/question.html b/templates/look-and-feel/layouts/question.html index 0d68652..223cd87 100644 --- a/templates/look-and-feel/layouts/question.html +++ b/templates/look-and-feel/layouts/question.html @@ -1,6 +1,7 @@ {% extends "look-and-feel/layouts/two_thirds.html" %} {% from "look-and-feel/components/header.njk" import header %} {% from "look-and-feel/components/phase_banner.njk" import phaseBanner %} +{% from "look-and-feel/components/errors.njk" import errorSummary %} {% block page_title %}{{ title }}{% endblock %} @@ -15,18 +16,7 @@
- {%- if fields.validated and not fields.valid -%} -
-

- There was a problem -

- -
- {%- endif -%} + {{ errorSummary(fields) }} {% block fields -%} {%- endblock %}