hof 20.0.0-beta.6 → 20.0.0-beta.9
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/automate-publish.yml +1 -1
- package/.github/workflows/automate-tag.yml +1 -1
- package/.nyc_output/e2fdc3eb-4fd2-47e0-a392-fe5f665776a4.json +1 -0
- package/.nyc_output/processinfo/e2fdc3eb-4fd2-47e0-a392-fe5f665776a4.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/build/lib/mkdir.js +2 -2
- package/components/date/index.js +37 -26
- package/components/date/templates/date.html +3 -3
- package/components/emailer/index.js +49 -41
- package/components/emailer/transports/debug.js +1 -2
- package/components/summary/index.js +18 -0
- package/config/hof-defaults.js +5 -3
- package/config/rate-limits.js +20 -0
- package/config/sanitisation-rules.js +29 -0
- package/controller/base-controller.js +26 -8
- package/controller/controller.js +11 -15
- package/frontend/govuk-template/build/config.js +1 -1
- package/frontend/template-mixins/mixins/template-mixins.js +5 -5
- package/frontend/template-mixins/partials/forms/checkbox-group.html +3 -3
- package/frontend/template-mixins/partials/forms/input-text-group.html +2 -2
- package/frontend/template-mixins/partials/forms/option-group.html +3 -3
- package/frontend/template-mixins/partials/forms/select.html +2 -2
- package/frontend/template-mixins/partials/forms/textarea-group.html +2 -2
- package/frontend/template-mixins/partials/mixins/panel.html +1 -2
- package/frontend/template-partials/translations/src/en/errors.json +12 -0
- package/frontend/template-partials/views/rate-limit-error.html +10 -0
- package/frontend/themes/gov-uk/client-js/govuk-cookies.js +43 -44
- package/frontend/themes/gov-uk/client-js/index.js +2 -2
- package/frontend/themes/gov-uk/client-js/skip-to-main.js +18 -17
- package/index.js +9 -4
- package/lib/router.js +2 -1
- package/lib/settings.js +9 -8
- package/middleware/errors.js +32 -0
- package/middleware/index.js +2 -1
- package/middleware/rate-limiter.js +98 -0
- package/package.json +6 -7
- package/sandbox/apps/sandbox/fields.js +11 -12
- package/sandbox/server.js +5 -0
- package/transpiler/lib/write-files.js +1 -2
- package/utilities/helpers/index.js +16 -1
- package/wizard/index.js +1 -0
- package/.nyc_output/65af88d9-aebe-4d1b-a21d-6fbf7f2bbda4.json +0 -1
- package/.nyc_output/processinfo/65af88d9-aebe-4d1b-a21d-6fbf7f2bbda4.json +0 -1
@@ -8,7 +8,7 @@ module.exports = {
|
|
8
8
|
'landing-page-radio': {
|
9
9
|
mixin: 'radio-group',
|
10
10
|
validate: ['required'],
|
11
|
-
|
11
|
+
isPageHeading: true,
|
12
12
|
// Design system says to avoid in-line unless it's two options,
|
13
13
|
// so just added as an example below but by default it isn't
|
14
14
|
className: ['govuk-radios--inline'],
|
@@ -16,12 +16,12 @@ module.exports = {
|
|
16
16
|
},
|
17
17
|
name: {
|
18
18
|
validate: ['required', 'notUrl', { type: 'maxlength', arguments: 200 }],
|
19
|
+
// need to remove this for the heading to go
|
19
20
|
labelClassName: ['govuk-label--l'],
|
20
|
-
|
21
|
+
isPageHeading: 'true'
|
21
22
|
},
|
22
23
|
'dateOfBirth': dateComponent('dateOfBirth', {
|
23
|
-
|
24
|
-
controlType: 'date-input',
|
24
|
+
isPageHeading: 'true',
|
25
25
|
validate: [
|
26
26
|
'required',
|
27
27
|
'date',
|
@@ -29,28 +29,24 @@ module.exports = {
|
|
29
29
|
]
|
30
30
|
}),
|
31
31
|
building: {
|
32
|
-
noHeading: 'true',
|
33
32
|
validate: ['required', 'notUrl', { type: 'maxlength', arguments: 100 }]
|
34
33
|
},
|
35
34
|
street: {
|
36
|
-
noHeading: 'true',
|
37
35
|
validate: ['notUrl', { type: 'maxlength', arguments: 50 }],
|
38
36
|
labelClassName: 'visuallyhidden'
|
39
37
|
},
|
40
38
|
townOrCity: {
|
41
|
-
noHeading: 'true',
|
42
39
|
validate: ['required', 'notUrl',
|
43
40
|
{ type: 'regex', arguments: /^([^0-9]*)$/ },
|
44
41
|
{ type: 'maxlength', arguments: 100 }
|
45
42
|
]
|
46
43
|
},
|
47
44
|
postcode: {
|
48
|
-
noHeading: 'true',
|
49
45
|
validate: ['required', 'postcode'],
|
50
46
|
formatter: ['removespaces', 'uppercase']
|
51
47
|
},
|
52
48
|
incomeTypes: {
|
53
|
-
|
49
|
+
isPageHeading: 'true',
|
54
50
|
mixin: 'checkbox-group',
|
55
51
|
labelClassName: 'visuallyhidden',
|
56
52
|
validate: ['required'],
|
@@ -63,7 +59,7 @@ module.exports = {
|
|
63
59
|
]
|
64
60
|
},
|
65
61
|
countryOfHearing: {
|
66
|
-
|
62
|
+
isPageHeading: 'true',
|
67
63
|
mixin: 'radio-group',
|
68
64
|
validate: ['required'],
|
69
65
|
options: [
|
@@ -73,7 +69,7 @@ module.exports = {
|
|
73
69
|
]
|
74
70
|
},
|
75
71
|
email: {
|
76
|
-
|
72
|
+
isPageHeading: 'true',
|
77
73
|
labelClassName: ['govuk-label--l'],
|
78
74
|
validate: ['required', 'email']
|
79
75
|
},
|
@@ -86,6 +82,7 @@ module.exports = {
|
|
86
82
|
},
|
87
83
|
countrySelect: {
|
88
84
|
mixin: 'select',
|
85
|
+
isPageHeading: 'true',
|
89
86
|
className: ['typeahead'],
|
90
87
|
options:[''].concat(require('homeoffice-countries').allCountries),
|
91
88
|
legend: {
|
@@ -97,12 +94,13 @@ module.exports = {
|
|
97
94
|
mixin: 'textarea',
|
98
95
|
// we want to ignore default formatters as we want
|
99
96
|
// to preserve white space
|
97
|
+
isPageHeading: 'true',
|
100
98
|
'ignore-defaults': true,
|
101
99
|
// apply the other default formatters
|
102
100
|
formatter: ['trim', 'hyphens'],
|
103
101
|
labelClassName: ['govuk-label--l'],
|
104
102
|
// attributes here are passed to the field element
|
105
|
-
validate: ['required', { type: 'maxlength', arguments:
|
103
|
+
validate: ['required', { type: 'maxlength', arguments: 10 }],
|
106
104
|
attributes: [{
|
107
105
|
attribute: 'rows',
|
108
106
|
value: 8
|
@@ -110,6 +108,7 @@ module.exports = {
|
|
110
108
|
},
|
111
109
|
appealStages: {
|
112
110
|
mixin: 'select',
|
111
|
+
isPageHeading: 'true',
|
113
112
|
validate: ['required'],
|
114
113
|
options: [{
|
115
114
|
value: '',
|
package/sandbox/server.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
const fs = require('fs');
|
4
4
|
const path = require('path');
|
5
|
-
const mkdir = require('mkdirp').sync;
|
6
5
|
const rm = require('rimraf').sync;
|
7
6
|
|
8
7
|
const debug = require('debug')('hof:transpiler');
|
@@ -16,7 +15,7 @@ module.exports = (dir, data) => {
|
|
16
15
|
const outputDir = path.resolve(dir, '..', lang);
|
17
16
|
rm(outputDir);
|
18
17
|
debug(`Emptied directory ${outputDir}`);
|
19
|
-
|
18
|
+
fs.mkdirSync(outputDir);
|
20
19
|
debug(`Made directory ${outputDir}`);
|
21
20
|
Object.keys(data[lang]).forEach(namespace => {
|
22
21
|
fs.writeFileSync(path.resolve(outputDir, `${namespace}.json`), JSON.stringify(data[lang][namespace], null, ' '));
|
@@ -94,7 +94,7 @@ module.exports = class Helpers {
|
|
94
94
|
/**
|
95
95
|
* utility function which returns undefined on
|
96
96
|
* failed translations instead of returning the key
|
97
|
-
* @param {Function} translate - the translate
|
97
|
+
* @param {Function} translate - the translate function
|
98
98
|
* @param {String} key - the key to translate
|
99
99
|
* @returns {String|undefined} the string result if successful, undefined if not
|
100
100
|
*/
|
@@ -131,4 +131,19 @@ module.exports = class Helpers {
|
|
131
131
|
`pages.${key}.header`
|
132
132
|
]) || key;
|
133
133
|
}
|
134
|
+
/**
|
135
|
+
* utility function which returns true or false on
|
136
|
+
* forks depending on whether a value exists on the page
|
137
|
+
* @param {Object} req - an http request object
|
138
|
+
* @param {Object} res - an http response object
|
139
|
+
* @param {Function|Object} condition - a field condition that is either a function or object
|
140
|
+
* @returns {Boolean} the boolean result of whether a field value is set on the page or session for a fork
|
141
|
+
*/
|
142
|
+
static isFieldValueInPageOrSessionValid(req, res, condition) {
|
143
|
+
return _.isFunction(condition) ?
|
144
|
+
condition(req, res) :
|
145
|
+
condition.value === (req.form.values[condition.field] ||
|
146
|
+
(!Object.keys(req.form.values).includes(condition.field) &&
|
147
|
+
_.get(req, `form.historicalValues[${condition.field}]`)));
|
148
|
+
}
|
134
149
|
};
|
package/wizard/index.js
CHANGED
@@ -69,6 +69,7 @@ const Wizard = (steps, fields, setts) => {
|
|
69
69
|
options.confirmStep = settings.confirmStep;
|
70
70
|
options.clearSession = options.clearSession || false;
|
71
71
|
options.fieldsConfig = _.cloneDeep(fields);
|
72
|
+
options.sanitiseInputs = settings.sanitiseInputs;
|
72
73
|
|
73
74
|
options.defaultFormatters = [].concat(settings.formatters);
|
74
75
|
|