@planning-inspectorate/dynamic-forms 1.17.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.releaserc +14 -0
  2. package/README.md +68 -3
  3. package/package.json +2 -1
  4. package/src/components/address/index.njk +2 -19
  5. package/src/components/address/question.test.js +1 -1
  6. package/src/components/boolean/index.njk +4 -21
  7. package/src/components/checkbox/index.njk +3 -21
  8. package/src/components/conditional/textarea.njk +1 -1
  9. package/src/components/conditional/unit.njk +1 -1
  10. package/src/components/date/index.njk +3 -20
  11. package/src/components/date-period/index.njk +4 -21
  12. package/src/components/date-time/index.njk +4 -21
  13. package/src/components/identifier/index.njk +2 -19
  14. package/src/components/multi-field-input/index.njk +3 -20
  15. package/src/components/multi-field-input/question.test.js +3 -3
  16. package/src/components/number-entry/index.njk +7 -21
  17. package/src/components/radio/index.njk +8 -21
  18. package/src/components/select/index.njk +2 -19
  19. package/src/components/single-line-input/index.njk +4 -21
  20. package/src/components/task-list/index.njk +2 -8
  21. package/src/components/text-entry/index.njk +4 -21
  22. package/src/components/text-entry-redact/index.njk +2 -19
  23. package/src/components/text-entry-redact/question.test.js +4 -4
  24. package/src/components/unit-option-entry/index.njk +5 -20
  25. package/src/controller.js +2 -2
  26. package/src/controller.test.js +5 -5
  27. package/src/journey/journey.js +7 -7
  28. package/src/journey/journey.test.js +10 -10
  29. package/src/middleware/redirect-to-unanswered-question.test.js +1 -1
  30. package/src/validator/address-validator.js +1 -1
  31. package/src/validator/address-validator.test.js +1 -5
  32. package/test/journey.js +2 -2
  33. package/test/snapshots/add-insurance.html +1 -11
  34. package/test/snapshots/check-your-answers-not-started.html +0 -3
  35. package/test/snapshots/check-your-answers-with-answers.html +0 -3
  36. package/test/snapshots/companions.html +2 -15
  37. package/test/snapshots/departure-date.html +1 -11
  38. package/test/snapshots/holiday-activities.html +1 -11
  39. package/test/snapshots/holiday-arrival.html +2 -9
  40. package/test/snapshots/holiday-description.html +1 -11
  41. package/test/snapshots/holiday-destination.html +0 -10
  42. package/test/snapshots/holiday-period.html +2 -15
  43. package/test/snapshots/holiday-snack.html +1 -11
  44. package/test/snapshots/hotel-address.html +0 -7
  45. package/test/snapshots/luggage-weight-units.html +2 -17
  46. package/test/snapshots/nights.html +1 -12
  47. package/test/snapshots/secret-wish.html +0 -7
  48. package/test/snapshots/travel-class.html +1 -10
  49. package/test/snapshots/travel-insurance-type.html +0 -10
  50. package/test/views/layout-check-your-answers.njk +1 -1
  51. package/test/views/layout-journey.njk +1 -0
  52. package/test/views/layout-question.njk +0 -2
package/.releaserc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "plugins": [
3
+ [
4
+ "@semantic-release/commit-analyzer",
5
+ {
6
+ "preset": "conventionalcommits",
7
+ "presentConfig": {}
8
+ }
9
+ ],
10
+ "@semantic-release/release-notes-generator",
11
+ "@semantic-release/npm",
12
+ "@semantic-release/github"
13
+ ]
14
+ }
package/README.md CHANGED
@@ -21,7 +21,7 @@ The functionality for 'check-your-answers' pages can also be useful for generati
21
21
 
22
22
  ## Requirements
23
23
 
24
- To use this package nunjucks must be configured so that the component view files are available, and static assets must be made available for certain components and styling.
24
+ To use this package nunjucks must be configured so that the component view files are available, and static assets must be made available for certain components and styling. Some nunjucks templates are required to correctly render the question pages and task list views.
25
25
 
26
26
  ### Nunjucks
27
27
 
@@ -67,12 +67,77 @@ The select component can use the [accessible-autocomplete](https://www.npmjs.com
67
67
 
68
68
  ### Layouts
69
69
 
70
- The layout file used for the journey should include the following blocks:
70
+ There are two layout files that need to be configured for dynamic-forms: journey and task list.
71
+
72
+ **Journey template**
73
+
74
+ The journey template is used for question pages. It must include a block called `dynQuestionContent`, and a block called `head` (which the default gov.uk template has).
75
+ It should also include the rendering of the errorSummary component. The path to this template is configured via the `journeyTemplate` property on a Journey.
76
+
77
+ e.g.
78
+
79
+ ```nunjucks
80
+ {% extends "govuk/template.njk" %}
81
+
82
+ {% block beforeContent %}
83
+ {% if errorSummary %}
84
+ <div class="govuk-grid-row">
85
+ <div class="govuk-grid-column-two-thirds">
86
+ {{ govukErrorSummary({
87
+ titleText: "There is a problem",
88
+ errorList: errorSummary,
89
+ attributes: {"data-cy": "error-wrapper"}
90
+ }) }}
91
+ </div>
92
+ </div>
93
+ {% endif %}
94
+ {% endblock %}
95
+
96
+ {% block content %}
97
+ <div class="govuk-grid-row">
98
+ <div class="govuk-grid-column-full">
99
+ <h1 class="govuk-heading-xl">
100
+ {% if pageCaption %}
101
+ <span class="govuk-caption-xl">{{ pageCaption }}</span>
102
+ {% endif %}
103
+ {{ pageHeading }}
104
+ </h1>
105
+ </div>
106
+ </div>
107
+
108
+ {% block dynQuestionContent %}{% endblock %}
109
+ {% endblock %}
110
+ ```
71
111
 
72
- TODO!
112
+ **Task list template**
113
+
114
+ The task list template is used for the task list or "check your answers" page. It must include a block called `dynTaskList`. The path to this template is configured via the `taskListTemplate` property on a Journey.
115
+
116
+ e.g.
117
+
118
+ ```nunjucks
119
+ {% extends "govuk/template.njk" %}
120
+
121
+ {% block content %}
122
+ <div class="govuk-grid-row">
123
+ <div class="govuk-grid-column-full">
124
+ <h1 class="govuk-heading-xl">
125
+ {% if pageCaption %}
126
+ <span class="govuk-caption-xl">{{ pageCaption }}</span>
127
+ {% endif %}
128
+ {{ pageHeading }}
129
+ </h1>
130
+ </div>
131
+ </div>
132
+
133
+ {% block dynTaskList %}{% endblock %}
134
+ {% endblock %}
135
+ ```
73
136
 
74
137
  ## Usage
75
138
 
139
+ The test directory includes a very basic journey in `test/journey.js`. This may be a useful guide for setting up a journey and associated questions. Also in `test/questions.test.js` there is a function `createAppWithQuestions` which may be a useful guide for setting up the appropriate controllers and routes for a journey.
140
+
76
141
  ### Conditions
77
142
 
78
143
  Conditions are used to show/hide questions based on the answers to other questions. There are fluent methods on a Section
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/dynamic-forms",
3
- "version": "1.17.0",
3
+ "version": "2.0.1",
4
4
  "description": "This package is for building GDS forms using a configuration-based approach.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -32,6 +32,7 @@
32
32
  "@commitlint/cli": "^20.0.0",
33
33
  "@commitlint/config-conventional": "^20.0.0",
34
34
  "body-parser": "^2.2.0",
35
+ "conventional-changelog-conventionalcommits": "^9.1.0",
35
36
  "cookie-parser": "^1.4.7",
36
37
  "eslint": "^9.29.0",
37
38
  "eslint-config-prettier": "^10.1.5",
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/input/macro.njk" import govukInput %}
5
4
  {% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
6
5
  {% from "govuk/components/button/macro.njk" import govukButton %}
@@ -11,27 +10,11 @@
11
10
  {% set county= question.fieldName + "_county" %}
12
11
  {% set postcode= question.fieldName + "_postcode" %}
13
12
 
14
- {% block before_content %}
15
- <div class="govuk-grid-row">
16
- <div class="govuk-grid-column-two-thirds">
17
- {% if errorSummary %}
18
- {{ govukErrorSummary({
19
- titleText: "There is a problem",
20
- errorList: errorSummary,
21
- attributes: {"data-cy": "error-wrapper"}
22
- }) }}
23
- {% endif %}
24
- </div>
25
- </div>
26
-
27
- {{ super() }}
28
- {% endblock before_content %}
29
-
30
- {% block content %}
13
+ {% block dynQuestionContent %}
31
14
  <div class="govuk-grid-row">
32
15
  <div class="govuk-grid-column-two-thirds">
33
16
  <form action="" method="post" novalidate>
34
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
17
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
35
18
  {% call govukFieldset({
36
19
  legend: {
37
20
  text: question.question,
@@ -132,7 +132,7 @@ describe('AddressQuestion', () => {
132
132
  const model = await question.prepQuestionForRendering(
133
133
  {},
134
134
  { getBackLink: mock.fn(), response },
135
- { layoutTemplate: 'views/layout-question.njk' }
135
+ { layoutTemplate: 'views/layout-journey.njk' }
136
136
  );
137
137
 
138
138
  assert.strictEqual(model.question.hint, hintText);
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/radios/macro.njk" import govukRadios %}
5
4
  {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
6
5
  {% from "govuk/components/button/macro.njk" import govukButton %}
@@ -11,27 +10,11 @@
11
10
  {% endset %}
12
11
  {% endif %}
13
12
 
14
- {% block before_content %}
15
- <div class="govuk-grid-row">
16
- <div class="govuk-grid-column-two-thirds">
17
- {% if errorSummary %}
18
- {{ govukErrorSummary({
19
- titleText: "There is a problem",
20
- errorList: errorSummary,
21
- attributes: {"data-cy": "error-wrapper"}
22
- }) }}
23
- {% endif %}
24
- </div>
25
- </div>
26
-
27
- {{ super() }}
28
- {% endblock before_content %}
29
-
30
- {% block content %}
13
+ {% block dynQuestionContent %}
31
14
  <div class="govuk-grid-row">
32
15
  <div class="govuk-grid-column-two-thirds">
33
16
  <form action="" method="post" novalidate>
34
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
17
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
35
18
  {% if question.interfaceType === 'radio' %}
36
19
  {{ govukRadios({
37
20
  classes: "govuk-radios",
@@ -47,7 +30,7 @@
47
30
  classes: "govuk-fieldset__legend--l"
48
31
  }
49
32
  },
50
- hint: { text: question.hint },
33
+ hint: question.hint and { text: question.hint },
51
34
  items: question.options
52
35
  }) }}
53
36
 
@@ -59,7 +42,7 @@
59
42
  errorMessage: errors[question.fieldName] and {
60
43
  text: errors[question.fieldName].msg
61
44
  },
62
- hint: {
45
+ hint: htmlHint and {
63
46
  html: htmlHint
64
47
  },
65
48
  fieldset: {
@@ -1,31 +1,13 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
5
4
  {% from "govuk/components/button/macro.njk" import govukButton %}
6
5
 
7
-
8
- {% block before_content %}
9
- <div class="govuk-grid-row">
10
- <div class="govuk-grid-column-two-thirds">
11
- {% if errorSummary %}
12
- {{ govukErrorSummary({
13
- titleText: "There is a problem",
14
- errorList: errorSummary,
15
- attributes: {"data-cy": "error-wrapper"}
16
- }) }}
17
- {% endif %}
18
- </div>
19
- </div>
20
-
21
- {{ super() }}
22
- {% endblock before_content %}
23
-
24
- {% block content %}
6
+ {% block dynQuestionContent %}
25
7
  <div class="govuk-grid-row">
26
8
  <div class="govuk-grid-column-two-thirds">
27
9
  <form action="" method="post" novalidate>
28
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
10
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
29
11
  {{ govukCheckboxes({
30
12
  classes: "govuk-checkboxes",
31
13
  idPrefix: question.fieldName,
@@ -33,7 +15,7 @@
33
15
  errorMessage: errors[question.fieldName] and {
34
16
  text: errors[question.fieldName].msg
35
17
  },
36
- hint: {
18
+ hint: question.description and {
37
19
  text: question.description
38
20
  },
39
21
  fieldset: {
@@ -4,7 +4,7 @@
4
4
  label: {
5
5
  text: question
6
6
  },
7
- hint: {
7
+ hint: hint and {
8
8
  text: hint
9
9
  },
10
10
  id: fieldName,
@@ -1,7 +1,7 @@
1
1
  {% from "govuk/components/input/macro.njk" import govukInput %}
2
2
 
3
3
  {{ govukInput({
4
- hint: {
4
+ hint: hint and {
5
5
  text: hint
6
6
  },
7
7
  label: {
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/date-input/macro.njk" import govukDateInput %}
5
4
  {% from "govuk/components/button/macro.njk" import govukButton %}
6
5
 
@@ -14,27 +13,11 @@
14
13
  {% endset %}
15
14
  {% endif %}
16
15
 
17
- {% block before_content %}
18
- <div class="govuk-grid-row">
19
- <div class="govuk-grid-column-two-thirds">
20
- {% if errorSummary %}
21
- {{ govukErrorSummary({
22
- titleText: "There is a problem",
23
- errorList: errorSummary,
24
- attributes: {"data-cy": "error-wrapper"}
25
- }) }}
26
- {% endif %}
27
- </div>
28
- </div>
29
-
30
- {{ super() }}
31
- {% endblock before_content %}
32
-
33
- {% block content %}
16
+ {% block dynQuestionContent %}
34
17
  <div class="govuk-grid-row">
35
18
  <div class="govuk-grid-column-two-thirds">
36
19
  <form action="" method="post" novalidate>
37
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
20
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
38
21
  {{ govukDateInput({
39
22
  id: question.fieldName,
40
23
  fieldset: {
@@ -44,7 +27,7 @@
44
27
  classes: "govuk-fieldset__legend--l"
45
28
  }
46
29
  },
47
- hint: {
30
+ hint: question.hint and {
48
31
  text: question.hint
49
32
  },
50
33
  errorMessage: errorSummary and {
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/date-input/macro.njk" import govukDateInput %}
5
4
  {% from "govuk/components/button/macro.njk" import govukButton %}
6
5
  {% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
@@ -20,27 +19,11 @@
20
19
  {% endset %}
21
20
  {% endif %}
22
21
 
23
- {% block before_content %}
24
- <div class="govuk-grid-row">
25
- <div class="govuk-grid-column-two-thirds">
26
- {% if errorSummary %}
27
- {{ govukErrorSummary({
28
- titleText: "There is a problem",
29
- errorList: errorSummary,
30
- attributes: {"data-cy": "error-wrapper"}
31
- }) }}
32
- {% endif %}
33
- </div>
34
- </div>
35
-
36
- {{ super() }}
37
- {% endblock before_content %}
38
-
39
- {% block content %}
22
+ {% block dynQuestionContent %}
40
23
  <div class="govuk-grid-row">
41
24
  <div class="govuk-grid-column-two-thirds">
42
25
  <form action="" method="post" novalidate>
43
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
26
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
44
27
 
45
28
  {{ govukFieldset({
46
29
  legend: {
@@ -57,7 +40,7 @@
57
40
  text: labels.start
58
41
  }
59
42
  },
60
- hint: {
43
+ hint: question.hint and {
61
44
  text: question.hint
62
45
  },
63
46
  errorMessage: errorSummary and {
@@ -95,7 +78,7 @@
95
78
  text: labels.end
96
79
  }
97
80
  },
98
- hint: {
81
+ hint: question.hint and {
99
82
  text: question.hint
100
83
  },
101
84
  errorMessage: errorSummary and {
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/button/macro.njk" import govukButton %}
5
4
  {% from "govuk/components/date-input/macro.njk" import govukDateInput %}
6
5
  {% from "govuk/components/input/macro.njk" import govukInput %}
@@ -19,23 +18,7 @@
19
18
  {% endset %}
20
19
  {% endif %}
21
20
 
22
- {% block before_content %}
23
- <div class="govuk-grid-row">
24
- <div class="govuk-grid-column-two-thirds">
25
- {% if errorSummary %}
26
- {{ govukErrorSummary({
27
- titleText: "There is a problem",
28
- errorList: errorSummary,
29
- attributes: {"data-cy": "error-wrapper"}
30
- }) }}
31
- {% endif %}
32
- </div>
33
- </div>
34
-
35
- {{ super() }}
36
- {% endblock before_content %}
37
-
38
- {% block content %}
21
+ {% block dynQuestionContent %}
39
22
  <style {% if cspNonce %}nonce={{ cspNonce }}{% endif %}>
40
23
  .pins-select--width-4 {
41
24
  min-width: 4.5em !important;
@@ -46,7 +29,7 @@
46
29
  <div class="govuk-grid-row">
47
30
  <div class="govuk-grid-column-two-thirds">
48
31
  <form action="" method="post" novalidate>
49
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
32
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
50
33
  {{ govukDateInput({
51
34
  id: question.fieldName,
52
35
  fieldset: {
@@ -86,13 +69,13 @@
86
69
 
87
70
  <div class="govuk-form-group{% if errors[hour].msg or errors[minutes].msg or errors[period].msg %} govuk-form-group--error{% endif %}">
88
71
  <fieldset class="govuk-fieldset" role="group">
89
- <div id="{{ question.fieldName }}-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
72
+ <div id="{{ question.fieldName }}-time-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
90
73
  {% if errors[hour].msg or errors[minutes].msg or errors[period].msg %}
91
74
  <p id="{{ question.fieldName }}-error" class="govuk-error-message">
92
75
  <span class="govuk-visually-hidden">Error:</span> {{ errors[hour].msg or errors[minutes].msg or errors[period].msg }}
93
76
  </p>
94
77
  {% endif %}
95
- <div class="govuk-date-input" id={{ question.fieldName }}>
78
+ <div class="govuk-date-input" id="{{ question.fieldName }}-time">
96
79
  <div class="govuk-date-input__item">
97
80
  {{ govukInput({
98
81
  classes: "govuk-input--width-2 govuk-input--error" if errors[question.fieldName] or errors[hour] else "govuk-input--width-2",
@@ -1,31 +1,14 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/input/macro.njk" import govukInput %}
5
4
  {% from "govuk/components/label/macro.njk" import govukLabel %}
6
5
  {% from "govuk/components/button/macro.njk" import govukButton %}
7
6
 
8
- {% block before_content %}
9
- <div class="govuk-grid-row">
10
- <div class="govuk-grid-column-two-thirds">
11
- {% if errorSummary %}
12
- {{ govukErrorSummary({
13
- titleText: "There is a problem",
14
- errorList: errorSummary,
15
- attributes: {"data-cy": "error-wrapper"}
16
- }) }}
17
- {% endif %}
18
- </div>
19
- </div>
20
-
21
- {{ super() }}
22
- {% endblock before_content %}
23
-
24
- {% block content %}
7
+ {% block dynQuestionContent %}
25
8
  <div class="govuk-grid-row">
26
9
  <div class="govuk-grid-column-two-thirds">
27
10
  <form action="" method="post" novalidate>
28
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
29
12
  {% if question.label %}
30
13
  <h1 class="govuk-heading-l">
31
14
  {{ question.question }}
@@ -1,6 +1,5 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/input/macro.njk" import govukInput %}
5
4
  {% from "govuk/components/label/macro.njk" import govukLabel %}
6
5
  {% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
@@ -8,27 +7,11 @@
8
7
 
9
8
  {% set inputFields = question.inputFields %}
10
9
 
11
- {% block before_content %}
12
- <div class="govuk-grid-row">
13
- <div class="govuk-grid-column-two-thirds">
14
- {% if errorSummary %}
15
- {{ govukErrorSummary({
16
- titleText: "There is a problem",
17
- errorList: errorSummary,
18
- attributes: {"data-cy": "error-wrapper"}
19
- }) }}
20
- {% endif %}
21
- </div>
22
- </div>
23
-
24
- {{ super() }}
25
- {% endblock before_content %}
26
-
27
- {% block content %}
10
+ {% block dynQuestionContent %}
28
11
  <div class="govuk-grid-row">
29
12
  <div class="govuk-grid-column-two-thirds">
30
13
  <form action="" method="post" novalidate>
31
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
14
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
32
15
 
33
16
  {% call govukFieldset({
34
17
  legend: {
@@ -70,7 +53,7 @@
70
53
  prefix: inputField.prefix,
71
54
  suffix: inputField.suffix,
72
55
  value: inputField.value,
73
- hint: {
56
+ hint: inputField.hint and {
74
57
  text: inputField.hint
75
58
  },
76
59
  classes: inputField.classes or "govuk-input-!-width-three-quarters",
@@ -231,7 +231,7 @@ describe('./src/dynamic-forms/components/single-line-input/question.js', () => {
231
231
  }
232
232
  },
233
233
  journeyTemplate: 'mock template',
234
- listingPageViewPath: 'mock path',
234
+ taskListTemplate: 'mock path',
235
235
  journeyTitle: 'mock title',
236
236
  sections: []
237
237
  });
@@ -265,7 +265,7 @@ describe('./src/dynamic-forms/components/single-line-input/question.js', () => {
265
265
  }
266
266
  },
267
267
  journeyTemplate: 'mock template',
268
- listingPageViewPath: 'mock path',
268
+ taskListTemplate: 'mock path',
269
269
  journeyTitle: 'mock title',
270
270
  sections: []
271
271
  });
@@ -299,7 +299,7 @@ describe('./src/dynamic-forms/components/single-line-input/question.js', () => {
299
299
  }
300
300
  },
301
301
  journeyTemplate: 'mock template',
302
- listingPageViewPath: 'mock path',
302
+ taskListTemplate: 'mock path',
303
303
  journeyTitle: 'mock title',
304
304
  sections: []
305
305
  });
@@ -1,34 +1,20 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/input/macro.njk" import govukInput %}
5
4
  {% from "govuk/components/button/macro.njk" import govukButton %}
6
5
 
7
- {% block before_content %}
8
- <div class="govuk-grid-row">
9
- <div class="govuk-grid-column-two-thirds">
10
- {% if errorSummary %}
11
- {{ govukErrorSummary({
12
- titleText: "There is a problem",
13
- errorList: errorSummary,
14
- attributes: {"data-cy": "error-wrapper"}
15
- }) }}
16
- {% endif %}
17
- </div>
18
- </div>
19
-
20
- {{ super() }}
21
- {% endblock before_content %}
22
-
23
- {% block content %}
6
+ {% block dynQuestionContent %}
24
7
  <div class="govuk-grid-row">
25
8
  <div class="govuk-grid-column-two-thirds">
26
9
  <h1 class="govuk-heading-l">{{ question.question }}</h1>
27
- <p class="govuk-body">{{ question.description }}</p>
10
+ {%- if question.description %}
11
+ <p class="govuk-body">{{ question.description }}</p>
12
+ {%- endif %}
13
+
28
14
  <form action="" method="post" novalidate>
29
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
15
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
30
16
  {{ govukInput({
31
- hint: {
17
+ hint: question.hint and {
32
18
  text: question.hint
33
19
  },
34
20
  label: {
@@ -1,35 +1,20 @@
1
1
  {% extends layoutTemplate %}
2
2
 
3
- {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
4
3
  {% from "govuk/components/radios/macro.njk" import govukRadios %}
5
4
  {% from "govuk/components/button/macro.njk" import govukButton %}
6
5
  {% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
7
6
 
8
- {% block before_content %}
9
- <div class="govuk-grid-row">
10
- <div class="govuk-grid-column-two-thirds">
11
- {% if errorSummary %}
12
- {{ govukErrorSummary({
13
- titleText: "There is a problem",
14
- errorList: errorSummary,
15
- attributes: {"data-cy": "error-wrapper"}
16
- }) }}
17
- {% endif %}
18
- </div>
19
- </div>
20
-
21
- {{ super() }}
22
- {% endblock before_content %}
23
-
24
- {% block content %}
7
+ {% block dynQuestionContent %}
25
8
  <div class="govuk-grid-row">
26
9
  <div class="govuk-grid-column-two-thirds">
27
10
  <form action="" method="post" novalidate>
28
- <input type="hidden" name="_csrf" value="{{ _csrf }}">
11
+ {% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
29
12
 
30
13
  {% if question.legend %}
31
14
  <h1 class="govuk-heading-l">{{ question.question }}</h1>
32
- <p class="govuk-body">{{ question.description }}</p>
15
+ {%- if question.description %}
16
+ <p class="govuk-body">{{ question.description }}</p>
17
+ {%- endif -%}
33
18
 
34
19
  {% if question.html %}
35
20
  {% include question.html ignore missing %}
@@ -62,7 +47,9 @@
62
47
  }
63
48
  }) %}
64
49
 
65
- <p class="govuk-body">{{ question.description }}</p>
50
+ {%- if question.description %}
51
+ <p class="govuk-body">{{ question.description }}</p>
52
+ {%- endif -%}
66
53
 
67
54
  {% if question.html %}
68
55
  {% include question.html ignore missing %}