@planning-inspectorate/dynamic-forms 3.9.0 → 3.10.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.
- package/package.json +1 -1
- package/src/components/address/index.njk +1 -6
- package/src/components/boolean/index.njk +1 -6
- package/src/components/boolean/question.js +5 -2
- package/src/components/checkbox/index.njk +1 -6
- package/src/components/checkbox/question.js +4 -2
- package/src/components/date/index.njk +1 -21
- package/src/components/date-period/index.njk +1 -6
- package/src/components/date-time/index.njk +1 -6
- package/src/components/identifier/index.njk +1 -6
- package/src/components/manage-list/index.njk +1 -6
- package/src/components/multi-field-input/index.njk +1 -7
- package/src/components/number-entry/index.njk +1 -6
- package/src/components/radio/index.njk +1 -21
- package/src/components/select/index.njk +1 -22
- package/src/components/single-line-input/index.njk +1 -6
- package/src/components/task-list/index.njk +0 -1
- package/src/components/text-entry/index.njk +1 -6
- package/src/components/text-entry-redact/index.njk +1 -5
- package/src/components/unit-option-entry/index.njk +1 -6
- package/src/components/utils/actions.njk +35 -0
- package/src/questions/question-types.d.ts +26 -1
- package/src/questions/question.js +10 -3
- package/test/secondary-actions.test.js +253 -0
- package/test/snapshots/add-insurance.html +2 -1
- package/test/snapshots/companions.html +1 -1
- package/test/snapshots/contact-email.html +2 -1
- package/test/snapshots/departure-date.html +2 -2
- package/test/snapshots/holiday-activities.html +2 -1
- package/test/snapshots/holiday-arrival.html +2 -1
- package/test/snapshots/holiday-description.html +2 -1
- package/test/snapshots/holiday-destination.html +2 -2
- package/test/snapshots/holiday-period.html +2 -1
- package/test/snapshots/holiday-snack.html +2 -1
- package/test/snapshots/hotel-address.html +2 -1
- package/test/snapshots/luggage-weight-units.html +2 -1
- package/test/snapshots/manage-list-render-questions.html +2 -1
- package/test/snapshots/manage-list-render.html +2 -1
- package/test/snapshots/nights.html +3 -2
- package/test/snapshots/secondary-actions-radio-plain.html +46 -0
- package/test/snapshots/secondary-actions-radio.html +53 -0
- package/test/snapshots/secret-wish.html +2 -1
- package/test/snapshots/travel-class.html +2 -2
- package/test/snapshots/travel-companions.html +2 -1
- package/test/snapshots/travel-companions_travel-companion-email.html +2 -1
- package/test/snapshots/travel-companions_travel-companion-name.html +2 -1
- package/test/snapshots/travel-insurance-type.html +2 -2
- package/types/src/components/boolean/question.d.ts +3 -1
- package/types/src/components/boolean/question.d.ts.map +1 -1
- package/types/src/components/checkbox/question.d.ts +3 -1
- package/types/src/components/checkbox/question.d.ts.map +1 -1
- package/types/src/questions/question-types.d.ts +26 -1
- package/types/src/questions/question.d.ts +13 -2
- package/types/src/questions/question.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
4
4
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
|
|
7
6
|
{% set addressLine1= question.fieldName + "_addressLine1" %}
|
|
8
7
|
{% set addressLine2= question.fieldName + "_addressLine2" %}
|
|
@@ -97,11 +96,7 @@
|
|
|
97
96
|
text: errors[postcode].msg
|
|
98
97
|
}
|
|
99
98
|
}) }}
|
|
100
|
-
{
|
|
101
|
-
text: continueButtonText,
|
|
102
|
-
type: "submit",
|
|
103
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
104
|
-
}) }}
|
|
99
|
+
{% include "components/utils/actions.njk" %}
|
|
105
100
|
{% endcall %}
|
|
106
101
|
</form>
|
|
107
102
|
</div>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/radios/macro.njk" import govukRadios %}
|
|
4
4
|
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
|
|
7
6
|
{% if question.html %}
|
|
8
7
|
{% set htmlHint %}
|
|
@@ -55,11 +54,7 @@
|
|
|
55
54
|
items: question.options
|
|
56
55
|
}) }}
|
|
57
56
|
{% endif %}
|
|
58
|
-
{
|
|
59
|
-
text: continueButtonText,
|
|
60
|
-
type: "submit",
|
|
61
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
62
|
-
}) }}
|
|
57
|
+
{% include "components/utils/actions.njk" %}
|
|
63
58
|
</form>
|
|
64
59
|
</div>
|
|
65
60
|
</div>
|
|
@@ -46,6 +46,7 @@ export default class BooleanQuestion extends RadioQuestion {
|
|
|
46
46
|
* @param {Array.<import('../../questions/options-question.js').Option>} [params.options]
|
|
47
47
|
* @param {Array.<import('#base-validator').BaseValidator>} [params.validators]
|
|
48
48
|
* @param {boolean} [params.editable]
|
|
49
|
+
* @param {import('#question-types').QuestionParameters['viewData']} [params.viewData]
|
|
49
50
|
*/
|
|
50
51
|
constructor({
|
|
51
52
|
title,
|
|
@@ -59,7 +60,8 @@ export default class BooleanQuestion extends RadioQuestion {
|
|
|
59
60
|
validators,
|
|
60
61
|
interfaceType = 'radio',
|
|
61
62
|
options,
|
|
62
|
-
editable
|
|
63
|
+
editable,
|
|
64
|
+
viewData
|
|
63
65
|
}) {
|
|
64
66
|
let defaultOptions = options || [
|
|
65
67
|
{
|
|
@@ -90,7 +92,8 @@ export default class BooleanQuestion extends RadioQuestion {
|
|
|
90
92
|
options: defaultOptions,
|
|
91
93
|
validators,
|
|
92
94
|
html,
|
|
93
|
-
editable
|
|
95
|
+
editable,
|
|
96
|
+
viewData
|
|
94
97
|
});
|
|
95
98
|
|
|
96
99
|
this.interfaceType = interfaceType;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
|
|
6
5
|
{% block dynQuestionContent %}
|
|
7
6
|
<div class="govuk-grid-row">
|
|
@@ -27,11 +26,7 @@
|
|
|
27
26
|
},
|
|
28
27
|
items: question.options
|
|
29
28
|
}) }}
|
|
30
|
-
{
|
|
31
|
-
text: continueButtonText,
|
|
32
|
-
type: "submit",
|
|
33
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
34
|
-
}) }}
|
|
29
|
+
{% include "components/utils/actions.njk" %}
|
|
35
30
|
</form>
|
|
36
31
|
</div>
|
|
37
32
|
</div>
|
|
@@ -21,8 +21,9 @@ export default class CheckboxQuestion extends OptionsQuestion {
|
|
|
21
21
|
* @param {string} [params.description]
|
|
22
22
|
* @param {Array.<import('../../questions/options-question.js').Option>} params.options
|
|
23
23
|
* @param {Array.<import('#base-validator').BaseValidator>} [params.validators]
|
|
24
|
+
* @param {import('#question-types').QuestionParameters['viewData']} [params.viewData]
|
|
24
25
|
*/
|
|
25
|
-
constructor({ title, question, fieldName, url, pageTitle, description, options, validators }) {
|
|
26
|
+
constructor({ title, question, fieldName, url, pageTitle, description, options, validators, viewData }) {
|
|
26
27
|
super({
|
|
27
28
|
title,
|
|
28
29
|
question,
|
|
@@ -32,7 +33,8 @@ export default class CheckboxQuestion extends OptionsQuestion {
|
|
|
32
33
|
pageTitle,
|
|
33
34
|
description,
|
|
34
35
|
options,
|
|
35
|
-
validators
|
|
36
|
+
validators,
|
|
37
|
+
viewData
|
|
36
38
|
});
|
|
37
39
|
|
|
38
40
|
this.optionJoinString = defaultOptionJoinString;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/date-input/macro.njk" import govukDateInput %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
|
|
6
5
|
{% set day= question.fieldName + "_day" %}
|
|
7
6
|
{% set month= question.fieldName + "_month" %}
|
|
@@ -62,26 +61,7 @@
|
|
|
62
61
|
{{ beforeSubmitButton }}
|
|
63
62
|
{% endif %}
|
|
64
63
|
|
|
65
|
-
{
|
|
66
|
-
text: continueButtonText,
|
|
67
|
-
type: "submit",
|
|
68
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
69
|
-
}) }}
|
|
70
|
-
{% if extraActionButtons|length %}
|
|
71
|
-
{% for extraActionButton in extraActionButtons %}
|
|
72
|
-
{{ govukButton({
|
|
73
|
-
text: extraActionButton.text,
|
|
74
|
-
type: extraActionButton.type,
|
|
75
|
-
href: extraActionButton.href,
|
|
76
|
-
attributes: {
|
|
77
|
-
"formaction": extraActionButton.formaction or "",
|
|
78
|
-
"data-cy": "button-" + extraActionButton.text|lower|replace(" ", "-"),
|
|
79
|
-
"name": extraActionButton.text|lower|replace(" ", "-")
|
|
80
|
-
},
|
|
81
|
-
classes: extraActionButton.classes or "govuk-button--secondary"
|
|
82
|
-
}) }}
|
|
83
|
-
{% endfor %}
|
|
84
|
-
{% endif %}
|
|
64
|
+
{%- include "components/utils/actions.njk" %}
|
|
85
65
|
</form>
|
|
86
66
|
</div>
|
|
87
67
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/date-input/macro.njk" import govukDateInput %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
6
5
|
|
|
7
6
|
{% set startFieldName = question.fieldName + "_start" %}
|
|
@@ -117,11 +116,7 @@
|
|
|
117
116
|
]
|
|
118
117
|
}) }}
|
|
119
118
|
|
|
120
|
-
{
|
|
121
|
-
text: continueButtonText,
|
|
122
|
-
type: "submit",
|
|
123
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
124
|
-
}) }}
|
|
119
|
+
{% include "components/utils/actions.njk" %}
|
|
125
120
|
</form>
|
|
126
121
|
</div>
|
|
127
122
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
4
3
|
{% from "govuk/components/date-input/macro.njk" import govukDateInput %}
|
|
5
4
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
6
5
|
{% from "govuk/components/select/macro.njk" import govukSelect %}
|
|
@@ -117,11 +116,7 @@
|
|
|
117
116
|
</fieldset>
|
|
118
117
|
</div>
|
|
119
118
|
|
|
120
|
-
{
|
|
121
|
-
text: continueButtonText,
|
|
122
|
-
type: "submit",
|
|
123
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
124
|
-
}) }}
|
|
119
|
+
{% include "components/utils/actions.njk" %}
|
|
125
120
|
</form>
|
|
126
121
|
</div>
|
|
127
122
|
</div>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
4
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
|
|
7
6
|
{% block dynQuestionContent %}
|
|
8
7
|
<div class="govuk-grid-row">
|
|
@@ -56,11 +55,7 @@
|
|
|
56
55
|
|
|
57
56
|
{% endif %}
|
|
58
57
|
|
|
59
|
-
{
|
|
60
|
-
text: continueButtonText,
|
|
61
|
-
type: "submit",
|
|
62
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
63
|
-
}) }}
|
|
58
|
+
{% include "components/utils/actions.njk" %}
|
|
64
59
|
</form>
|
|
65
60
|
</div>
|
|
66
61
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
4
3
|
|
|
5
4
|
{% block dynQuestionContent %}
|
|
6
5
|
<div class="govuk-grid-row">
|
|
@@ -50,11 +49,7 @@
|
|
|
50
49
|
<a href="{{ util.trimTrailingSlash(originalUrl) }}/{{ question.addAnotherLink }}" class="govuk-link">Add another</a>
|
|
51
50
|
</p>
|
|
52
51
|
|
|
53
|
-
{
|
|
54
|
-
text: continueButtonText,
|
|
55
|
-
type: "submit",
|
|
56
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
57
|
-
}) }}
|
|
52
|
+
{% include "components/utils/actions.njk" %}
|
|
58
53
|
</form>
|
|
59
54
|
</div>
|
|
60
55
|
</div>
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
4
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
5
5
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
6
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
7
6
|
|
|
8
7
|
{% set inputFields = question.value %}
|
|
9
8
|
|
|
@@ -63,12 +62,7 @@
|
|
|
63
62
|
|
|
64
63
|
{% endcall %}
|
|
65
64
|
|
|
66
|
-
{
|
|
67
|
-
text: continueButtonText,
|
|
68
|
-
type: "submit",
|
|
69
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
70
|
-
}) }}
|
|
71
|
-
|
|
65
|
+
{% include "components/utils/actions.njk" %}
|
|
72
66
|
</form>
|
|
73
67
|
</div>
|
|
74
68
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
|
|
6
5
|
{% block dynQuestionContent %}
|
|
7
6
|
<div class="govuk-grid-row">
|
|
@@ -33,11 +32,7 @@
|
|
|
33
32
|
inputmode: 'numeric',
|
|
34
33
|
spellcheck: false
|
|
35
34
|
}) }}
|
|
36
|
-
{
|
|
37
|
-
text: continueButtonText,
|
|
38
|
-
type: "submit",
|
|
39
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
40
|
-
}) }}
|
|
35
|
+
{% include "components/utils/actions.njk" -%}
|
|
41
36
|
</form>
|
|
42
37
|
</div>
|
|
43
38
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/radios/macro.njk" import govukRadios %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
6
5
|
|
|
7
6
|
{% block dynQuestionContent %}
|
|
@@ -70,26 +69,7 @@
|
|
|
70
69
|
|
|
71
70
|
{% endif %}
|
|
72
71
|
|
|
73
|
-
{
|
|
74
|
-
text: continueButtonText,
|
|
75
|
-
type: "submit",
|
|
76
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
77
|
-
}) }}
|
|
78
|
-
{% if extraActionButtons|length %}
|
|
79
|
-
{% for extraActionButton in extraActionButtons %}
|
|
80
|
-
{{ govukButton({
|
|
81
|
-
text: extraActionButton.text,
|
|
82
|
-
type: extraActionButton.type,
|
|
83
|
-
href: extraActionButton.href,
|
|
84
|
-
attributes: {
|
|
85
|
-
"formaction": extraActionButton.formaction or "",
|
|
86
|
-
"data-cy": "button-" + extraActionButton.text|lower|replace(" ", "-"),
|
|
87
|
-
"name": extraActionButton.text|lower|replace(" ", "-")
|
|
88
|
-
},
|
|
89
|
-
classes: extraActionButton.classes or "govuk-button--secondary"
|
|
90
|
-
}) }}
|
|
91
|
-
{% endfor %}
|
|
92
|
-
{% endif %}
|
|
72
|
+
{%- include "components/utils/actions.njk" %}
|
|
93
73
|
</form>
|
|
94
74
|
</div>
|
|
95
75
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/select/macro.njk" import govukSelect %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
|
|
6
5
|
{% block head %}
|
|
7
6
|
{% if not question.disableAccessibleAutocomplete %}
|
|
@@ -38,28 +37,8 @@
|
|
|
38
37
|
items: question.options
|
|
39
38
|
}) }}
|
|
40
39
|
|
|
41
|
-
{{ govukButton({
|
|
42
|
-
text: continueButtonText,
|
|
43
|
-
type: "submit",
|
|
44
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
45
|
-
}) }}
|
|
46
|
-
|
|
47
|
-
{% if extraActionButtons|length %}
|
|
48
|
-
{% for extraActionButton in extraActionButtons %}
|
|
49
|
-
{{ govukButton({
|
|
50
|
-
text: extraActionButton.text,
|
|
51
|
-
type: extraActionButton.type,
|
|
52
|
-
href: extraActionButton.href,
|
|
53
|
-
attributes: {
|
|
54
|
-
"formaction": extraActionButton.formaction or "",
|
|
55
|
-
"data-cy": "button-" + extraActionButton.text|lower|replace(" ", "-"),
|
|
56
|
-
"name": extraActionButton.text|lower|replace(" ", "-")
|
|
57
|
-
},
|
|
58
|
-
classes: extraActionButton.classes or "govuk-button--secondary"
|
|
59
|
-
}) }}
|
|
60
|
-
{% endfor %}
|
|
61
|
-
{% endif %}
|
|
62
40
|
|
|
41
|
+
{% include "components/utils/actions.njk" %}
|
|
63
42
|
</form>
|
|
64
43
|
</div>
|
|
65
44
|
</div>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
4
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
|
|
7
6
|
{% block dynQuestionContent %}
|
|
8
7
|
<div class="govuk-grid-row">
|
|
@@ -70,11 +69,7 @@
|
|
|
70
69
|
|
|
71
70
|
{% endif %}
|
|
72
71
|
|
|
73
|
-
{
|
|
74
|
-
text: continueButtonText,
|
|
75
|
-
type: "submit",
|
|
76
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
77
|
-
}) }}
|
|
72
|
+
{% include "components/utils/actions.njk" %}
|
|
78
73
|
</form>
|
|
79
74
|
</div>
|
|
80
75
|
</div>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
|
|
4
4
|
{% from "govuk/components/tag/macro.njk" import govukTag %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
{% from "./task-list-multi-section.njk" import multiTaskList %}
|
|
7
6
|
{% from "./task-list-single-section.njk" import singleTaskList %}
|
|
8
7
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/textarea/macro.njk" import govukTextarea %}
|
|
4
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
5
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
|
|
7
6
|
|
|
8
7
|
{% block dynQuestionContent %}
|
|
@@ -78,11 +77,7 @@
|
|
|
78
77
|
</div>
|
|
79
78
|
{% endif %}
|
|
80
79
|
|
|
81
|
-
{
|
|
82
|
-
text: continueButtonText,
|
|
83
|
-
type: "submit",
|
|
84
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
85
|
-
}) }}
|
|
80
|
+
{% include "components/utils/actions.njk" %}
|
|
86
81
|
</form>
|
|
87
82
|
</div>
|
|
88
83
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/radios/macro.njk" import govukRadios %}
|
|
4
|
-
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
4
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
6
5
|
|
|
7
6
|
{% block dynQuestionContent %}
|
|
@@ -37,11 +36,7 @@
|
|
|
37
36
|
|
|
38
37
|
{% endcall %}
|
|
39
38
|
|
|
40
|
-
{
|
|
41
|
-
text: continueButtonText,
|
|
42
|
-
type: "submit",
|
|
43
|
-
attributes: { "data-cy":"button-save-and-continue"}
|
|
44
|
-
}) }}
|
|
39
|
+
{% include "components/utils/actions.njk" %}
|
|
45
40
|
</form>
|
|
46
41
|
</div>
|
|
47
42
|
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{% from "govuk/components/button/macro.njk" import govukButton -%}
|
|
2
|
+
|
|
3
|
+
{# for backwards compatibility #}
|
|
4
|
+
{%- set secondaryActions = secondaryActions or extraActionButtons -%}
|
|
5
|
+
{%- set hasSecondaryActions = secondaryActions|length > 0 -%}
|
|
6
|
+
|
|
7
|
+
{% if hasSecondaryActions %}<div class="govuk-button-group">
|
|
8
|
+
{% endif %}
|
|
9
|
+
{{ govukButton({
|
|
10
|
+
text: continueButtonText,
|
|
11
|
+
type: "submit",
|
|
12
|
+
attributes: { "data-cy":"button-save-and-continue"}
|
|
13
|
+
}) }}
|
|
14
|
+
|
|
15
|
+
{% if hasSecondaryActions %}
|
|
16
|
+
{% for secondaryAction in secondaryActions %}
|
|
17
|
+
{%- set name = secondaryAction.text|lower|replace(" ", "-") -%}
|
|
18
|
+
{%- if secondaryAction.href -%}
|
|
19
|
+
{# name and formaction aren't valid for <a> tags #}
|
|
20
|
+
{%- set attributes = {"data-cy": "button-" + name} -%}
|
|
21
|
+
{%- elseif secondaryAction.formaction and (not secondaryAction.type or secondaryAction.type == "submit") -%}
|
|
22
|
+
{%- set attributes = {"data-cy": "button-" + name, "name": name, "formaction": secondaryAction.formaction} -%}
|
|
23
|
+
{%- else -%}
|
|
24
|
+
{%- set attributes = {"data-cy": "button-" + name, "name": name} -%}
|
|
25
|
+
{%- endif %}
|
|
26
|
+
{{ govukButton({
|
|
27
|
+
text: secondaryAction.text,
|
|
28
|
+
type: secondaryAction.type,
|
|
29
|
+
href: secondaryAction.href,
|
|
30
|
+
attributes: attributes,
|
|
31
|
+
classes: secondaryAction.classes or "govuk-button--secondary"
|
|
32
|
+
}) }}
|
|
33
|
+
{% endfor %}
|
|
34
|
+
</div>
|
|
35
|
+
{%- endif %}
|
|
@@ -22,7 +22,17 @@ export interface QuestionParameters {
|
|
|
22
22
|
// override the action link for this question
|
|
23
23
|
actionLink?: ActionLink;
|
|
24
24
|
// static view data for this question
|
|
25
|
-
viewData?:
|
|
25
|
+
viewData?: {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated replaced by secondaryActions
|
|
28
|
+
*/
|
|
29
|
+
extraActionButtons?: SecondaryAction[];
|
|
30
|
+
/**
|
|
31
|
+
* Secondary action buttons
|
|
32
|
+
*/
|
|
33
|
+
secondaryActions?: SecondaryAction[];
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
export interface ActionLink {
|
|
@@ -30,6 +40,21 @@ export interface ActionLink {
|
|
|
30
40
|
href: string;
|
|
31
41
|
}
|
|
32
42
|
|
|
43
|
+
export type SecondaryAction = SecondaryActionButton | SecondaryActionLink;
|
|
44
|
+
|
|
45
|
+
export interface SecondaryActionButton {
|
|
46
|
+
text: string;
|
|
47
|
+
type?: string;
|
|
48
|
+
formaction?: string;
|
|
49
|
+
classes?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SecondaryActionLink {
|
|
53
|
+
text: string;
|
|
54
|
+
href: string;
|
|
55
|
+
classes?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
export interface QuestionViewModel {
|
|
34
59
|
question: {
|
|
35
60
|
value: string | number | Record<string, any>;
|
|
@@ -92,7 +92,14 @@ export class Question {
|
|
|
92
92
|
title: '',
|
|
93
93
|
text: ''
|
|
94
94
|
};
|
|
95
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Private, but not marked as such because it breaks types, either using #variable:
|
|
97
|
+
* - Property '#isInManageListSection' is missing in type
|
|
98
|
+
* or with @private
|
|
99
|
+
* - Types have separate declarations of a private property '_isInManageListSection'.
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
*/
|
|
102
|
+
_isInManageListSection = false;
|
|
96
103
|
|
|
97
104
|
/**
|
|
98
105
|
* @param {import('#question-types').QuestionParameters} params
|
|
@@ -169,14 +176,14 @@ export class Question {
|
|
|
169
176
|
* @returns {boolean}
|
|
170
177
|
*/
|
|
171
178
|
get isInManageListSection() {
|
|
172
|
-
return this
|
|
179
|
+
return this._isInManageListSection;
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
set isInManageListSection(value) {
|
|
176
183
|
if (!value) {
|
|
177
184
|
throw new Error('Question isInManageListSection is false by default');
|
|
178
185
|
}
|
|
179
|
-
this
|
|
186
|
+
this._isInManageListSection = value;
|
|
180
187
|
}
|
|
181
188
|
|
|
182
189
|
/**
|