@dwp/govuk-casa 7.0.8 → 8.0.0-beta2
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/README.md +22 -17
- package/dist/mjs/esm-wrapper.js +10 -0
- package/package.json +55 -80
- package/views/casa/components/checkboxes/template.njk +4 -1
- package/views/casa/components/date-input/template.njk +3 -3
- package/views/casa/components/journey-form/README.md +3 -1
- package/views/casa/components/journey-form/template.njk +1 -1
- package/views/casa/components/postal-address-object/template.njk +5 -5
- package/views/casa/components/radios/template.njk +1 -1
- package/views/casa/errors/static.njk +11 -0
- package/views/casa/layouts/journey.njk +26 -9
- package/views/casa/layouts/main.njk +7 -20
- package/views/casa/partials/scripts.njk +8 -3
- package/views/casa/partials/styles.njk +2 -2
- package/casa.js +0 -208
- package/definitions/review-page.js +0 -60
- package/dist/casa/css/casa-ie8.css +0 -1
- package/dist/casa/css/casa.css +0 -1
- package/dist/casa/js/casa.js +0 -1
- package/index.d.ts +0 -121
- package/lib/ConfigIngestor.js +0 -588
- package/lib/GatherModifier.js +0 -14
- package/lib/I18n.js +0 -160
- package/lib/JourneyContext.d.ts +0 -97
- package/lib/JourneyContext.js +0 -552
- package/lib/JourneyMap.js +0 -233
- package/lib/JourneyRoad.js +0 -330
- package/lib/Logger.js +0 -59
- package/lib/PageDictionary.d.ts +0 -11
- package/lib/PageDirectory.js +0 -77
- package/lib/Plan.js +0 -423
- package/lib/RoadConverter.js +0 -153
- package/lib/UserJourney.js +0 -8
- package/lib/Util.js +0 -227
- package/lib/Validation.js +0 -20
- package/lib/bootstrap/end-session.js +0 -44
- package/lib/bootstrap/load-definitions.js +0 -64
- package/lib/commonBodyParser.js +0 -15
- package/lib/enums.js +0 -6
- package/lib/gather-modifiers/index.js +0 -7
- package/lib/gather-modifiers/trimPostalAddressObject.js +0 -75
- package/lib/gather-modifiers/trimWhitespace.js +0 -16
- package/lib/utils/createGetRequest.d.ts +0 -5
- package/lib/utils/createGetRequest.js +0 -59
- package/lib/utils/index.js +0 -11
- package/lib/utils/parseRequest.d.ts +0 -5
- package/lib/utils/parseRequest.js +0 -72
- package/lib/utils/sanitise.js +0 -74
- package/lib/utils/validate.js +0 -32
- package/lib/validation/ArrayObjectField.js +0 -49
- package/lib/validation/ObjectField.js +0 -53
- package/lib/validation/SimpleField.d.ts +0 -12
- package/lib/validation/SimpleField.js +0 -46
- package/lib/validation/ValidationError.d.ts +0 -14
- package/lib/validation/ValidationError.js +0 -170
- package/lib/validation/ValidatorFactory.d.ts +0 -32
- package/lib/validation/ValidatorFactory.js +0 -91
- package/lib/validation/index.js +0 -22
- package/lib/validation/processor/flattenErrorArray.js +0 -24
- package/lib/validation/processor/queue.js +0 -214
- package/lib/validation/processor.js +0 -84
- package/lib/validation/rules/README.md +0 -3
- package/lib/validation/rules/ValidationRules.d.ts +0 -14
- package/lib/validation/rules/dateObject.js +0 -156
- package/lib/validation/rules/email.js +0 -44
- package/lib/validation/rules/inArray.js +0 -61
- package/lib/validation/rules/index.js +0 -23
- package/lib/validation/rules/nino.js +0 -48
- package/lib/validation/rules/optional.js +0 -14
- package/lib/validation/rules/postalAddressObject.js +0 -142
- package/lib/validation/rules/regex.js +0 -39
- package/lib/validation/rules/required.js +0 -57
- package/lib/validation/rules/strlen.js +0 -57
- package/lib/validation/rules/wordCount.js +0 -61
- package/lib/view-filters/formatDateObject.js +0 -35
- package/lib/view-filters/includes.js +0 -10
- package/lib/view-filters/index.js +0 -23
- package/lib/view-filters/mergeObjectsDeep.js +0 -21
- package/lib/view-filters/renderAsAttributes.js +0 -33
- package/middleware/errors/404.js +0 -12
- package/middleware/errors/catch-all.js +0 -27
- package/middleware/errors/index.js +0 -9
- package/middleware/headers/config-defaults.js +0 -57
- package/middleware/headers/headers.js +0 -40
- package/middleware/headers/index.js +0 -9
- package/middleware/i18n/i18n.js +0 -56
- package/middleware/i18n/index.js +0 -16
- package/middleware/index.js +0 -55
- package/middleware/mount/index.js +0 -9
- package/middleware/mount/mount.js +0 -10
- package/middleware/nunjucks/environment.js +0 -57
- package/middleware/nunjucks/index.js +0 -8
- package/middleware/page/csrf.js +0 -37
- package/middleware/page/edit-mode.js +0 -52
- package/middleware/page/gather.js +0 -75
- package/middleware/page/index.js +0 -103
- package/middleware/page/journey-continue.js +0 -157
- package/middleware/page/journey-rails.js +0 -102
- package/middleware/page/prepare-request.js +0 -77
- package/middleware/page/render.js +0 -75
- package/middleware/page/skip.js +0 -72
- package/middleware/page/utils.js +0 -206
- package/middleware/page/validate.js +0 -67
- package/middleware/session/expiry.js +0 -95
- package/middleware/session/genid.js +0 -18
- package/middleware/session/index.js +0 -18
- package/middleware/session/init.js +0 -25
- package/middleware/session/seed.js +0 -50
- package/middleware/session/timeout.js +0 -5
- package/middleware/static/asset-versions.js +0 -23
- package/middleware/static/index.js +0 -104
- package/middleware/static/prepare-assets.js +0 -51
- package/middleware/static/serve-assets.js +0 -58
- package/middleware/variables/index.js +0 -12
- package/middleware/variables/variables.js +0 -35
- package/src/browserconfig.xml +0 -5
- package/src/js/casa.js +0 -132
- package/src/scss/_casaElements.scss +0 -11
- package/src/scss/_casaGovukTemplateJinjaPolyfill.scss +0 -39
- package/src/scss/_casaMountUrl.scss +0 -8
- package/src/scss/casa-ie8.scss +0 -3
- package/src/scss/casa.scss +0 -14
- package/test/unit/templates/README.md +0 -5
- package/test/utils/BaseTestWaypoint.js +0 -106
- package/test/utils/concatWaypoints.js +0 -26
- package/test/utils/index.js +0 -6
- package/test/utils/testTraversal.js +0 -90
- package/views/casa/partials/cookie_message.njk +0 -3
- package/views/casa/partials/phase_banner_alpha.njk +0 -8
- package/views/casa/partials/phase_banner_beta.njk +0 -8
- package/views/casa/review/page-block.njk +0 -8
- package/views/casa/review/review.njk +0 -47
package/README.md
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
# CASA
|
|
2
2
|
|
|
3
|
-
A framework
|
|
3
|
+
A framework for building forms based on the [GOV.UK Design System](https://design-system.service.gov.uk/).
|
|
4
4
|
|
|
5
|
-
### Support
|
|
6
|
-
|
|
7
|
-
CASA is maintained by the [DWP Engineering Practice](mailto:open-source@engineering.digital.dwp.gov.uk).
|
|
8
|
-
|
|
9
|
-
### Contributing
|
|
10
|
-
|
|
11
|
-
If you'd like to contribute any changes, enhancements or report issues, please take a look at our [contribution guide](CONTRIBUTING.md).
|
|
12
5
|
|
|
13
6
|
## Features
|
|
14
7
|
|
|
15
8
|
* Adopts the [GOVUK Design System](https://design-system.service.gov.uk/) which provides well-researched, accessible markup out of the box
|
|
16
|
-
* Handles complex
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
9
|
+
* Handles complex journey routing so you can easily tailor users' journeys to provide the best experience
|
|
10
|
+
* Multi-language support
|
|
11
|
+
* A small core, but highly extensible through hook and plugin mechanisms
|
|
12
|
+
* Built on ExpressJS so offers a shallow learning curve
|
|
13
|
+
* Distributable supports both ES6 and CommonJS codebases
|
|
20
14
|
|
|
21
|
-
## Requirements
|
|
22
|
-
|
|
23
|
-
CASA aims to maintain support for the **latest LTS version** of NodeJS, and requires at least version `6.4.0` of npm. See the [NodeJS release schedule](https://nodejs.org/en/about/releases/) for more information.
|
|
24
15
|
|
|
25
16
|
## Getting started
|
|
26
17
|
|
|
27
|
-
|
|
18
|
+
```bash
|
|
19
|
+
npm -E @dwp/govuk-casa
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
* [Documentation](docs/index.md)
|
|
23
|
+
* [Examples](examples/)
|
|
28
24
|
|
|
29
|
-
Alternatively, read through our **[Guides](docs/guide.md)** to start building an understanding of the core concepts involved in building a CASA app.
|
|
30
25
|
|
|
31
26
|
## Migrating between versions
|
|
32
27
|
|
|
33
28
|
A series of migration guides are provided in [`docs/migration-guides/`](docs/migration-guides/) that should help you upgrade between major versions of CASA.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Support
|
|
32
|
+
|
|
33
|
+
CASA is maintained by the [DWP Engineering Practice](mailto:open-source@engineering.digital.dwp.gov.uk).
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
If you'd like to contribute any changes, enhancements or report issues, please take a look at our [contribution guide](CONTRIBUTING.md) and [design guidelines](docs/contributors/index.md).
|
package/dist/mjs/esm-wrapper.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Basic wrapper to act as the package entrypoint for ESM applications
|
|
2
2
|
// ref: https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1
|
|
3
|
+
// The `../casa.js` reference here is correct. This file will be copied into
|
|
4
|
+
// `dist/` in the right location at build time, which will resolve that file
|
|
5
|
+
// path correctly.
|
|
3
6
|
import casa from '../casa.js';
|
|
4
7
|
|
|
5
8
|
export const { configure } = casa;
|
|
@@ -7,5 +10,12 @@ export const { validators } = casa;
|
|
|
7
10
|
export const { field } = casa;
|
|
8
11
|
export const { Plan } = casa;
|
|
9
12
|
export const { JourneyContext } = casa;
|
|
13
|
+
export const { ValidatorFactory } = casa;
|
|
10
14
|
export const { ValidationError } = casa;
|
|
15
|
+
|
|
16
|
+
// Utilities
|
|
11
17
|
export const { waypointUrl } = casa;
|
|
18
|
+
export const { endSession } = casa;
|
|
19
|
+
|
|
20
|
+
// Nunjucks filters
|
|
21
|
+
export const { nunjucksFilters } = casa;
|
package/package.json
CHANGED
|
@@ -1,110 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dwp/govuk-casa",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "casa.js",
|
|
3
|
+
"version": "8.0.0-beta2",
|
|
4
|
+
"description": "A framework for building GOVUK Collect-And-Submit-Applications",
|
|
5
|
+
"main": "dist/casa.js",
|
|
6
|
+
"module": "dist/mjs/casa.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./dist/mjs/esm-wrapper.js",
|
|
9
|
+
"require": "./dist/casa.js"
|
|
10
|
+
},
|
|
11
|
+
"typings": "dist/casa.d.ts",
|
|
6
12
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"/locales/**/*",
|
|
11
|
-
"/middleware/**/*",
|
|
12
|
-
"/test/utils/**/*",
|
|
13
|
-
"/src/scss/*",
|
|
14
|
-
"/src/browserconfig.xml",
|
|
15
|
-
"/views/**/*",
|
|
16
|
-
"/index.js",
|
|
17
|
-
"/casa.js",
|
|
18
|
-
"/**/*.d.ts",
|
|
19
|
-
"!/**/*/.DS_Store",
|
|
20
|
-
"!/**/*/.gitkeep",
|
|
21
|
-
"!/examples/**/*",
|
|
22
|
-
"!/test/unit/testdata/**/*"
|
|
13
|
+
"dist/**/*",
|
|
14
|
+
"locales/**/*",
|
|
15
|
+
"views/**/*"
|
|
23
16
|
],
|
|
24
17
|
"engines": {
|
|
25
|
-
"node": ">=14.
|
|
18
|
+
"node": ">=14.17.2"
|
|
26
19
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
20
|
+
"scripts": {
|
|
21
|
+
"pipeline": "npm test && npm run test:e2e && npm run lint",
|
|
22
|
+
"test": "mocha './tests/**/*.test.js'",
|
|
23
|
+
"test:e2e": "spiderplan --worker-init ./tests/e2e/worker-init.js --language en ./tests/e2e/personas/**/*.yaml",
|
|
24
|
+
"test:combined": "npm test; npm run test:e2e",
|
|
25
|
+
"lint": "eslint .",
|
|
26
|
+
"coverage": "c8 npm run test:combined",
|
|
27
|
+
"build": "npm run build:prepare && npm run build:sources && npm run build:css-assets",
|
|
28
|
+
"build:prepare": "rm -rf dist/* && mkdir -p dist/assets/js/ && mkdir -p dist/assets/css/",
|
|
29
|
+
"build:sources": "tsc -p tsconfig-cjs.json && ./scripts/fixup.sh",
|
|
30
|
+
"build:css-assets": "node scripts/compile-sass.js",
|
|
31
|
+
"prepare": "npm run build",
|
|
32
|
+
"upgrade-deps": "OD=$(npm outdated --long --parseable); echo \"$OD\" | grep ':devDependencies:' | awk -F: '{ print $4 }' | xargs npm i -DE; echo \"$OD\" | grep ':dependencies:' | awk -F: '{ print $4 }' | xargs npm i -E"
|
|
30
33
|
},
|
|
34
|
+
"keywords": [],
|
|
35
|
+
"author": "DWP Digital",
|
|
36
|
+
"license": "ISC",
|
|
37
|
+
"type": "module",
|
|
31
38
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"colors": "1.4.0",
|
|
39
|
+
"cookie-parser": "1.4.6",
|
|
34
40
|
"csurf": "1.11.0",
|
|
35
41
|
"debug": "4.3.3",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
42
|
+
"deepmerge": "4.2.2",
|
|
43
|
+
"express": "4.17.1",
|
|
44
|
+
"express-session": "1.17.2",
|
|
39
45
|
"govuk-frontend": "3.14.0",
|
|
40
|
-
"govuk_template_jinja": "0.26.0",
|
|
41
46
|
"graphlib": "2.1.8",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
47
|
+
"helmet": "4.6.0",
|
|
48
|
+
"i18next": "21.6.0",
|
|
49
|
+
"i18next-http-middleware": "3.1.4",
|
|
50
|
+
"js-yaml": "4.1.0",
|
|
51
|
+
"lodash": "4.17.21",
|
|
44
52
|
"luxon": "2.1.1",
|
|
45
53
|
"nunjucks": "3.2.3",
|
|
46
|
-
"serve-favicon": "2.5.0",
|
|
47
|
-
"uid-safe": "2.1.5",
|
|
48
54
|
"uuid": "8.3.2",
|
|
49
|
-
"validator": "13.7.0"
|
|
55
|
+
"validator": "^13.7.0"
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
52
|
-
"@
|
|
58
|
+
"@babel/core": "7.16.0",
|
|
59
|
+
"@babel/eslint-parser": "7.16.3",
|
|
60
|
+
"@babel/preset-env": "7.16.4",
|
|
53
61
|
"@commitlint/config-conventional": "15.0.0",
|
|
54
|
-
"@
|
|
55
|
-
"@dwp/
|
|
62
|
+
"@dwp/casa-spiderplan": "2.0.0",
|
|
63
|
+
"@dwp/casa-spiderplan-a11y-plugin": "0.1.3",
|
|
64
|
+
"@dwp/casa-spiderplan-zap-plugin": "0.1.1",
|
|
56
65
|
"@dwp/eslint-config-base": "5.0.1",
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"autocannon": "7.5.0",
|
|
66
|
+
"@types/express": "4.17.13",
|
|
67
|
+
"@types/node": "16.11.12",
|
|
68
|
+
"@types/nunjucks": "3.2.0",
|
|
69
|
+
"babel-eslint": "10.1.0",
|
|
70
|
+
"c8": "7.10.0",
|
|
63
71
|
"chai": "4.3.4",
|
|
64
|
-
"
|
|
65
|
-
"chai-http": "4.3.0",
|
|
66
|
-
"cheerio": "1.0.0-rc.10",
|
|
67
|
-
"conventional-changelog-cli": "2.1.1",
|
|
72
|
+
"commitlint": "15.0.0",
|
|
68
73
|
"eslint": "7.32.0",
|
|
69
74
|
"eslint-plugin-no-unsafe-regex": "1.0.0",
|
|
70
75
|
"eslint-plugin-sonarjs": "0.11.0",
|
|
71
|
-
"
|
|
72
|
-
"express-session": "1.17.2",
|
|
76
|
+
"fast-check": "2.20.0",
|
|
73
77
|
"husky": "7.0.4",
|
|
74
|
-
"jsdom": "19.0.0",
|
|
75
|
-
"minimatch": "3.0.4",
|
|
76
78
|
"mocha": "9.1.3",
|
|
77
|
-
"nyc": "15.1.0",
|
|
78
|
-
"proxyquire": "2.1.3",
|
|
79
79
|
"sass": "1.44.0",
|
|
80
80
|
"sinon": "12.0.1",
|
|
81
81
|
"sinon-chai": "3.7.0",
|
|
82
82
|
"supertest": "6.1.6",
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"express": "4.x",
|
|
88
|
-
"express-session": "1.x"
|
|
89
|
-
},
|
|
90
|
-
"scripts": {
|
|
91
|
-
"pipeline": "npm test && npm run compliance && npm run quality && npm run security:vulnerable-packages && (npm outdated || true)",
|
|
92
|
-
"compliance": "npm run compliance:lint",
|
|
93
|
-
"compliance:lint": "eslint .",
|
|
94
|
-
"test": "npm run test:unit --silent && npm run test:integration --silent",
|
|
95
|
-
"test:unit": "mocha -R spec \"./test/unit/**/*.test.js\"",
|
|
96
|
-
"test:integration": "mocha -R spec \"./test/integration/**/*.test.js\"",
|
|
97
|
-
"test:performance": "node ./test/performance/plan.test.js",
|
|
98
|
-
"quality": "npm run quality:coverage",
|
|
99
|
-
"quality:coverage": "nyc npm test",
|
|
100
|
-
"quality:mutation": "stryker run",
|
|
101
|
-
"security": "npm run security:vulnerable-packages",
|
|
102
|
-
"security:vulnerable-packages": "npm audit --production --registry=https://registry.npmjs.org --json | node -e 'a=JSON.parse(fs.readFileSync(\"/dev/stdin\",\"utf-8\")).metadata.vulnerabilities;process.exit(a.high+a.critical);'",
|
|
103
|
-
"package:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
104
|
-
"compile-static-assets": "node ./scripts/compile-sass.js && node ./scripts/compile-js.js",
|
|
105
|
-
"prepare": "npm run compile-static-assets --silent; husky install",
|
|
106
|
-
"upgrade-deps": "OD=$(npm outdated --long --parseable); echo \"$OD\" | grep ':devDependencies:' | awk -F: '{ print $4 }' | xargs npm i -DE; echo \"$OD\" | grep ':dependencies:' | awk -F: '{ print $4 }' | xargs npm i -E"
|
|
107
|
-
},
|
|
108
|
-
"author": "DWP <open-source@engineering.digital.dwp.gov.uk>",
|
|
109
|
-
"license": "ISC"
|
|
83
|
+
"typescript": "4.5.3"
|
|
84
|
+
}
|
|
110
85
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
id: params.id if params.id else 'f-' + params.name + '-wrapper' | safe
|
|
17
17
|
}) %}
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
{# Add checked flag to chosen inputs #}
|
|
20
21
|
{% set mergedItems = [] %}
|
|
21
22
|
{% for item in params.items %}
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
{% set mergedItems = (mergedItems.push(item), mergedItems) %}
|
|
31
32
|
{% endfor %}
|
|
32
33
|
|
|
34
|
+
|
|
33
35
|
{# Merge parameters #}
|
|
34
36
|
{% set mergedParams = mergeObjects(params, {
|
|
35
37
|
name: fieldName,
|
|
@@ -43,11 +45,12 @@
|
|
|
43
45
|
|
|
44
46
|
{# Ensure that the first item has the id matching `f-<name>` in order for error summary linkage to work #}
|
|
45
47
|
{% if not mergedParams.items[0].id %}
|
|
46
|
-
{% set mergedParams =
|
|
48
|
+
{% set mergedParams = mergeObjects(mergedParams, {
|
|
47
49
|
items: [{
|
|
48
50
|
id: 'f-' + params.name
|
|
49
51
|
}]
|
|
50
52
|
}) %}
|
|
51
53
|
{% endif %}
|
|
52
54
|
|
|
55
|
+
|
|
53
56
|
{{ govukCheckboxes(mergedParams) }}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
namePrefix: '',
|
|
22
22
|
attributes: mergedAttributes,
|
|
23
23
|
items: [
|
|
24
|
-
|
|
24
|
+
mergeObjects({
|
|
25
25
|
label: t('macros:dateInput.day'),
|
|
26
26
|
classes: 'govuk-input--width-2 ' + (inputErrorClass if includes(fieldErrors[0].focusSuffix, '[dd]') or not hasSuffixHighlights)
|
|
27
27
|
}, params.items[0] if params.items[0] else {}, {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
name: params.namePrefix + '[dd]',
|
|
30
30
|
value: params.casaValue.dd
|
|
31
31
|
}),
|
|
32
|
-
|
|
32
|
+
mergeObjects({
|
|
33
33
|
label: t('macros:dateInput.month'),
|
|
34
34
|
classes: 'govuk-input--width-2 ' + (inputErrorClass if includes(fieldErrors[0].focusSuffix, '[mm]') or not hasSuffixHighlights)
|
|
35
35
|
}, params.items[1] if params.items[1] else {}, {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
name: params.namePrefix + '[mm]',
|
|
38
38
|
value: params.casaValue.mm
|
|
39
39
|
}),
|
|
40
|
-
|
|
40
|
+
mergeObjects({
|
|
41
41
|
label: t('macros:dateInput.year'),
|
|
42
42
|
classes: 'govuk-input--width-4 ' + (inputErrorClass if includes(fieldErrors[0].focusSuffix, '[yyyy]') or not hasSuffixHighlights)
|
|
43
43
|
}, params.items[2] if params.items[2] else {}, {
|
|
@@ -10,6 +10,7 @@ A "Continue" button (and "Cancel" link if in edit mode) will also be added.
|
|
|
10
10
|
{% from "casa/components/journey-form/macro.njk" import casaJourneyForm with context %}
|
|
11
11
|
|
|
12
12
|
{% call casaJourneyForm({
|
|
13
|
+
formUrl: '/form/url',
|
|
13
14
|
csrfToken: casa.csrfToken,
|
|
14
15
|
inEditMode: true,
|
|
15
16
|
editOriginUrl: '/url/to/review/page',
|
|
@@ -23,7 +24,7 @@ A "Continue" button (and "Cancel" link if in edit mode) will also be added.
|
|
|
23
24
|
Which will render something like this:
|
|
24
25
|
|
|
25
26
|
```html
|
|
26
|
-
<form action="
|
|
27
|
+
<form action="/form/url" method="post" autocomplete="off" novalidate class="casa-journey-form">
|
|
27
28
|
<input type="hidden" name="_csrf" value="..." />
|
|
28
29
|
<input type="hidden" name="edit" value="true" />
|
|
29
30
|
<input type="hidden" name="editorigin" value="/url/to/review/page" />
|
|
@@ -47,6 +48,7 @@ Note that the submit button is configured to prevent double-clicks and avoid dup
|
|
|
47
48
|
|
|
48
49
|
| Name | Type | Required | Description |
|
|
49
50
|
|------|------|----------|-------------|
|
|
51
|
+
| `formUrl` | string | Yes | The form's "action", available in a `formUrl` template variable |
|
|
50
52
|
| `csrfToken` | string | Yes | Token used to protect form from CSRF (available to user's templates via the global `casa.csrfToken` variable) |
|
|
51
53
|
| `inEditMode` | boolean | No | Toggle edit-mode of the form (available to page templates using default GET/POST handlers via the local `inEditMode` variable) |
|
|
52
54
|
| `editOriginUrl` | string | No | Absolute URL to the page from which the edit request came (defaults to `review`) (available to user's templates using default GET/POST handlers via the local `editOriginUrl` variable) |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
2
2
|
|
|
3
|
-
<form action="
|
|
3
|
+
<form action="{{ params.formUrl }}" method="post" autocomplete="off" novalidate class="casa-journey-form">
|
|
4
4
|
<input type="hidden" name="_csrf" value="{{ params.csrfToken }}" />
|
|
5
5
|
{% if params.inEditMode %}<input type="hidden" name="edit" value="true" />{% endif %}
|
|
6
6
|
{% if params.inEditMode and params.editOriginUrl %}<input type="hidden" name="editorigin" value="{{ params.editOriginUrl }}" />{% endif %}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{% if fieldAddress1Errors %}
|
|
15
15
|
{% set fieldAttributes = mergeObjects(fieldAttributes, {'data-validation': {fn: params.name + '[address1]', va: fieldAddress1Errors[0].validator} | dump}) %}
|
|
16
16
|
{% endif %}
|
|
17
|
-
{{ govukInput(
|
|
17
|
+
{{ govukInput(mergeObjects({
|
|
18
18
|
label: {
|
|
19
19
|
html: t('macros:postalAddressObject.address1')
|
|
20
20
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
{% if fieldAddress2Errors %}
|
|
34
34
|
{% set fieldAttributes = mergeObjects(fieldAttributes, {'data-validation': {fn: params.name + '[address2]', va: fieldAddress2Errors[0].validator} | dump}) %}
|
|
35
35
|
{% endif %}
|
|
36
|
-
{{ govukInput(
|
|
36
|
+
{{ govukInput(mergeObjects({
|
|
37
37
|
label: {
|
|
38
38
|
html: t('macros:postalAddressObject.address2')
|
|
39
39
|
},
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
{% if fieldErrors %}
|
|
55
55
|
{% set fieldAttributes = mergeObjects(fieldAttributes, {'data-validation': {fn: params.name + '[address3]', va: fieldErrors[0].validator} | dump}) %}
|
|
56
56
|
{% endif %}
|
|
57
|
-
{{ govukInput(
|
|
57
|
+
{{ govukInput(mergeObjects({
|
|
58
58
|
classes: "govuk-!-width-two-thirds",
|
|
59
59
|
label: {
|
|
60
60
|
html: t('macros:postalAddressObject.address3')
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
{% if fieldErrors %}
|
|
76
76
|
{% set fieldAttributes = mergeObjects(fieldAttributes, {'data-validation': {fn: params.name + '[address4]', va: fieldErrors[0].validator} | dump}) %}
|
|
77
77
|
{% endif %}
|
|
78
|
-
{{ govukInput(
|
|
78
|
+
{{ govukInput(mergeObjects({
|
|
79
79
|
classes: "govuk-!-width-two-thirds",
|
|
80
80
|
label: {
|
|
81
81
|
html: t('macros:postalAddressObject.address4')
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
{% if fieldErrors %}
|
|
97
97
|
{% set fieldAttributes = mergeObjects(fieldAttributes, {'data-validation': {fn: params.name + '[postcode]', va: fieldErrors[0].validator} | dump}) %}
|
|
98
98
|
{% endif %}
|
|
99
|
-
{{ govukInput(
|
|
99
|
+
{{ govukInput(mergeObjects({
|
|
100
100
|
classes: "govuk-input--width-10",
|
|
101
101
|
label: {
|
|
102
102
|
html: t('macros:postalAddressObject.postcode')
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
{# Ensure that the first item has the id matching `f-<name>` in order for error summary linkage to work #}
|
|
38
38
|
{% if not mergedParams.items[0].id %}
|
|
39
|
-
{% set mergedParams =
|
|
39
|
+
{% set mergedParams = mergeObjects(mergedParams, {
|
|
40
40
|
items: [{
|
|
41
41
|
id: 'f-' + params.name
|
|
42
42
|
}]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% extends "casa/layouts/main.njk" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Sorry, there is a problem with the service
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block content %}
|
|
8
|
+
<h1 class="govuk-heading-xl">Sorry, there is a problem with the service</h1>
|
|
9
|
+
|
|
10
|
+
<p class="govuk-body">Try again in a few moments.</p>
|
|
11
|
+
{% endblock %}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
{% extends "casa/layouts/main.njk" %}
|
|
2
2
|
|
|
3
3
|
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
|
|
4
|
+
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
5
|
+
{% from "casa/components/journey-form/macro.njk" import casaJourneyForm with context %}
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
{# Automatically apply padding with/without back link #}
|
|
6
9
|
{% set mainClasses %}{{ mainClasses }} govuk-main-wrapper--auto-spacing{% endset %}
|
|
7
10
|
|
|
8
11
|
|
|
12
|
+
{# Add back link, if appropriate #}
|
|
9
13
|
{% block beforeContent %}
|
|
10
|
-
{# Phase banner #}
|
|
11
|
-
{# TODO: remove phase variable - just get template author to override a `casa/partials/phase_banner.njk` template #}
|
|
12
|
-
{% if casa.phase == 'alpha' %}
|
|
13
|
-
{% include "casa/partials/phase_banner_alpha.njk" %}
|
|
14
|
-
{% elseif casa.phase == 'beta' %}
|
|
15
|
-
{% include "casa/partials/phase_banner_beta.njk" %}
|
|
16
|
-
{% endif %}
|
|
17
|
-
|
|
18
|
-
{# Add back link, if appropriate #}
|
|
19
14
|
{% if not inEditMode and casa.journeyPreviousUrl %}
|
|
20
15
|
{{ govukBackLink({
|
|
21
16
|
text: t('common:back'),
|
|
@@ -30,3 +25,25 @@
|
|
|
30
25
|
{{- t("error:documentTtlePrefix") if formErrors -}}
|
|
31
26
|
{% block casaPageTitle %}{% endblock %}
|
|
32
27
|
{%- endblock %}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
{# A default content block. Override this if you want a customised form #}
|
|
31
|
+
{% block content %}
|
|
32
|
+
{% if formErrorsGovukArray %}
|
|
33
|
+
{{ govukErrorSummary({
|
|
34
|
+
titleText: t("error:summary.h1"),
|
|
35
|
+
descriptionText: errorDescription or t('error:summary.defaultDescription'),
|
|
36
|
+
errorList: formErrorsGovukArray
|
|
37
|
+
}) }}
|
|
38
|
+
{% endif %}
|
|
39
|
+
|
|
40
|
+
{% call casaJourneyForm({
|
|
41
|
+
formUrl: formUrl,
|
|
42
|
+
csrfToken: casa.csrfToken,
|
|
43
|
+
inEditMode: inEditMode,
|
|
44
|
+
editOriginUrl: editOriginUrl,
|
|
45
|
+
activeContextId: activeContextId
|
|
46
|
+
}) %}
|
|
47
|
+
{% block journey_form %}{% endblock %}
|
|
48
|
+
{% endcall %}
|
|
49
|
+
{% endblock %}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{% extends "govuk/template.njk" %}
|
|
2
2
|
|
|
3
|
-
{% set assetPath = govuk.assetPath %}
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
{% block head %}
|
|
7
5
|
{% include "casa/partials/styles.njk" %}
|
|
@@ -12,29 +10,18 @@
|
|
|
12
10
|
{# Harcoding content for the skip link as t() may not be availble on some error pages #}
|
|
13
11
|
{{ govukSkipLink({
|
|
14
12
|
href: '#main-content',
|
|
15
|
-
text:
|
|
13
|
+
text: "Neidio i'r prif gynnwys" if locale === 'cy' else 'Skip to main content'
|
|
16
14
|
}) }}
|
|
17
15
|
{% endblock %}
|
|
18
16
|
|
|
19
17
|
|
|
20
|
-
{% block bodyStart %}
|
|
21
|
-
<div id="global-cookie-message" class="js-hidden">
|
|
22
|
-
{% include "casa/partials/cookie_message.njk" %}
|
|
23
|
-
</div>
|
|
24
|
-
{% endblock %}
|
|
25
|
-
|
|
26
|
-
|
|
27
18
|
{% block header %}
|
|
28
|
-
{{ govukHeader(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{% include "casa/partials/phase_banner_alpha.njk" %}
|
|
35
|
-
{% elseif casa.phase == 'beta' %}
|
|
36
|
-
{% include "casa/partials/phase_banner_beta.njk" %}
|
|
37
|
-
{% endif %}
|
|
19
|
+
{{ govukHeader({
|
|
20
|
+
assetsPath: assetPath + "/images",
|
|
21
|
+
serviceName: t('common:serviceName') if t else '',
|
|
22
|
+
serviceUrl: casa.mountUrl,
|
|
23
|
+
homepageUrl: "https://www.gov.uk/"
|
|
24
|
+
}) }}
|
|
38
25
|
{% endblock %}
|
|
39
26
|
|
|
40
27
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<!-- CASA -->
|
|
2
|
-
<script src="{{ casa.mountUrl }}govuk/
|
|
3
|
-
<script
|
|
4
|
-
|
|
2
|
+
<script src="{{ casa.mountUrl }}govuk/assets/js/all.js?{{ casaVersion }}"></script>
|
|
3
|
+
<script nonce="{{ cspNonce }}">
|
|
4
|
+
window.GOVUKFrontend.initAll();
|
|
5
|
+
if (window.history.replaceState) {
|
|
6
|
+
// Prevent re-submission of POST on refreshing page
|
|
7
|
+
window.history.replaceState(null, null, window.location.href);
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
5
10
|
<!-- /CASA -->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- CASA -->
|
|
2
|
-
<!--[if gt IE 8]><!--><link href="{{ casa.mountUrl }}
|
|
2
|
+
<!--[if gt IE 8]><!--><link href="{{ casa.mountUrl }}casa/assets/css/casa.css?{{ casaVersion }}" rel="stylesheet" /><!--<![endif]-->
|
|
3
3
|
<!--[if lte IE 8]>
|
|
4
|
-
<link href="{{ casa.mountUrl }}
|
|
4
|
+
<link href="{{ casa.mountUrl }}casa/assets/css/casa-ie8.css?{{ casaVersion }}" rel="stylesheet" />
|
|
5
5
|
<![endif]-->
|
|
6
6
|
<!-- /CASA -->
|