Skip to content

Commit dea88cb

Browse files
Consolidate form views
1 parent 2b4fcb8 commit dea88cb

File tree

14 files changed

+119
-273
lines changed

14 files changed

+119
-273
lines changed

designer/server/src/routes/forms/contact/email.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default [
4545
// Create the email contact view model
4646
const model = emailViewModel(metadata, validation)
4747

48-
return h.view('forms/contact/email', model)
48+
return h.view('forms/question-inputs', model)
4949
},
5050
options: {
5151
auth: {

designer/server/src/routes/forms/contact/online.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default [
4646
// Create the online contact view model
4747
const model = onlineViewModel(metadata, validation)
4848

49-
return h.view('forms/contact/online', model)
49+
return h.view('forms/question-inputs', model)
5050
},
5151
options: {
5252
auth: {
Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
1-
{% extends "layouts/page.njk" %}
1+
{% extends "forms/question-input.njk" %}
22

3-
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
4-
{% from "govuk/components/input/macro.njk" import govukInput %}
5-
6-
{% block content %}
7-
<form method="post" novalidate>
8-
{% call appPageBody({
9-
errorList: errorList,
10-
heading: pageHeading,
11-
buttons: buttons
12-
}) %}
13-
<p class="govuk-body">
14-
To confirm the file was meant for your team, enter the email address the file was sent to.
15-
</p>
16-
17-
{{ govukInput({
18-
label: field.label,
19-
hint: field.hint,
20-
id: field.id,
21-
name: field.name,
22-
type: field.type,
23-
value: field.value,
24-
errorMessage: {
25-
text: formErrors[field.name].text
26-
} if formErrors[field.name],
27-
autocapitalize: field.autocapitalize,
28-
autocomplete: field.autocomplete,
29-
spellcheck: field.spellcheck
30-
}) }}
31-
{% endcall %}
32-
</form>
33-
{% endblock %}
3+
{% set bodyStart %}
4+
<p class="govuk-body">
5+
To confirm the file was meant for your team, enter the email address the file was sent to.
6+
</p>
7+
{% endset %}

designer/server/src/views/forms/contact/email.njk

Lines changed: 0 additions & 37 deletions
This file was deleted.

designer/server/src/views/forms/contact/online.njk

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
1-
{% extends "layouts/page.njk" %}
1+
{% extends "forms/question-textarea.njk" %}
22

3-
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
4-
{% from "govuk/components/textarea/macro.njk" import govukTextarea %}
5-
6-
{% block beforeContent %}
7-
<div class="govuk-width-container app-width-container--wide">
8-
{{ govukBackLink(backLink) }}
3+
{% set bodyStart %}
4+
<p class="govuk-body">You can provide an optional phone number for support. You must include the opening times.</p>
5+
<h2 class="govuk-heading-s">Example</h2>
6+
<div class="govuk-inset-text">
7+
<ul class="govuk-list">
8+
<li>Telephone: 020 7946 0101</li>
9+
<li>Monday to Friday, 8am to 6pm</li>
10+
</ul>
911
</div>
10-
{% endblock %}
11-
12-
{% block content %}
13-
<form method="post" novalidate>
14-
{% call appPageBody({
15-
errorList: errorList,
16-
heading: pageHeading,
17-
buttons: buttons
18-
}) %}
19-
<p class="govuk-body">You can provide an optional phone number for support. You must include the opening times.</p>
20-
<h2 class="govuk-heading-s">Example</h2>
21-
<div class="govuk-inset-text">
22-
<ul class="govuk-list">
23-
<li>Telephone: 020 7946 0101</li>
24-
<li>Monday to Friday, 8am to 6pm</li>
25-
</ul>
26-
</div>
27-
28-
{{ govukTextarea({
29-
label: field.label,
30-
hint: field.hint,
31-
id: field.id,
32-
name: field.name,
33-
type: field.type,
34-
value: field.value,
35-
errorMessage: {
36-
text: formErrors[field.name].text
37-
} if formErrors[field.name],
38-
autocapitalize: field.autocapitalize,
39-
autocomplete: field.autocomplete,
40-
spellcheck: field.spellcheck
41-
}) }}
12+
{% endset %}
4213

43-
{% include "forms/partials/markdown-guidance.njk" %}
44-
{% endcall %}
45-
</form>
46-
{% endblock %}
14+
{% set bodyEnd %}
15+
{% include "forms/partials/markdown-guidance.njk" %}
16+
{% endset %}

designer/server/src/views/forms/make-draft-live.njk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
{% endif %}
1717

1818
{% if form.notificationEmail %}
19-
<p class="govuk-body-l">
20-
Completed forms will be sent to <a href="mailto:{{ form.notificationEmail | urlencode }}" class="govuk-link">{{ form.notificationEmail }}</a>.
21-
</p>
19+
<p class="govuk-body-l">
20+
Completed forms will be sent to <a href="mailto:{{ form.notificationEmail | urlencode }}" class="govuk-link">{{ form.notificationEmail }}</a>.
21+
</p>
2222
{% endif %}
2323
{% endcall %}
2424
</form>
Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
1-
{% extends "layouts/page.njk" %}
1+
{% extends "forms/question-input.njk" %}
22

3-
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
4-
{% from "govuk/components/input/macro.njk" import govukInput %}
5-
6-
{% block beforeContent %}
7-
<div class="govuk-width-container app-width-container--wide">
8-
{{ govukBackLink(backLink) }}
9-
</div>
10-
{% endblock %}
11-
12-
{% block content %}
13-
<form method="post" novalidate>
14-
{% call appPageBody({
15-
errorList: errorList,
16-
heading: pageHeading,
17-
buttons: buttons
18-
}) %}
19-
<p class="govuk-body-l">Enter an email address for submitted forms to be sent to for processing.</p>
20-
<p class="govuk-body-l">It should be a shared government email inbox and you should test it before making a form live.</p>
21-
22-
{{ govukInput({
23-
label: field.label,
24-
hint: field.hint,
25-
id: field.id,
26-
name: field.name,
27-
type: field.type,
28-
value: field.value,
29-
errorMessage: {
30-
text: formErrors[field.name].text
31-
} if formErrors[field.name],
32-
autocapitalize: field.autocapitalize,
33-
autocomplete: field.autocomplete,
34-
spellcheck: field.spellcheck
35-
}) }}
36-
{% endcall %}
37-
</form>
38-
{% endblock %}
3+
{% set bodyStart %}
4+
<p class="govuk-body-l">Enter an email address for submitted forms to be sent to for processing.</p>
5+
<p class="govuk-body-l">It should be a shared government email inbox and you should test it before making a form live.</p>
6+
{% endset %}
Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,8 @@
1-
{% extends "layouts/page.njk" %}
2-
3-
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
4-
{% from "govuk/components/input/macro.njk" import govukInput %}
5-
6-
{% block beforeContent %}
7-
<div class="govuk-width-container app-width-container--wide">
8-
{{ govukBackLink(backLink) }}
9-
</div>
10-
{% endblock %}
11-
12-
{% block content %}
13-
<form method="post" novalidate>
14-
{% call appPageBody({
15-
errorList: errorList,
16-
heading: pageHeading,
17-
buttons: buttons
18-
}) %}
19-
<p class="govuk-body-l">
20-
To comply with the UK General Data Protection Regulation (UK GDPR),
21-
you must provide privacy information for the people who will enter their data into your form.
22-
</p>
23-
24-
{{ govukInput({
25-
label: field.label,
26-
hint: field.hint,
27-
id: field.id,
28-
name: field.name,
29-
type: field.type,
30-
value: field.value,
31-
errorMessage: {
32-
text: formErrors[field.name].text
33-
} if formErrors[field.name],
34-
autocapitalize: field.autocapitalize,
35-
autocomplete: field.autocomplete,
36-
spellcheck: field.spellcheck
37-
}) }}
38-
{% endcall %}
39-
</form>
40-
{% endblock %}
1+
{% extends "forms/question-input.njk" %}
2+
3+
{% set bodyStart %}
4+
<p class="govuk-body-l">
5+
To comply with the UK General Data Protection Regulation (UK GDPR),
6+
you must provide privacy information for the people who will enter their data into your form.
7+
</p>
8+
{% endset %}

designer/server/src/views/forms/question-input.njk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
heading: pageHeading,
1717
buttons: buttons
1818
}) %}
19+
{% if bodyStart %}
20+
{{ bodyStart | safe }}
21+
{% endif %}
22+
1923
{{ govukInput({
2024
label: field.label,
2125
hint: field.hint,
@@ -30,6 +34,10 @@
3034
autocomplete: field.autocomplete,
3135
spellcheck: field.spellcheck
3236
}) }}
37+
38+
{% if bodyEnd %}
39+
{{ bodyEnd | safe }}
40+
{% endif %}
3341
{% endcall %}
3442
</form>
3543
{% endblock %}

0 commit comments

Comments
 (0)