hof 22.9.0-beta.v1 → 22.9.0-beta.v2
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/package/.eslintignore +0 -1
- package/package/CHANGELOG.md +0 -232
- package/package/LICENSE +0 -21
- package/package/README.md +0 -1887
- package/package/bin/hof-build +0 -10
- package/package/bin/hof-transpiler +0 -12
- package/package/build/helpers/importer.js +0 -29
- package/package/build/helpers/local.js +0 -35
- package/package/build/helpers/resolver/import.js +0 -32
- package/package/build/helpers/resolver/nearest-package-root.js +0 -33
- package/package/build/helpers/resolver/package.js +0 -29
- package/package/build/helpers/resolver.js +0 -16
- package/package/build/index.js +0 -49
- package/package/build/lib/env.js +0 -36
- package/package/build/lib/mkdir.js +0 -9
- package/package/build/lib/run.js +0 -17
- package/package/build/lib/spawn.js +0 -18
- package/package/build/tasks/browserify/compress.js +0 -15
- package/package/build/tasks/browserify/index.js +0 -48
- package/package/build/tasks/build/index.js +0 -6
- package/package/build/tasks/images/index.js +0 -27
- package/package/build/tasks/index.js +0 -8
- package/package/build/tasks/sass/index.js +0 -67
- package/package/build/tasks/translate/index.js +0 -20
- package/package/build/tasks/watch/index.js +0 -161
- package/package/components/address-lookup/default-model.js +0 -76
- package/package/components/address-lookup/defaults.js +0 -25
- package/package/components/address-lookup/index.js +0 -251
- package/package/components/address-lookup/templates/address-lookup.html +0 -14
- package/package/components/address-lookup/templates/address.html +0 -22
- package/package/components/address-lookup/templates/postcode.html +0 -9
- package/package/components/clear-session/Readme.md +0 -46
- package/package/components/clear-session/index.js +0 -26
- package/package/components/combine-and-loop-fields/Readme.md +0 -42
- package/package/components/combine-and-loop-fields/index.js +0 -156
- package/package/components/date/fields.js +0 -16
- package/package/components/date/index.js +0 -172
- package/package/components/date/templates/date.html +0 -20
- package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
- package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
- package/package/components/emailer/assets/images/spacer.gif +0 -0
- package/package/components/emailer/email-service.js +0 -51
- package/package/components/emailer/emailer.js +0 -53
- package/package/components/emailer/index.js +0 -74
- package/package/components/emailer/transports/debug.js +0 -74
- package/package/components/emailer/transports/index.js +0 -8
- package/package/components/emailer/transports/ses.js +0 -36
- package/package/components/emailer/transports/smtp.js +0 -26
- package/package/components/emailer/transports/stub.js +0 -5
- package/package/components/emailer/views/layout.html +0 -63
- package/package/components/homeoffice-countries/index.js +0 -22
- package/package/components/index.js +0 -13
- package/package/components/notify/index.js +0 -62
- package/package/components/notify/notify.js +0 -51
- package/package/components/session-timeout-warning/index.js +0 -67
- package/package/components/summary/index.js +0 -237
- package/package/config/builder-defaults.js +0 -45
- package/package/config/component-defaults.js +0 -13
- package/package/config/hof-defaults.js +0 -65
- package/package/config/rate-limits.js +0 -20
- package/package/config/sanitisation-rules.js +0 -32
- package/package/controller/base-controller.js +0 -296
- package/package/controller/behaviour-hooks.js +0 -51
- package/package/controller/behaviour-session.js +0 -64
- package/package/controller/controller.js +0 -258
- package/package/controller/deprecate-error.js +0 -10
- package/package/controller/formatting/formatters.js +0 -70
- package/package/controller/formatting/index.js +0 -32
- package/package/controller/index.js +0 -17
- package/package/controller/validation/email.js +0 -30
- package/package/controller/validation/index.js +0 -101
- package/package/controller/validation/validators.js +0 -181
- package/package/controller/validation-error.js +0 -14
- package/package/frontend/govuk-template/build/config.js +0 -24
- package/package/frontend/govuk-template/build/govuk_template.html +0 -102
- package/package/frontend/govuk-template/build/index.js +0 -23
- package/package/frontend/govuk-template/govuk_template_generated.html +0 -102
- package/package/frontend/govuk-template/index.js +0 -29
- package/package/frontend/index.js +0 -9
- package/package/frontend/template-mixins/mixins/helpers.js +0 -103
- package/package/frontend/template-mixins/mixins/index.js +0 -37
- package/package/frontend/template-mixins/mixins/render.js +0 -12
- package/package/frontend/template-mixins/mixins/template-mixins.js +0 -520
- package/package/frontend/template-mixins/partials/forms/checkbox-group.html +0 -47
- package/package/frontend/template-mixins/partials/forms/checkbox.html +0 -16
- package/package/frontend/template-mixins/partials/forms/input-submit.html +0 -1
- package/package/frontend/template-mixins/partials/forms/input-text-date.html +0 -37
- package/package/frontend/template-mixins/partials/forms/input-text-group.html +0 -45
- package/package/frontend/template-mixins/partials/forms/option-group.html +0 -43
- package/package/frontend/template-mixins/partials/forms/select.html +0 -17
- package/package/frontend/template-mixins/partials/forms/textarea-group.html +0 -37
- package/package/frontend/template-mixins/partials/mixins/panel.html +0 -4
- package/package/frontend/template-partials/index.js +0 -9
- package/package/frontend/template-partials/translations/index.js +0 -26
- package/package/frontend/template-partials/translations/src/cy/base.json +0 -4
- package/package/frontend/template-partials/translations/src/cy/buttons.json +0 -6
- package/package/frontend/template-partials/translations/src/cy/cookies.json +0 -104
- package/package/frontend/template-partials/translations/src/cy/errorlist.json +0 -6
- package/package/frontend/template-partials/translations/src/cy/errors.json +0 -18
- package/package/frontend/template-partials/translations/src/cy/terms.json +0 -28
- package/package/frontend/template-partials/translations/src/en/accessibility.json +0 -43
- package/package/frontend/template-partials/translations/src/en/base.json +0 -5
- package/package/frontend/template-partials/translations/src/en/buttons.json +0 -10
- package/package/frontend/template-partials/translations/src/en/cookies.json +0 -116
- package/package/frontend/template-partials/translations/src/en/errorlist.json +0 -7
- package/package/frontend/template-partials/translations/src/en/errors.json +0 -35
- package/package/frontend/template-partials/translations/src/en/exit.json +0 -5
- package/package/frontend/template-partials/translations/src/en/fields.json +0 -5
- package/package/frontend/template-partials/translations/src/en/journey.json +0 -6
- package/package/frontend/template-partials/translations/src/en/save-and-exit.json +0 -4
- package/package/frontend/template-partials/translations/src/en/terms.json +0 -28
- package/package/frontend/template-partials/views/404.html +0 -9
- package/package/frontend/template-partials/views/accessibility.html +0 -55
- package/package/frontend/template-partials/views/confirm.html +0 -8
- package/package/frontend/template-partials/views/confirmation.html +0 -19
- package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
- package/package/frontend/template-partials/views/cookie-error.html +0 -1
- package/package/frontend/template-partials/views/cookies.html +0 -84
- package/package/frontend/template-partials/views/email/data-row.html +0 -4
- package/package/frontend/template-partials/views/email/formatted.html +0 -12
- package/package/frontend/template-partials/views/email/layout.html +0 -63
- package/package/frontend/template-partials/views/email/raw.html +0 -11
- package/package/frontend/template-partials/views/email/section-row.html +0 -3
- package/package/frontend/template-partials/views/error.html +0 -20
- package/package/frontend/template-partials/views/exit.html +0 -9
- package/package/frontend/template-partials/views/feedback-submitted.html +0 -11
- package/package/frontend/template-partials/views/layout.html +0 -55
- package/package/frontend/template-partials/views/partials/analytics-table.html +0 -25
- package/package/frontend/template-partials/views/partials/back.html +0 -5
- package/package/frontend/template-partials/views/partials/bullet-list.html +0 -7
- package/package/frontend/template-partials/views/partials/confirmation-alert.html +0 -6
- package/package/frontend/template-partials/views/partials/continue.html +0 -5
- package/package/frontend/template-partials/views/partials/cookie-banner.html +0 -29
- package/package/frontend/template-partials/views/partials/cookie-notification.html +0 -4
- package/package/frontend/template-partials/views/partials/cookie-settings-button.html +0 -1
- package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +0 -8
- package/package/frontend/template-partials/views/partials/details-summary.html +0 -8
- package/package/frontend/template-partials/views/partials/external-link.html +0 -1
- package/package/frontend/template-partials/views/partials/form.html +0 -10
- package/package/frontend/template-partials/views/partials/gatag.html +0 -60
- package/package/frontend/template-partials/views/partials/head.html +0 -31
- package/package/frontend/template-partials/views/partials/heading.html +0 -11
- package/package/frontend/template-partials/views/partials/items-table.html +0 -32
- package/package/frontend/template-partials/views/partials/maincontent-left.html +0 -10
- package/package/frontend/template-partials/views/partials/navigation.html +0 -8
- package/package/frontend/template-partials/views/partials/page.html +0 -23
- package/package/frontend/template-partials/views/partials/panel-indent.html +0 -3
- package/package/frontend/template-partials/views/partials/session-cookies-table.html +0 -28
- package/package/frontend/template-partials/views/partials/session-timeout-warning.html +0 -38
- package/package/frontend/template-partials/views/partials/summary-table-row.html +0 -14
- package/package/frontend/template-partials/views/partials/summary-table.html +0 -8
- package/package/frontend/template-partials/views/partials/table.html +0 -18
- package/package/frontend/template-partials/views/partials/validation-list.html +0 -3
- package/package/frontend/template-partials/views/partials/validation-summary.html +0 -25
- package/package/frontend/template-partials/views/partials/warn.html +0 -7
- package/package/frontend/template-partials/views/rate-limit-error.html +0 -10
- package/package/frontend/template-partials/views/save-and-exit.html +0 -17
- package/package/frontend/template-partials/views/service-unavailable.html +0 -13
- package/package/frontend/template-partials/views/session-timeout.html +0 -7
- package/package/frontend/template-partials/views/step.html +0 -14
- package/package/frontend/template-partials/views/terms.html +0 -26
- package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +0 -145
- package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +0 -121
- package/package/frontend/themes/gov-uk/client-js/index.js +0 -27
- package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +0 -348
- package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +0 -19
- package/package/frontend/themes/gov-uk/index.js +0 -9
- package/package/frontend/themes/gov-uk/styles/_base.scss +0 -17
- package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +0 -155
- package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -111
- package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +0 -33
- package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +0 -23
- package/package/frontend/themes/gov-uk/styles/_helpers.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/_layout.scss +0 -125
- package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +0 -27
- package/package/frontend/themes/gov-uk/styles/_pdf.scss +0 -42
- package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +0 -121
- package/package/frontend/themes/gov-uk/styles/_typography.scss +0 -27
- package/package/frontend/themes/gov-uk/styles/_variables.scss +0 -11
- package/package/frontend/themes/gov-uk/styles/govuk.scss +0 -43
- package/package/frontend/themes/gov-uk/styles/mixins.scss +0 -16
- package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +0 -73
- package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +0 -8
- package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +0 -20
- package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +0 -17
- package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +0 -51
- package/package/frontend/themes/index.js +0 -5
- package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
- package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
- package/package/frontend/toolkit/assets/javascript/character-count.js +0 -99
- package/package/frontend/toolkit/assets/javascript/form-focus.js +0 -101
- package/package/frontend/toolkit/assets/javascript/helpers.js +0 -177
- package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +0 -72
- package/package/frontend/toolkit/assets/javascript/validation.js +0 -71
- package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +0 -189
- package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +0 -39
- package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +0 -6
- package/package/frontend/toolkit/assets/stylesheets/_base.scss +0 -17
- package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/_layout.scss +0 -118
- package/package/frontend/toolkit/assets/stylesheets/_typography.scss +0 -27
- package/package/frontend/toolkit/assets/stylesheets/_variables.scss +0 -11
- package/package/frontend/toolkit/assets/stylesheets/app.scss +0 -30
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +0 -47
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +0 -38
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +0 -175
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +0 -167
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +0 -39
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +0 -67
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +0 -40
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +0 -29
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +0 -33
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +0 -33
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +0 -63
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +0 -39
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +0 -63
- package/package/frontend/toolkit/assets/stylesheets/mixins.scss +0 -16
- package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +0 -73
- package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +0 -20
- package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +0 -17
- package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +0 -51
- package/package/frontend/toolkit/index.js +0 -10
- package/package/index.js +0 -351
- package/package/lib/deindex.js +0 -18
- package/package/lib/encryption.js +0 -23
- package/package/lib/ga-tag.js +0 -89
- package/package/lib/health.js +0 -26
- package/package/lib/helpers.js +0 -66
- package/package/lib/logger.js +0 -65
- package/package/lib/markdown.js +0 -46
- package/package/lib/router.js +0 -111
- package/package/lib/serve-static.js +0 -12
- package/package/lib/sessions.js +0 -82
- package/package/lib/settings.js +0 -74
- package/package/lib/which.js +0 -28
- package/package/middleware/cookies.js +0 -43
- package/package/middleware/deep-translate.js +0 -32
- package/package/middleware/errors.js +0 -119
- package/package/middleware/index.js +0 -10
- package/package/middleware/not-found.js +0 -38
- package/package/middleware/rate-limiter.js +0 -98
- package/package/middleware/service-unavailable.js +0 -64
- package/package/model/apis/axios-settings.js +0 -21
- package/package/model/apis/html-to-pdf-converter.js +0 -35
- package/package/model/apis/index.js +0 -5
- package/package/model/index.js +0 -348
- package/package/package.json +0 -147
- package/package/sandbox/README.md +0 -66
- package/package/sandbox/apps/sandbox/behaviours/clear-session.js +0 -8
- package/package/sandbox/apps/sandbox/behaviours/country-select.js +0 -10
- package/package/sandbox/apps/sandbox/behaviours/international-number.js +0 -22
- package/package/sandbox/apps/sandbox/fields.js +0 -128
- package/package/sandbox/apps/sandbox/index.js +0 -99
- package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +0 -189
- package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +0 -43
- package/package/sandbox/apps/sandbox/translations/src/en/errors.json +0 -5
- package/package/sandbox/apps/sandbox/translations/src/en/exit.json +0 -4
- package/package/sandbox/apps/sandbox/translations/src/en/fields.json +0 -101
- package/package/sandbox/apps/sandbox/translations/src/en/journey.json +0 -7
- package/package/sandbox/apps/sandbox/translations/src/en/pages.json +0 -72
- package/package/sandbox/apps/sandbox/translations/src/en/validation.json +0 -54
- package/package/sandbox/apps/sandbox/views/form-guidance-link.html +0 -8
- package/package/sandbox/apps/sandbox/views/save-and-exit.html +0 -19
- package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
- package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
- package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
- package/package/sandbox/assets/js/index.js +0 -70
- package/package/sandbox/assets/scss/app.scss +0 -27
- package/package/sandbox/codecept.conf.js +0 -15
- package/package/sandbox/config.js +0 -17
- package/package/sandbox/package.json +0 -26
- package/package/sandbox/server.js +0 -23
- package/package/sandbox/yarn.lock +0 -262
- package/package/transpiler/index.js +0 -2
- package/package/transpiler/lib/aggregate.js +0 -32
- package/package/transpiler/lib/build.js +0 -15
- package/package/transpiler/lib/compile.js +0 -12
- package/package/transpiler/lib/expand-dirs.js +0 -14
- package/package/transpiler/lib/write-files.js +0 -24
- package/package/utilities/autofill/index.js +0 -189
- package/package/utilities/autofill/inputs.js +0 -60
- package/package/utilities/countries.js +0 -12
- package/package/utilities/helpers/index.js +0 -189
- package/package/utilities/index.js +0 -9
- package/package/utilities/reqres/index.js +0 -18
- package/package/utilities/test-data/data/domain.json +0 -7
- package/package/utilities/test-data/data/firstname.json +0 -16
- package/package/utilities/test-data/data/lastname.json +0 -10
- package/package/utilities/test-data/data/postcode.json +0 -12
- package/package/utilities/test-data/data/streetname.json +0 -8
- package/package/utilities/test-data/data/streetsuffix.json +0 -7
- package/package/utilities/test-data/data/town.json +0 -9
- package/package/utilities/test-data/index.js +0 -67
- package/package/wizard/behaviours/complete.js +0 -20
- package/package/wizard/behaviours/index.js +0 -5
- package/package/wizard/index.js +0 -124
- package/package/wizard/middleware/back-links.js +0 -68
- package/package/wizard/middleware/check-complete.js +0 -13
- package/package/wizard/middleware/check-progress.js +0 -139
- package/package/wizard/middleware/check-session.js +0 -17
- package/package/wizard/middleware/csrf.js +0 -47
- package/package/wizard/middleware/session-model.js +0 -11
- package/package/wizard/middleware/session.js +0 -9
- package/package/wizard/model.js +0 -29
- package/package/wizard/util/constants.js +0 -5
- package/package/wizard/util/helpers.js +0 -19
@@ -1,161 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console */
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
const build = require('../build');
|
5
|
-
const chokidar = require('chokidar');
|
6
|
-
const throttle = require('lodash').throttle;
|
7
|
-
const uniq = require('lodash').uniq;
|
8
|
-
const cp = require('child_process');
|
9
|
-
const path = require('path');
|
10
|
-
const match = require('minimatch');
|
11
|
-
const chalk = require('chalk');
|
12
|
-
const extname = require('path').extname;
|
13
|
-
|
14
|
-
const tasks = require('../');
|
15
|
-
|
16
|
-
const run = require('../../lib/run');
|
17
|
-
const env = require('../../lib/env');
|
18
|
-
|
19
|
-
module.exports = config => {
|
20
|
-
let toBuild = [];
|
21
|
-
let server;
|
22
|
-
|
23
|
-
const matchers = Object.keys(tasks).reduce((map, key) => {
|
24
|
-
if (!config[key]) {
|
25
|
-
return map;
|
26
|
-
}
|
27
|
-
const matcher = config[key].match || config[key].src;
|
28
|
-
if (matcher) {
|
29
|
-
map[key] = matcher;
|
30
|
-
}
|
31
|
-
return map;
|
32
|
-
}, {});
|
33
|
-
|
34
|
-
function triggersTask(file) {
|
35
|
-
return Object.keys(matchers).filter(key => match(file, matchers[key]));
|
36
|
-
}
|
37
|
-
|
38
|
-
function restart() {
|
39
|
-
if (server) {
|
40
|
-
server.kill();
|
41
|
-
server.removeAllListeners();
|
42
|
-
console.log(chalk.green('Restarting due to changes'));
|
43
|
-
}
|
44
|
-
const args = config.server.cmd.split(' ');
|
45
|
-
const cmd = args.shift();
|
46
|
-
server = cp.spawn(cmd, args, { stdio: ['ignore', 'inherit', 'inherit'] });
|
47
|
-
|
48
|
-
server.on('exit', code => {
|
49
|
-
if (code) {
|
50
|
-
console.log(chalk.red('Server exited with non-zero exit code. Awaiting code changes.'));
|
51
|
-
}
|
52
|
-
});
|
53
|
-
}
|
54
|
-
|
55
|
-
function detectRestart(jobs, files) {
|
56
|
-
const restartingJobs = jobs.filter(job => config[job].restart !== false);
|
57
|
-
const restartingFiles = files.filter(file => config.server.extensions.indexOf(extname(file)) > -1);
|
58
|
-
return restartingJobs.length || restartingFiles.length;
|
59
|
-
}
|
60
|
-
|
61
|
-
function rebuild() {
|
62
|
-
let jobs = [];
|
63
|
-
toBuild.forEach(file => {
|
64
|
-
if (config.verbose) {
|
65
|
-
console.log(`${chalk.yellow('Changed')}: ${file}`);
|
66
|
-
}
|
67
|
-
jobs = jobs.concat(triggersTask(file));
|
68
|
-
});
|
69
|
-
jobs = uniq(jobs);
|
70
|
-
|
71
|
-
if (toBuild.indexOf('hof.settings.json') > -1) {
|
72
|
-
console.log(chalk.red('Build configuration modified. Manual restart required.'));
|
73
|
-
server.kill();
|
74
|
-
// eslint-disable-next-line no-process-exit
|
75
|
-
process.exit();
|
76
|
-
}
|
77
|
-
|
78
|
-
jobs.forEach(job => {
|
79
|
-
console.log(`Executing build task: ${chalk.green(job)}`);
|
80
|
-
});
|
81
|
-
|
82
|
-
const shouldRestart = detectRestart(jobs, toBuild);
|
83
|
-
toBuild = [];
|
84
|
-
return run(jobs.map(task => tasks[task]), config)
|
85
|
-
.then(() => {
|
86
|
-
if (shouldRestart) {
|
87
|
-
restart();
|
88
|
-
}
|
89
|
-
});
|
90
|
-
}
|
91
|
-
|
92
|
-
function stdin() {
|
93
|
-
process.stdin.resume();
|
94
|
-
process.stdin.setEncoding('utf8');
|
95
|
-
process.stdin.on('data', data => {
|
96
|
-
const dataType = (data + '').trim().toLowerCase();
|
97
|
-
if (dataType === config.watch.restart) {
|
98
|
-
restart();
|
99
|
-
}
|
100
|
-
});
|
101
|
-
}
|
102
|
-
|
103
|
-
function watch() {
|
104
|
-
return new Promise(resolve => {
|
105
|
-
const ignored = [].concat(config.watch.ignore);
|
106
|
-
let watchLocation = '.';
|
107
|
-
|
108
|
-
if (!config.watchNodeModules) {
|
109
|
-
console.log('Ignoring node_modules directory. To watch node_modules run with --watch-node-modules flag');
|
110
|
-
ignored.push('node_modules');
|
111
|
-
}
|
112
|
-
if (!config.watchDotFiles) {
|
113
|
-
console.log('Ignoring dotfiles. To watch dotfiles run with --watch-dotfiles flag');
|
114
|
-
ignored.push(/(^|[\/\\])\../);
|
115
|
-
}
|
116
|
-
|
117
|
-
if (process.env.HOF_SANDBOX === 'true') {
|
118
|
-
const rootDir = require('path').resolve(__dirname, '../../../');
|
119
|
-
ignored.push(`${rootDir}/frontend/govuk-template/govuk_template_generated.html`);
|
120
|
-
watchLocation = [rootDir, '.'];
|
121
|
-
}
|
122
|
-
|
123
|
-
const watcher = chokidar.watch(watchLocation, { ignored });
|
124
|
-
|
125
|
-
watcher.on('ready', () => {
|
126
|
-
const watched = watcher.getWatched();
|
127
|
-
console.log(`Watching ${Object.keys(watched).length} files for changes`);
|
128
|
-
|
129
|
-
const throttledRebuild = throttle(rebuild, 1000);
|
130
|
-
watcher.on('all', (event, file) => {
|
131
|
-
toBuild.push(file);
|
132
|
-
throttledRebuild();
|
133
|
-
});
|
134
|
-
stdin();
|
135
|
-
resolve();
|
136
|
-
});
|
137
|
-
});
|
138
|
-
}
|
139
|
-
|
140
|
-
function loadenv() {
|
141
|
-
let envfile = '.env';
|
142
|
-
if (typeof config.env === 'string') {
|
143
|
-
envfile = config.env;
|
144
|
-
}
|
145
|
-
envfile = path.resolve(process.cwd(), envfile);
|
146
|
-
return env(envfile, !!config.env)
|
147
|
-
.then(dotenv => {
|
148
|
-
Object.keys(dotenv).forEach(key => {
|
149
|
-
if (process.env[key] && config.verbose) {
|
150
|
-
console.log(` Overwriting environment variable ${key} with local value`);
|
151
|
-
}
|
152
|
-
process.env[key] = dotenv[key];
|
153
|
-
});
|
154
|
-
});
|
155
|
-
}
|
156
|
-
|
157
|
-
return build(config)
|
158
|
-
.then(() => watch())
|
159
|
-
.then(() => loadenv())
|
160
|
-
.then(() => restart());
|
161
|
-
};
|
@@ -1,76 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const _ = require('lodash');
|
4
|
-
const Model = require('../../model');
|
5
|
-
const defaults = require('./defaults');
|
6
|
-
|
7
|
-
const IS_VALIDATING = 'IS_VALIDATING';
|
8
|
-
|
9
|
-
module.exports = class PostcodesModel extends Model {
|
10
|
-
constructor(options) {
|
11
|
-
super(options);
|
12
|
-
this.options = _.merge({}, defaults.POSTCODE_API, options);
|
13
|
-
}
|
14
|
-
|
15
|
-
url() {
|
16
|
-
const validating = this.get(IS_VALIDATING);
|
17
|
-
const options = {
|
18
|
-
url: validating ?
|
19
|
-
`${this.options.hostname}/${this.options.paths.validate}/${this.get('postcode')}` :
|
20
|
-
`${this.options.hostname}/${this.options.paths.lookup}`
|
21
|
-
};
|
22
|
-
if (!validating) {
|
23
|
-
options.query = {
|
24
|
-
postcode: this.get('postcode')
|
25
|
-
};
|
26
|
-
}
|
27
|
-
return super.url(options);
|
28
|
-
}
|
29
|
-
|
30
|
-
requestConfig(options) {
|
31
|
-
return _.merge(super.requestConfig(options), {
|
32
|
-
timeout: 5000,
|
33
|
-
headers: {
|
34
|
-
Authorization: this.options.authorization
|
35
|
-
}
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
validate() {
|
40
|
-
// eslint-disable-next-line consistent-return
|
41
|
-
return new Promise((resolve, reject) => {
|
42
|
-
this.set(IS_VALIDATING, true);
|
43
|
-
let allowedCountries = this.options.validate && this.options.validate.allowedCountries;
|
44
|
-
if (!allowedCountries) {
|
45
|
-
return resolve();
|
46
|
-
}
|
47
|
-
|
48
|
-
const getError = () => {
|
49
|
-
const err = new Error('Validation Error');
|
50
|
-
err.status = 418;
|
51
|
-
err.type = 'country';
|
52
|
-
return err;
|
53
|
-
};
|
54
|
-
|
55
|
-
if (this.get('postcode').toUpperCase().startsWith('BT')) {
|
56
|
-
return reject(getError());
|
57
|
-
}
|
58
|
-
|
59
|
-
this.fetch()
|
60
|
-
.then(data => {
|
61
|
-
this.set(IS_VALIDATING, false);
|
62
|
-
if (data && data.country && data.country.name) {
|
63
|
-
allowedCountries = _.castArray(allowedCountries).map(c => c.toLowerCase());
|
64
|
-
if (allowedCountries.indexOf(data.country.name.toLowerCase()) === -1) {
|
65
|
-
return reject(getError());
|
66
|
-
}
|
67
|
-
}
|
68
|
-
return resolve();
|
69
|
-
})
|
70
|
-
.catch(err => {
|
71
|
-
this.set(IS_VALIDATING, false);
|
72
|
-
return reject(err);
|
73
|
-
});
|
74
|
-
});
|
75
|
-
}
|
76
|
-
};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/* eslint max-len: 0, no-process-env: 0 */
|
2
|
-
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
module.exports = {
|
6
|
-
CANT_FIND: 'I can\'t find the address in the list',
|
7
|
-
CHANGE: 'Change',
|
8
|
-
POSTCODE_LABEL: 'Postcode',
|
9
|
-
SELECT_LABEL: 'Select the address',
|
10
|
-
ADDRESS_LABEL: 'Address',
|
11
|
-
POSTCODE_ENTERED: 'Postcode you entered: ',
|
12
|
-
POSTCODE_ERROR: {
|
13
|
-
'not-found': 'Sorry – we couldn’t find any addresses for that postcode, enter your address manually',
|
14
|
-
'cant-connect': 'Sorry – we couldn’t connect to the postcode lookup service at this time, enter your address manually'
|
15
|
-
},
|
16
|
-
ENTER_MANUALLY: 'Enter address manually',
|
17
|
-
POSTCODE_API: {
|
18
|
-
hostname: 'https://postcodeinfo.service.justice.gov.uk',
|
19
|
-
authorization: process.env.POSTCODE_AUTH || '',
|
20
|
-
paths: {
|
21
|
-
lookup: 'addresses',
|
22
|
-
validate: 'postcodes'
|
23
|
-
}
|
24
|
-
}
|
25
|
-
};
|
@@ -1,251 +0,0 @@
|
|
1
|
-
/* eslint-disable func-names */
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
const path = require('path');
|
5
|
-
const querystring = require('querystring');
|
6
|
-
const _ = require('lodash');
|
7
|
-
|
8
|
-
const DefaultModel = require('./default-model');
|
9
|
-
const defaults = require('./defaults');
|
10
|
-
|
11
|
-
const conditionalTranslate = (key, t) => {
|
12
|
-
let result = t(key);
|
13
|
-
if (result === key) {
|
14
|
-
result = null;
|
15
|
-
}
|
16
|
-
return result;
|
17
|
-
};
|
18
|
-
|
19
|
-
const getFields = (key, t, requiredValidate) => ({
|
20
|
-
|
21
|
-
[`${key}-postcode`]: {
|
22
|
-
label: conditionalTranslate(`fields.${key}-postcode.label`, t) || defaults.POSTCODE_LABEL,
|
23
|
-
mixin: 'input-text-code',
|
24
|
-
validate: requiredValidate ? ['required', 'postcode'] : ['postcode'],
|
25
|
-
formatter: 'uppercase'
|
26
|
-
},
|
27
|
-
[`${key}-select`]: {
|
28
|
-
label: conditionalTranslate(`fields.${key}-select.label`, t) || defaults.SELECT_LABEL,
|
29
|
-
mixin: 'select',
|
30
|
-
validate: [function required(val) {
|
31
|
-
return val !== '-1';
|
32
|
-
}]
|
33
|
-
},
|
34
|
-
[key]: {
|
35
|
-
label: conditionalTranslate(`fields.${key}.label`, t) || defaults.ADDRESS_LABEL,
|
36
|
-
mixin: 'textarea',
|
37
|
-
validate: 'required',
|
38
|
-
'ignore-defaults': true,
|
39
|
-
formatter: ['trim', 'hyphens'],
|
40
|
-
attributes: [{
|
41
|
-
attribute: 'rows',
|
42
|
-
value: 6
|
43
|
-
}]
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
|
-
const getConfig = key => ({
|
48
|
-
postcode: {
|
49
|
-
fields: [`${key}-postcode`],
|
50
|
-
template: 'postcode'
|
51
|
-
},
|
52
|
-
lookup: {
|
53
|
-
fields: [`${key}-select`],
|
54
|
-
template: 'address-lookup'
|
55
|
-
},
|
56
|
-
address: {
|
57
|
-
fields: [key],
|
58
|
-
template: 'address'
|
59
|
-
},
|
60
|
-
manual: {
|
61
|
-
fields: [key],
|
62
|
-
template: 'address'
|
63
|
-
}
|
64
|
-
});
|
65
|
-
|
66
|
-
module.exports = config => {
|
67
|
-
const addressKey = config.addressKey;
|
68
|
-
const required = config.required;
|
69
|
-
if (!addressKey) {
|
70
|
-
throw new Error('addressKey must be provided');
|
71
|
-
}
|
72
|
-
|
73
|
-
const Model = config.Model || DefaultModel;
|
74
|
-
const apiSettings = config.apiSettings || {};
|
75
|
-
const validate = config.validate;
|
76
|
-
|
77
|
-
return superclass => class extends superclass {
|
78
|
-
configure(req, res, callback) {
|
79
|
-
this.model = new Model(_.merge({}, apiSettings, { validate }));
|
80
|
-
req.query.step = req.query.step || 'postcode';
|
81
|
-
const subSteps = getConfig(addressKey);
|
82
|
-
const step = subSteps[req.query.step];
|
83
|
-
_.merge(req.form.options, {
|
84
|
-
subSteps,
|
85
|
-
addressKey,
|
86
|
-
fields: _.pick(getFields(addressKey, req.translate, required), step.fields),
|
87
|
-
apiError: null
|
88
|
-
});
|
89
|
-
if (step.template) {
|
90
|
-
req.form.options.template = path.resolve(__dirname, `./templates/${step.template}.html`);
|
91
|
-
}
|
92
|
-
super.configure(req, res, callback);
|
93
|
-
}
|
94
|
-
|
95
|
-
getNextStep(req, res, callback) {
|
96
|
-
const step = super.getNextStep(req, res, callback);
|
97
|
-
|
98
|
-
if (req.query.step === 'postcode' && req.form.values[`${addressKey}-postcode`]) {
|
99
|
-
const nextSubStep = req.sessionModel.get(`${addressKey}-addresses`) ? 'lookup' : 'address';
|
100
|
-
const qs = querystring.stringify(_.merge({}, req.query, {
|
101
|
-
step: nextSubStep
|
102
|
-
}));
|
103
|
-
return `?${qs}`;
|
104
|
-
}
|
105
|
-
return step;
|
106
|
-
}
|
107
|
-
|
108
|
-
getValues(req, res, callback) {
|
109
|
-
if (req.query.step === 'manual') {
|
110
|
-
req.sessionModel.unset([
|
111
|
-
`${addressKey}-postcodeApiMeta`
|
112
|
-
]);
|
113
|
-
} else if (req.query.step === 'lookup') {
|
114
|
-
const addresses = req.sessionModel.get(`${addressKey}-addresses`);
|
115
|
-
const formattedlist = _.map(_.map(addresses, 'formatted_address'), ads => {
|
116
|
-
const address = ads.split('\n').join(', ');
|
117
|
-
return {
|
118
|
-
value: address,
|
119
|
-
label: address
|
120
|
-
};
|
121
|
-
});
|
122
|
-
|
123
|
-
const count = `${formattedlist.length} address${formattedlist.length > 1 ? 'es' : ''}`;
|
124
|
-
// eslint-disable-next-line max-len
|
125
|
-
req.form.options.fields[`${addressKey}-select`].options = [{value: '-1', label: count}].concat(formattedlist);
|
126
|
-
}
|
127
|
-
super.getValues(req, res, callback);
|
128
|
-
}
|
129
|
-
|
130
|
-
locals(req, res, callback) {
|
131
|
-
const isManual = req.query.step === 'manual';
|
132
|
-
const locals = super.locals(req, res, callback);
|
133
|
-
const postcode = req.sessionModel.get(`${addressKey}-postcode`);
|
134
|
-
const section = this.options.route.replace(/^\//, '');
|
135
|
-
const editLink = conditionalTranslate('pages.address-lookup.edit', req.translate) || defaults.CHANGE;
|
136
|
-
const cantFind = conditionalTranslate('pages.address-lookup.cantfind', req.translate) || defaults.CANT_FIND;
|
137
|
-
|
138
|
-
let postcodeApiMessageKey;
|
139
|
-
let postcodeError;
|
140
|
-
|
141
|
-
if (!isManual) {
|
142
|
-
postcodeApiMessageKey = (req.sessionModel.get(`${addressKey}-postcodeApiMeta`) || {}).messageKey;
|
143
|
-
}
|
144
|
-
|
145
|
-
if (postcodeApiMessageKey) {
|
146
|
-
const key = `pages.address-lookup.postcode-api.${postcodeApiMessageKey}`;
|
147
|
-
postcodeError = conditionalTranslate(key, req.translate) ||
|
148
|
-
defaults.POSTCODE_ERROR[postcodeApiMessageKey];
|
149
|
-
}
|
150
|
-
|
151
|
-
return _.merge({}, locals, {
|
152
|
-
postcodeEntered: conditionalTranslate('pages.address-lookup.postcode-entered', req.translate) ||
|
153
|
-
defaults.POSTCODE_ENTERED,
|
154
|
-
enterManually: conditionalTranslate('pages.address.lookup.enter-manually', req.translate) ||
|
155
|
-
defaults.ENTER_MANUALLY,
|
156
|
-
route: this.options.route,
|
157
|
-
editLink,
|
158
|
-
cantFind,
|
159
|
-
postcodeError,
|
160
|
-
postcode,
|
161
|
-
section
|
162
|
-
});
|
163
|
-
}
|
164
|
-
|
165
|
-
process(req, res, callback) {
|
166
|
-
if (req.query.step === 'postcode') {
|
167
|
-
const postcode = req.form.values[`${addressKey}-postcode`];
|
168
|
-
this.model.set({ postcode });
|
169
|
-
}
|
170
|
-
super.process(req, res, callback);
|
171
|
-
}
|
172
|
-
|
173
|
-
// eslint-disable-next-line consistent-return
|
174
|
-
lookupPostcode(req, res, callback) {
|
175
|
-
this.model.fetch()
|
176
|
-
.then(data => {
|
177
|
-
if (data.length) {
|
178
|
-
req.sessionModel.set(`${addressKey}-addresses`, data);
|
179
|
-
} else {
|
180
|
-
req.sessionModel.unset(`${addressKey}-addresses`);
|
181
|
-
req.sessionModel.set(`${addressKey}-postcodeApiMeta`, {
|
182
|
-
messageKey: 'not-found'
|
183
|
-
});
|
184
|
-
}
|
185
|
-
return callback();
|
186
|
-
})
|
187
|
-
.catch(err => {
|
188
|
-
req.sessionModel.set(`${addressKey}-postcodeApiMeta`, {
|
189
|
-
messageKey: 'cant-connect'
|
190
|
-
});
|
191
|
-
// eslint-disable-next-line no-console
|
192
|
-
console.error('Postcode lookup error: ',
|
193
|
-
`Code: ${err.status}; Detail: ${err.detail}`);
|
194
|
-
return callback();
|
195
|
-
});
|
196
|
-
}
|
197
|
-
|
198
|
-
saveValues(req, res, callback) {
|
199
|
-
const step = req.query.step;
|
200
|
-
if (step === 'postcode') {
|
201
|
-
return this.lookupPostcode(req, res, err => {
|
202
|
-
if (err) {
|
203
|
-
return callback(err);
|
204
|
-
}
|
205
|
-
return super.saveValues(req, res, callback);
|
206
|
-
});
|
207
|
-
} else if (step === 'lookup') {
|
208
|
-
const addressLines = req.form.values[`${addressKey}-select`].split(', ').join('\n');
|
209
|
-
req.sessionModel.set(addressKey, addressLines);
|
210
|
-
}
|
211
|
-
return super.saveValues(req, res, callback);
|
212
|
-
}
|
213
|
-
|
214
|
-
// eslint-disable-next-line consistent-return
|
215
|
-
validate(req, res, callback) {
|
216
|
-
if (req.query.step === 'postcode' && this.model.get('validate')) {
|
217
|
-
const key = `${addressKey}-postcode`;
|
218
|
-
const postcode = encodeURIComponent(req.form.values[key]);
|
219
|
-
this.model.validate(postcode)
|
220
|
-
.then(() => super.validate(req, res, callback))
|
221
|
-
.catch(e => {
|
222
|
-
let err = e;
|
223
|
-
// this code is set by the model for a validation error
|
224
|
-
if (err.status === 418) {
|
225
|
-
err = {
|
226
|
-
[key]: new this.ValidationError(key, {
|
227
|
-
key,
|
228
|
-
type: err.type,
|
229
|
-
redirect: undefined
|
230
|
-
}, req, res)
|
231
|
-
};
|
232
|
-
// cannot connect to validation service, skip api validation
|
233
|
-
} else if (err.status === 403 || err.status === 404) {
|
234
|
-
return super.validate(req, res, callback);
|
235
|
-
}
|
236
|
-
return callback(err);
|
237
|
-
});
|
238
|
-
} else {
|
239
|
-
return super.validate(req, res, callback);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
|
243
|
-
getBackLink(req, res) {
|
244
|
-
let backLink = super.getBackLink(req, res);
|
245
|
-
if (_.includes(['manual', 'address', 'lookup'], req.query.step)) {
|
246
|
-
backLink = req.path;
|
247
|
-
}
|
248
|
-
return backLink;
|
249
|
-
}
|
250
|
-
};
|
251
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
{{<partials-page}}
|
2
|
-
{{$page-content}}
|
3
|
-
<p>
|
4
|
-
<label>{{postcodeEntered}}</label>
|
5
|
-
<strong><span class="postcode">{{postcode}}</span></strong>
|
6
|
-
<strong><span class="link"><a class="change-postcode" href="{{#qs}}step=postcode{{/qs}}">{{editLink}}</a></span></strong>
|
7
|
-
</p>
|
8
|
-
{{#fields}}
|
9
|
-
{{#renderField}}{{/renderField}}
|
10
|
-
{{/fields}}
|
11
|
-
<p><span class="link"><a class="cant-find" href="{{#qs}}step=manual{{/qs}}">{{cantFind}}</a></span></p>
|
12
|
-
{{#input-submit}}continue{{/input-submit}}
|
13
|
-
{{/page-content}}
|
14
|
-
{{/partials-page}}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
{{<partials-page}}
|
2
|
-
{{$page-content}}
|
3
|
-
{{#postcode}}
|
4
|
-
<p>
|
5
|
-
<label>{{postcodeEntered}}</label>
|
6
|
-
<strong><span class="postcode">{{postcode}}</span></strong>
|
7
|
-
<strong><span class="link"><a class="change-postcode" href="{{#qs}}step=postcode{{/qs}}">{{editLink}}</a></span></strong>
|
8
|
-
</p>
|
9
|
-
{{/postcode}}
|
10
|
-
{{#postcodeError}}
|
11
|
-
<div class="alert-info">
|
12
|
-
<span class="info-message">
|
13
|
-
{{postcodeError}}
|
14
|
-
</span>
|
15
|
-
</div>
|
16
|
-
{{/postcodeError}}
|
17
|
-
{{#fields}}
|
18
|
-
{{#renderField}}{{/renderField}}
|
19
|
-
{{/fields}}
|
20
|
-
{{#input-submit}}continue{{/input-submit}}
|
21
|
-
{{/page-content}}
|
22
|
-
{{/partials-page}}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
{{<partials-page}}
|
2
|
-
{{$page-content}}
|
3
|
-
{{#fields}}
|
4
|
-
{{#renderField}}{{/renderField}}
|
5
|
-
{{/fields}}
|
6
|
-
<p><span class="link"><a href="{{#qs}}step=manual{{/qs}}">{{enterManually}}</a></span></p>
|
7
|
-
{{#input-submit}}find-address{{/input-submit}}
|
8
|
-
{{/page-content}}
|
9
|
-
{{/partials-page}}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# Clear Session Behaviour
|
2
|
-
|
3
|
-
## What this does
|
4
|
-
Resets the HOF session model `req.sessionModel.reset()` and clears anything stored by Redis when a user has submitted their information. This behaviour can be used on the final/penultimate step in a flow to ensure proper session clearing.
|
5
|
-
|
6
|
-
Clear session happens automatically for the step that uses it if it has no next step. However, if it does, then set the following on the step:
|
7
|
-
```
|
8
|
-
'/confirm': {
|
9
|
-
behaviour: require('hof').components.clearSession,
|
10
|
-
clearSession: true,
|
11
|
-
next: '/confirmation'
|
12
|
-
}
|
13
|
-
```
|
14
|
-
However if you want to prevent clear session where there is no next step then set 'clearSession' to false:
|
15
|
-
```
|
16
|
-
'/confirm': {
|
17
|
-
behaviour: require('hof').components.clearSession,
|
18
|
-
clearSession: false
|
19
|
-
}
|
20
|
-
```
|
21
|
-
|
22
|
-
## Additional information
|
23
|
-
|
24
|
-
In your fields file the clear session behaviour can be brought in like this.
|
25
|
-
|
26
|
-
```
|
27
|
-
'/confirm': {
|
28
|
-
behaviour: require('hof').components.clearSession
|
29
|
-
}
|
30
|
-
```
|
31
|
-
On your server.js file if you set res.locals to have a confirm step set:
|
32
|
-
```
|
33
|
-
app.use((req, res, next) => {
|
34
|
-
res.locals.confirmStep = '/confirm';
|
35
|
-
next();
|
36
|
-
});
|
37
|
-
```
|
38
|
-
Then the confirm behaviour will also ensure to reset options on your confirm step for 'uploadPdfShared' and 'submitted' back to false if using these options to keep track of the generation and submission of pdf files. The default configuration for your confirm step might looks like this:
|
39
|
-
```
|
40
|
-
'/confirm': {
|
41
|
-
behaviour: [SubmitPDFBehaviour, require('hof').components.clearSession],
|
42
|
-
uploadPdfShared: false,
|
43
|
-
submitted: false
|
44
|
-
}
|
45
|
-
```
|
46
|
-
where a SubmitPDFBehaviour is run first which updates the 'uploadPdfShared' and 'submitted' options on the confirm step to true. This clear session behaviour will ensure those are reset along with clearing the session model.
|
@@ -1,26 +0,0 @@
|
|
1
|
-
|
2
|
-
const _ = require('lodash');
|
3
|
-
|
4
|
-
module.exports = superclass => class extends superclass {
|
5
|
-
getValues(req, res, callback) {
|
6
|
-
return super.getValues(req, res, (err, values) => {
|
7
|
-
if (err) {
|
8
|
-
return callback(err, values);
|
9
|
-
}
|
10
|
-
|
11
|
-
const confirmStep = res.locals.confirmStep;
|
12
|
-
|
13
|
-
if (req.path !== confirmStep && _.get(this, `options.steps[${confirmStep}]`)) {
|
14
|
-
this.options.steps[confirmStep].uploadPdfShared = false;
|
15
|
-
this.options.steps[confirmStep].submitted = false;
|
16
|
-
}
|
17
|
-
const noNext = _.isUndefined(this.options.next);
|
18
|
-
const clearSession = this.options.clearSession;
|
19
|
-
// clear the session if there's no next step or we request to clear the session
|
20
|
-
if ((noNext && clearSession !== false) || clearSession === true) {
|
21
|
-
req.sessionModel.reset();
|
22
|
-
}
|
23
|
-
return callback(null, values);
|
24
|
-
});
|
25
|
-
}
|
26
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# Combine & Loop Fields Behaviour
|
2
|
-
|
3
|
-
## What this does
|
4
|
-
This allows you to specify fields to loop over and add as objects to a parent array. You can use this for adding multiple addresses, criminal offences, names etc. You can see here in this example, we ask for a set of details prefixed with the word `storage-` for getting address details for multiple storage addresses (see the Home Office's firearms repository). We then can aggregate these addresses as objects into an array called `all-storage-addresses` and get redirected back to `/add-address` whenever we selected `yes` to adding another address,
|
5
|
-
```
|
6
|
-
'/add-address': {
|
7
|
-
fields: [
|
8
|
-
'storage-building',
|
9
|
-
'storage-street',
|
10
|
-
'storage-townOrCity',
|
11
|
-
'storage-postcodeOrZIPCode'
|
12
|
-
],
|
13
|
-
next: '/add-another-address-with-list',
|
14
|
-
continueOnEdit: true
|
15
|
-
},
|
16
|
-
'/add-another-address-with-list': {
|
17
|
-
template: 'add-another-address-loop.html',
|
18
|
-
behaviours: CombineAndLoopFields({
|
19
|
-
groupName: 'all-storage-addresses',
|
20
|
-
fieldsToGroup: [
|
21
|
-
'storage-building',
|
22
|
-
'storage-street',
|
23
|
-
'storage-townOrCity',
|
24
|
-
'storage-postcodeOrZIPCode'
|
25
|
-
],
|
26
|
-
removePrefix: 'storage-',
|
27
|
-
combineValuesToSingleField: 'address',
|
28
|
-
groupOptional: true,
|
29
|
-
returnTo: '/add-address'
|
30
|
-
}),
|
31
|
-
next: '/confirm'
|
32
|
-
```
|
33
|
-
Here are the fields you call this behaviour first to set config for it:
|
34
|
-
```
|
35
|
-
`groupName`: (Required) a parent array for storing details for each object you are collecting information for,
|
36
|
-
`fieldsToGroup`: (Required) the fields being specified for an object, e.g. house number, street, postcode, that are grouped together,
|
37
|
-
`removePrefix`: (Optional) a string which is used to remove consistent prefixes from a collection of fields that are grouped together,
|
38
|
-
`combineValuesToSingleField`: (Optional) a new field that is created with its value being the concatenation of values of the fields specified in `fieldsToGroup`,
|
39
|
-
`groupOptional`: (Optional) set this to true if you want to land on the radio button question if all records in the group are deleted after creation,
|
40
|
-
`returnTo`: (Required) the next step if you want to add another object to this group
|
41
|
-
```
|
42
|
-
N.B. in the above example we use `continueOnEdit: true` on the individual record step (i.e. `/add-address`) to ensure we revisit the grouped fields page otherwise it will not be added to the group and the user will be returned to the 'Check Your Answers' page upon a field edit.
|