Skip to content

Commit 2b56580

Browse files
Changed to use nunjucks component
1 parent 6f39acd commit 2b56580

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

app/views/form-designer/question-routes/new-condition.html

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{% extends "layout-govuk-forms.html" %}
22

33
{% set pageTitle = 'Add a route from a question' %}
4+
{% set pageQuestion = 'Which question do you want to add a route from?' %}
5+
{% set pageHint = 'A route can only start from a question where people select one item from a list. You can only add one route from each question.' %}
46

57
{% block pageTitle %}
68
{{ "Error: " if containsErrors }}{{pageTitle}}: {{ data.formTitle or '[formTitle]' }} - GOV.UK Forms
@@ -37,42 +39,34 @@ <h1 class="govuk-heading-l">{{ pageTitle }}</h1>
3739
You can set up a route so if someone selects a specific answer to a question they’ll skip forward to a later question, or the end of the form.
3840
</p>
3941

42+
{% if data.pages.length >= 2 %}
43+
44+
{% set tempQuestions = [] %}
4045
{% for page in data.pages -%}
41-
{% set tempQuestions = {
42-
'name': page['long-title']
43-
} %}
46+
{% if page['type'] == 'select' and page['listSettings'].includes('oneOption') and not loop.last %}
47+
{% set tempQuestions = (
48+
tempQuestions.push({
49+
value: page.pageIndex,
50+
text: (page.pageIndex|int + 1) + '. ' + page['long-title'],
51+
checked: true if data.routeStartQuestion == (page.pageIndex|int + 1)
52+
}), tempQuestions)
53+
%}
54+
{% endif %}
4455
{%- endfor %}
4556

46-
{% if data.pages.length >= 2 %}
47-
<div class="govuk-form-group{% if containsErrors %} govuk-form-group--error{% endif %}">
48-
<fieldset class="govuk-fieldset">
49-
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">
50-
<h2 class="govuk-fieldset__heading">
51-
Which question do you want to add a route from?
52-
</h2>
53-
</legend>
54-
{% if containsErrors -%}
55-
<p id="routeStartQuestion-error" class="govuk-error-message">
56-
<span class="govuk-visually-hidden">Error:</span> {{ errorList[0].text }}
57-
</p>
58-
{%- endif %}
59-
<div id="routeStartQuestion-hint" class="govuk-hint">
60-
A route can only start from a question where people select one item from a list. You can only add one route from each question.
61-
</div>
62-
<div class="govuk-radios" data-module="govuk-radios">
63-
{% for page in data.pages -%}
64-
{% if page['type'] == 'select' and page['listSettings'].includes('oneOption') and not loop.last %}
65-
<div class="govuk-radios__item">
66-
<input class="govuk-radios__input" id="route-start-question" name="routeStartQuestion" type="radio" value="{{ page['pageIndex']|int + 1 }}">
67-
<label class="govuk-label govuk-radios__label" for="route-start-question">
68-
{{ page['pageIndex']|int + 1 }}. {{ page["long-title"] }}
69-
</label>
70-
</div>
71-
{% endif %}
72-
{%- endfor %}
73-
</div>
74-
</fieldset>
75-
</div>
57+
{{ govukRadios({
58+
name: "routeQuestion",
59+
fieldset: {
60+
legend: {
61+
text: pageQuestion,
62+
classes: "govuk-fieldset__legend--m"
63+
}
64+
},
65+
hint: {
66+
text: pageHint
67+
},
68+
items: tempQuestions
69+
}) }}
7670

7771
{{ govukButton({
7872
text: "Continue"

0 commit comments

Comments
 (0)