Skip to content

Commit 3edfdcc

Browse files
Use custom layout for DXT form pages (#66)
- Use layouts/form.njk as the base for DXT form pages - Update DXT to 0.1.14 - Fix blank string - Import DXT SCSS - Rename form.njk to dxt-forms.njk - Add Error: prefix to page title if errors exist - Include form views on viewpaths Co-authored-by: Alistair Laing <aliuk2012@users.noreply.github.com>
1 parent 4735cdc commit 3edfdcc

16 files changed

Lines changed: 85 additions & 109 deletions

File tree

package-lock.json

Lines changed: 33 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"license": "OGL-UK-3.0",
4040
"dependencies": {
4141
"@babel/runtime": "^7.26.0",
42-
"@defra/forms-engine-plugin": "^0.1.8",
42+
"@defra/forms-engine-plugin": "^0.1.15",
4343
"@defra/hapi-tracing": "^1.0.0",
4444
"@elastic/ecs-pino-format": "^1.5.0",
4545
"@hapi/bell": "^13.1.0",
@@ -123,7 +123,7 @@
123123
"tsx": "^4.19.2",
124124
"typescript": "^5.6.3",
125125
"webpack": "^5.96.1",
126-
"webpack-assets-manifest": "^5.2.1",
126+
"webpack-assets-manifest": "^6.0.2",
127127
"webpack-cli": "^5.1.4"
128128
}
129129
}

src/client/stylesheets/application.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@use 'govuk-frontend';
1+
@use 'pkg:@defra/forms-engine-plugin';
2+
@use 'pkg:govuk-frontend';
23

34
@use 'variables';
45
@use 'helpers';

src/config/nunjucks/nunjucks.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import * as filters from './filters/filters.js'
99
import * as globals from './globals.js'
1010

1111
const dirname = path.dirname(fileURLToPath(import.meta.url))
12+
export const grantsUiPaths = [
13+
path.resolve(dirname, '../../server/common/templates'),
14+
path.resolve(dirname, '../../server/common/components')
15+
]
1216
const nunjucksEnvironment = nunjucks.configure(
13-
[
14-
'node_modules/govuk-frontend/dist/',
15-
path.resolve(dirname, '../../server/common/templates'),
16-
path.resolve(dirname, '../../server/common/components')
17-
],
17+
['node_modules/govuk-frontend/dist/', ...grantsUiPaths],
1818
{
1919
autoescape: true,
2020
throwOnUndefined: false,

src/server/common/forms/definitions/adding-value.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
{
458458
"type": "YesNoField",
459459
"name": "remainingCostsYesNoField",
460-
"title": " ",
460+
"title": "Can you pay the remaining costs?",
461461
"options": {
462462
"customValidationMessages": {
463463
"any.required": "Select yes if you can pay the remaining costs"

src/server/common/helpers/serve-static-files.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ export const serveStaticFiles = {
1717
name: 'staticFiles',
1818
register(server) {
1919
server.route([
20-
{
21-
method: 'GET',
22-
path: '/stylesheets/application.min.css',
23-
handler: {
24-
file: './stylesheets/dxt-application.min.css'
25-
},
26-
options
27-
},
2820
{
2921
method: 'GET',
3022
path: '/javascripts/application.min.js',
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends "layouts/page.njk" %}
2+
3+
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
4+
5+
{% block pageTitle %}
6+
{{ "Error: " if errors | length }}{{ pageTitle | evaluate }} | {{ serviceName }}
7+
{% endblock %}
8+
9+
{% block beforeContent %}
10+
{{ super() }}
11+
{% if backLink %}
12+
{{ govukBackLink(backLink) }}
13+
{% endif %}
14+
{% endblock %}

src/server/common/templates/layouts/page.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
{% endblock %}
4444

4545
{% block pageTitle %}
46-
{{ pageTitle }} | {{ serviceName }}
46+
{{ "Error: " if errors | length }}{{ pageTitle }} | {{ serviceName }}
4747
{% endblock %}
4848

4949
{% block beforeContent %}

src/server/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import Scooter from '@hapi/scooter'
99
import path from 'path'
1010
import { fileURLToPath } from 'url'
1111
import { config } from '~/src/config/config.js'
12-
import { nunjucksConfig } from '~/src/config/nunjucks/nunjucks.js'
12+
import {
13+
nunjucksConfig,
14+
grantsUiPaths
15+
} from '~/src/config/nunjucks/nunjucks.js'
16+
import { context } from '~/src/config/nunjucks/context/context.js'
1317
// import auth from '~/src/plugins/auth.js'
1418
import csp from '~/src/plugins/content-security-policy.js'
1519
import sso from '~/src/plugins/sso.js'
@@ -43,7 +47,7 @@ const getViewPaths = () => {
4347
`${basePath}/land-grants/parcel`,
4448
`${basePath}/land-grants/submission`,
4549
`${basePath}/views`,
46-
`${basePath}/common/templates`
50+
...grantsUiPaths
4751
]
4852
}
4953

@@ -104,7 +108,11 @@ const registerFormsPlugin = async (server) => {
104108
filters: {
105109
formatCurrency
106110
},
107-
viewPaths: getViewPaths(),
111+
nunjucks: {
112+
baseLayoutPath: 'layouts/dxt-form.njk',
113+
paths: getViewPaths()
114+
},
115+
viewContext: context,
108116
controllers: {
109117
ConfirmationPageController,
110118
DeclarationPageController,

src/server/land-grants/actions/land-actions.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends baseLayoutPath %}
22

33
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
44
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
@@ -42,11 +42,11 @@
4242
checked: actions and actions.includes(action.code)
4343
}]) %}
4444
{% endfor %}
45-
45+
4646
{% if actionList.length > 0 %}
4747
<div class="govuk-form-group">
4848
<fieldset class="govuk-fieldset" aria-describedby="action-hint">
49-
49+
5050
<table class="govuk-table">
5151
<caption class="govuk-table__caption govuk-table__caption--l">Available actions for selected parcel</caption>
5252
<thead class="govuk-table__head">
@@ -84,7 +84,7 @@
8484

8585
</fieldset>
8686
</div>
87-
87+
8888
<div class="govuk-button-group">
8989
<input type="hidden" name="crumb" value="{{ crumb }}">
9090
{% block form %}

0 commit comments

Comments
 (0)