@planning-inspectorate/dynamic-forms 3.15.5 → 3.16.0
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/.gitattributes +3 -0
- package/.prettierrc +1 -0
- package/README.md +11 -3
- package/package.json +6 -4
- package/{types/src → src}/components/address/question.d.ts +14 -2
- package/src/components/address/question.d.ts.map +1 -0
- package/src/components/address/question.js +1 -2
- package/{types/src → src}/components/boolean/question.d.ts +2 -2
- package/src/components/boolean/question.d.ts.map +1 -0
- package/src/components/boolean/question.js +1 -1
- package/src/components/checkbox/question.d.ts +29 -0
- package/src/components/checkbox/question.d.ts.map +1 -0
- package/src/components/checkbox/question.js +1 -5
- package/{types/src → src}/components/date/question.d.ts +10 -2
- package/src/components/date/question.d.ts.map +1 -0
- package/src/components/date/question.js +1 -2
- package/{types/src → src}/components/date-period/question.d.ts +16 -4
- package/src/components/date-period/question.d.ts.map +1 -0
- package/src/components/date-period/question.js +1 -2
- package/{types/src → src}/components/date-time/question.d.ts +10 -2
- package/src/components/date-time/question.d.ts.map +1 -0
- package/src/components/date-time/question.js +1 -2
- package/src/components/email/question.d.ts +23 -0
- package/src/components/email/question.d.ts.map +1 -0
- package/src/components/email/question.js +1 -9
- package/src/components/manage-list/manage-list-actions.d.ts.map +1 -0
- package/src/components/manage-list/manage-list-section.d.ts.map +1 -0
- package/{types/src → src}/components/manage-list/question.d.ts +10 -3
- package/src/components/manage-list/question.d.ts.map +1 -0
- package/src/components/manage-list/question.js +4 -1
- package/{types/src → src}/components/manage-list/utils.d.ts +3 -3
- package/src/components/manage-list/utils.d.ts.map +1 -0
- package/src/components/manage-list/utils.js +2 -2
- package/src/components/multi-field-input/question.d.ts +52 -0
- package/src/components/multi-field-input/question.d.ts.map +1 -0
- package/src/components/multi-field-input/question.js +5 -13
- package/{types/src → src}/components/number-entry/question.d.ts +7 -3
- package/src/components/number-entry/question.d.ts.map +1 -0
- package/src/components/number-entry/question.js +2 -2
- package/src/components/radio/question.d.ts +19 -0
- package/src/components/radio/question.d.ts.map +1 -0
- package/src/components/radio/question.js +1 -5
- package/{types/src → src}/components/select/question.d.ts +7 -3
- package/src/components/select/question.d.ts.map +1 -0
- package/src/components/select/question.js +2 -2
- package/src/components/single-line-input/question.d.ts +20 -0
- package/src/components/single-line-input/question.d.ts.map +1 -0
- package/src/components/single-line-input/question.js +1 -1
- package/{types/src → src}/components/text-entry/question.d.ts +7 -3
- package/src/components/text-entry/question.d.ts.map +1 -0
- package/src/components/text-entry/question.js +1 -1
- package/{types/src → src}/components/text-entry-redact/question.d.ts +12 -9
- package/src/components/text-entry-redact/question.d.ts.map +1 -0
- package/src/components/text-entry-redact/question.js +4 -1
- package/{types/src → src}/components/unit-option-entry/question.d.ts +12 -8
- package/src/components/unit-option-entry/question.d.ts.map +1 -0
- package/src/components/unit-option-entry/question.js +5 -6
- package/src/components/utils/component-types.d.ts.map +1 -0
- package/src/components/utils/persisted-number-answer.d.ts.map +1 -0
- package/src/components/utils/question-has-answer.d.ts.map +1 -0
- package/src/components/utils/question-utils.d.ts.map +1 -0
- package/{types/src → src}/controller.d.ts +2 -7
- package/src/controller.d.ts.map +1 -0
- package/src/controller.js +3 -10
- package/{types/src → src}/index.d.ts +4 -3
- package/src/index.d.ts.map +1 -0
- package/src/index.js +6 -4
- package/src/journey/journey-response.d.ts +28 -0
- package/src/journey/journey-response.d.ts.map +1 -0
- package/src/journey/journey-response.js +4 -8
- package/{types/src → src}/journey/journey.d.ts +8 -8
- package/src/journey/journey.d.ts.map +1 -0
- package/src/journey/journey.js +6 -6
- package/src/lib/address-utils.d.ts.map +1 -0
- package/src/lib/address.d.ts.map +1 -0
- package/src/lib/date-utils.d.ts.map +1 -0
- package/src/lib/session-answer-store.d.ts.map +1 -0
- package/src/lib/utils.d.ts.map +1 -0
- package/src/lib/uuid.d.ts.map +1 -0
- package/src/middleware/build-get-journey.d.ts.map +1 -0
- package/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
- package/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
- package/src/middleware/redirect-to-unanswered-question.js +1 -1
- package/src/questions/create-questions.d.ts +18 -0
- package/src/questions/create-questions.d.ts.map +1 -0
- package/src/questions/create-questions.js +5 -4
- package/{types/src → src}/questions/options-question.d.ts +7 -7
- package/src/questions/options-question.d.ts.map +1 -0
- package/src/questions/options-question.js +4 -4
- package/{types/src → src}/questions/question.d.ts +33 -79
- package/src/questions/question.d.ts.map +1 -0
- package/src/questions/question.js +19 -51
- package/src/questions/questions.d.ts +3 -0
- package/src/questions/questions.d.ts.map +1 -0
- package/src/questions/questions.js +1 -1
- package/{types/src → src}/section.d.ts +16 -15
- package/src/section.d.ts.map +1 -0
- package/src/section.js +12 -14
- package/src/validator/address-validator.d.ts.map +1 -0
- package/src/validator/base-validator.d.ts.map +1 -0
- package/src/validator/conditional-required-validator.d.ts.map +1 -0
- package/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
- package/src/validator/coordinates-validator.d.ts.map +1 -0
- package/src/validator/cross-question-validator.d.ts.map +1 -0
- package/src/validator/date-period-validator.d.ts.map +1 -0
- package/src/validator/date-time-validator.d.ts.map +1 -0
- package/src/validator/date-validator.d.ts.map +1 -0
- package/src/validator/document-upload-validator.d.ts.map +1 -0
- package/src/validator/email-validator.d.ts.map +1 -0
- package/{types/src → src}/validator/multi-field-input-validator.d.ts +3 -3
- package/src/validator/multi-field-input-validator.d.ts.map +1 -0
- package/src/validator/multi-field-input-validator.js +3 -3
- package/{types/src → src}/validator/numeric-validator.d.ts +2 -2
- package/src/validator/numeric-validator.d.ts.map +1 -0
- package/src/validator/numeric-validator.js +2 -2
- package/src/validator/required-validator.d.ts.map +1 -0
- package/src/validator/same-answer-validator.d.ts.map +1 -0
- package/{types/src → src}/validator/string-validator.d.ts +3 -3
- package/src/validator/string-validator.d.ts.map +1 -0
- package/src/validator/string-validator.js +3 -3
- package/src/validator/unit-option-entry-validator.d.ts.map +1 -0
- package/src/validator/valid-option-validator.d.ts.map +1 -0
- package/src/validator/validation-error-handler.d.ts.map +1 -0
- package/src/validator/validator.d.ts.map +1 -0
- package/test/questions.js +1 -1
- package/test/secondary-actions.test.js +1 -1
- package/tsconfig.json +11 -4
- package/{src/questions → typedefs}/question-props.d.ts +28 -26
- package/{src/questions → typedefs}/question-types.d.ts +44 -16
- package/{src → typedefs}/section-types.d.ts +1 -1
- package/typedefs/section-types.js +1 -0
- package/move-types.js +0 -12
- package/src/components/identifier/index.njk +0 -62
- package/src/components/identifier/question.js +0 -33
- package/src/components/identifier/question.test.js +0 -46
- package/types/commitlint.config.d.ts +0 -7
- package/types/commitlint.config.d.ts.map +0 -1
- package/types/eslint.config.d.ts +0 -97
- package/types/eslint.config.d.ts.map +0 -1
- package/types/move-types.d.ts +0 -2
- package/types/move-types.d.ts.map +0 -1
- package/types/src/components/address/question.d.ts.map +0 -1
- package/types/src/components/boolean/question.d.ts.map +0 -1
- package/types/src/components/checkbox/question.d.ts +0 -33
- package/types/src/components/checkbox/question.d.ts.map +0 -1
- package/types/src/components/date/question.d.ts.map +0 -1
- package/types/src/components/date-period/question.d.ts.map +0 -1
- package/types/src/components/date-time/question.d.ts.map +0 -1
- package/types/src/components/email/question.d.ts +0 -35
- package/types/src/components/email/question.d.ts.map +0 -1
- package/types/src/components/identifier/question.d.ts +0 -16
- package/types/src/components/identifier/question.d.ts.map +0 -1
- package/types/src/components/manage-list/manage-list-actions.d.ts.map +0 -1
- package/types/src/components/manage-list/manage-list-section.d.ts.map +0 -1
- package/types/src/components/manage-list/question.d.ts.map +0 -1
- package/types/src/components/manage-list/utils.d.ts.map +0 -1
- package/types/src/components/multi-field-input/question.d.ts +0 -64
- package/types/src/components/multi-field-input/question.d.ts.map +0 -1
- package/types/src/components/number-entry/question.d.ts.map +0 -1
- package/types/src/components/radio/question.d.ts +0 -23
- package/types/src/components/radio/question.d.ts.map +0 -1
- package/types/src/components/select/question.d.ts.map +0 -1
- package/types/src/components/single-line-input/question.d.ts +0 -16
- package/types/src/components/single-line-input/question.d.ts.map +0 -1
- package/types/src/components/text-entry/question.d.ts.map +0 -1
- package/types/src/components/text-entry-redact/question.d.ts.map +0 -1
- package/types/src/components/unit-option-entry/question.d.ts.map +0 -1
- package/types/src/components/utils/component-types.d.ts.map +0 -1
- package/types/src/components/utils/persisted-number-answer.d.ts.map +0 -1
- package/types/src/components/utils/question-has-answer.d.ts.map +0 -1
- package/types/src/components/utils/question-utils.d.ts.map +0 -1
- package/types/src/controller.d.ts.map +0 -1
- package/types/src/index.d.ts.map +0 -1
- package/types/src/journey/journey-response.d.ts +0 -32
- package/types/src/journey/journey-response.d.ts.map +0 -1
- package/types/src/journey/journey-types.d.ts +0 -28
- package/types/src/journey/journey-types.d.ts.map +0 -1
- package/types/src/journey/journey.d.ts.map +0 -1
- package/types/src/lib/address-utils.d.ts.map +0 -1
- package/types/src/lib/address.d.ts.map +0 -1
- package/types/src/lib/date-utils.d.ts.map +0 -1
- package/types/src/lib/session-answer-store.d.ts.map +0 -1
- package/types/src/lib/utils.d.ts.map +0 -1
- package/types/src/lib/uuid.d.ts.map +0 -1
- package/types/src/middleware/build-get-journey.d.ts.map +0 -1
- package/types/src/middleware/redirect-to-unanswered-question.d.ts +0 -12
- package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +0 -1
- package/types/src/questions/create-questions.d.ts +0 -19
- package/types/src/questions/create-questions.d.ts.map +0 -1
- package/types/src/questions/options-question.d.ts.map +0 -1
- package/types/src/questions/question-props.d.ts +0 -295
- package/types/src/questions/question-props.d.ts.map +0 -1
- package/types/src/questions/question-types.d.ts +0 -86
- package/types/src/questions/question-types.d.ts.map +0 -1
- package/types/src/questions/question.d.ts.map +0 -1
- package/types/src/questions/questions.d.ts +0 -3
- package/types/src/questions/questions.d.ts.map +0 -1
- package/types/src/section.d.ts.map +0 -1
- package/types/src/validator/address-validator.d.ts.map +0 -1
- package/types/src/validator/base-validator.d.ts.map +0 -1
- package/types/src/validator/conditional-required-validator.d.ts.map +0 -1
- package/types/src/validator/confirmation-checkbox-validator.d.ts.map +0 -1
- package/types/src/validator/coordinates-validator.d.ts.map +0 -1
- package/types/src/validator/cross-question-validator.d.ts.map +0 -1
- package/types/src/validator/date-period-validator.d.ts.map +0 -1
- package/types/src/validator/date-time-validator.d.ts.map +0 -1
- package/types/src/validator/date-validator.d.ts.map +0 -1
- package/types/src/validator/document-upload-validator.d.ts.map +0 -1
- package/types/src/validator/email-validator.d.ts.map +0 -1
- package/types/src/validator/multi-field-input-validator.d.ts.map +0 -1
- package/types/src/validator/numeric-validator.d.ts.map +0 -1
- package/types/src/validator/required-validator.d.ts.map +0 -1
- package/types/src/validator/same-answer-validator.d.ts.map +0 -1
- package/types/src/validator/string-validator.d.ts.map +0 -1
- package/types/src/validator/unit-option-entry-validator.d.ts.map +0 -1
- package/types/src/validator/valid-option-validator.d.ts.map +0 -1
- package/types/src/validator/validation-error-handler.d.ts.map +0 -1
- package/types/src/validator/validator.d.ts.map +0 -1
- /package/{types/src → src}/components/manage-list/manage-list-actions.d.ts +0 -0
- /package/{types/src → src}/components/manage-list/manage-list-section.d.ts +0 -0
- /package/{types/src → src}/components/utils/component-types.d.ts +0 -0
- /package/{types/src → src}/components/utils/persisted-number-answer.d.ts +0 -0
- /package/{types/src → src}/components/utils/question-has-answer.d.ts +0 -0
- /package/{types/src → src}/components/utils/question-utils.d.ts +0 -0
- /package/{types/src → src}/lib/address-utils.d.ts +0 -0
- /package/{types/src → src}/lib/address.d.ts +0 -0
- /package/{types/src → src}/lib/date-utils.d.ts +0 -0
- /package/{types/src → src}/lib/session-answer-store.d.ts +0 -0
- /package/{types/src → src}/lib/utils.d.ts +0 -0
- /package/{types/src → src}/lib/uuid.d.ts +0 -0
- /package/{types/src → src}/middleware/build-get-journey.d.ts +0 -0
- /package/{types/src → src}/validator/address-validator.d.ts +0 -0
- /package/{types/src → src}/validator/base-validator.d.ts +0 -0
- /package/{types/src → src}/validator/conditional-required-validator.d.ts +0 -0
- /package/{types/src → src}/validator/confirmation-checkbox-validator.d.ts +0 -0
- /package/{types/src → src}/validator/coordinates-validator.d.ts +0 -0
- /package/{types/src → src}/validator/cross-question-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-period-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-time-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-validator.d.ts +0 -0
- /package/{types/src → src}/validator/document-upload-validator.d.ts +0 -0
- /package/{types/src → src}/validator/email-validator.d.ts +0 -0
- /package/{types/src → src}/validator/required-validator.d.ts +0 -0
- /package/{types/src → src}/validator/same-answer-validator.d.ts +0 -0
- /package/{types/src → src}/validator/unit-option-entry-validator.d.ts +0 -0
- /package/{types/src → src}/validator/valid-option-validator.d.ts +0 -0
- /package/{types/src → src}/validator/validation-error-handler.d.ts +0 -0
- /package/{types/src → src}/validator/validator.d.ts +0 -0
- /package/{src/journey → typedefs}/journey-types.d.ts +0 -0
- /package/{src/journey → typedefs}/journey-types.js +0 -0
- /package/{src/questions → typedefs}/question-props.js +0 -0
- /package/{src/questions → typedefs}/question-types.js +0 -0
package/src/journey/journey.js
CHANGED
|
@@ -131,7 +131,7 @@ export class Journey {
|
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* utility function to build up a url to a question
|
|
134
|
-
* @param {import('
|
|
134
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
135
135
|
* @returns {string} url for a question
|
|
136
136
|
*/
|
|
137
137
|
#buildQuestionUrl(params) {
|
|
@@ -183,7 +183,7 @@ export class Journey {
|
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* gets a question from the object's sections based on a section + question names
|
|
186
|
-
* @param {import('
|
|
186
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
187
187
|
* @returns {import('../questions/question.js').Question | undefined} question found by lookup
|
|
188
188
|
*/
|
|
189
189
|
getQuestionByParams(params) {
|
|
@@ -207,7 +207,7 @@ export class Journey {
|
|
|
207
207
|
* Get the back link for the journey - e.g. the previous question
|
|
208
208
|
*
|
|
209
209
|
* @param {Object} options
|
|
210
|
-
* @param {import('
|
|
210
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} options.params
|
|
211
211
|
* @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
|
|
212
212
|
* @returns {string|null} url for the next question, or null if unmatched
|
|
213
213
|
*/
|
|
@@ -227,7 +227,7 @@ export class Journey {
|
|
|
227
227
|
* Used after question post/saving
|
|
228
228
|
*
|
|
229
229
|
* @param {import('express').Response} res
|
|
230
|
-
* @param {import('
|
|
230
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
231
231
|
* @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
|
|
232
232
|
* @returns {void}
|
|
233
233
|
*/
|
|
@@ -239,7 +239,7 @@ export class Journey {
|
|
|
239
239
|
/**
|
|
240
240
|
* Get url for the next question in the journey
|
|
241
241
|
*
|
|
242
|
-
* @param {import('
|
|
242
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
243
243
|
* @param {Object} options
|
|
244
244
|
* @param {boolean} [options.reverse] - if passed in this will get the previous question
|
|
245
245
|
* @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
|
|
@@ -293,7 +293,7 @@ export class Journey {
|
|
|
293
293
|
* don't include other params which may be set (e.g. manageList* params), as we may now be
|
|
294
294
|
* redirecting to a non-manage list question, having previously been on a manage list question
|
|
295
295
|
*
|
|
296
|
-
* @type {import('
|
|
296
|
+
* @type {import('#typedefs/journey-types.d.ts').RouteParams}
|
|
297
297
|
*/
|
|
298
298
|
let newParams = {
|
|
299
299
|
section: currentSection.segment,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-utils.d.ts","sourceRoot":"","sources":["address-utils.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,kDAFa,MAAM,CAKlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["address.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IA0BC;;;;;;;;OAQG;IACH,wEANG;QAAuB,YAAY,EAA3B,MAAM;QACS,YAAY,EAA3B,MAAM;QACS,QAAQ,EAAvB,MAAM;QACS,MAAM,EAArB,MAAM;QACS,QAAQ,EAAvB,MAAM;KAChB,EAOA;IAxCD;;OAEG;IACH,cAFU,MAAM,CAEH;IAEb;;OAEG;IACH,cAFU,MAAM,CAEH;IAEb;;OAEG;IACH,UAFU,MAAM,CAEP;IAET;;OAEG;IACH,QAFU,MAAM,CAET;IAEP;;OAEG;IACH,UAFU,MAAM,CAEP;CAkBT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["date-utils.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,4CALW,IAAI,GAAC,MAAM,eAEnB;IAAyB,MAAM;CAC/B,GAAU,MAAM,CAMlB;AAED;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,2EAHW,cAAc,GACZ,IAAI,CAMhB;AAED;;GAEG;AACH,mCAWC;AAED;;GAEG;AACH,iCAWC;AAqCD;;;;;GAKG;AACH,4CAJW,IAAI,WACJ,IAAI,GACF,OAAO,CASnB;AAED;;;;GAIG;AACH,+CAHW,IAAI,GACF,OAAO,CASnB;AA/CM,uCAHI,IAAI,GACF,OAAO,CAInB;AAMM,wCAHI,IAAI,GACF,OAAO,CAInB;AAMM,kCAHI,IAAI,GACF,OAAO,CAInB;;UArFa,MAAM;WACN,MAAM;SACN,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-answer-store.d.ts","sourceRoot":"","sources":["session-answer-store.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,sDAJG;IAAsB,QAAQ;CAE9B,GAAU,OAAO,kBAAkB,EAAE,UAAU,CA8CjD;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gFANG;IAA0C,GAAG,EAArC,OAAO,SAAS,EAAE,OAAO;IACV,SAAS,EAAxB,MAAM;IACuB,WAAW;;;IACxB,QAAQ;CAChC,GAAU,IAAI,CAkBhB;AAED;;;;;;GAMG;AACH,8DAJW,MAAM,aACN,MAAM,GACJ,OAAO,SAAS,EAAE,OAAO,CA2BrC;AA/ED;;;;GAIG;AACH,gCAFU,OAAO,kBAAkB,EAAE,UAAU,CAEW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;GAGG;AACH,gCAHW,MAAM,GAAC,GAAG,GACR,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wBAFa,CAAC,SADH,CAAC,GAAC,CAAC,EAAE,OAKf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["uuid.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACC,yEAEC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-get-journey.d.ts","sourceRoot":"","sources":["build-get-journey.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+CAHW,CAAC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,gCAAgC,EAAE,eAAe,KAAK,OAAO,uBAAuB,EAAE,OAAO,GACpJ,OAAO,SAAS,EAAE,OAAO,CAgBrC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {function(import('../questions/question.js').Question, import('#journey-response').JourneyResponse): boolean} ShouldDisplayCondition
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Redirects to the first unanswered question in a journey, or to the task list if complete
|
|
6
|
+
*
|
|
7
|
+
* @param {ShouldDisplayCondition[]} [conditions]
|
|
8
|
+
* @returns {import('express').Handler}
|
|
9
|
+
*/
|
|
10
|
+
export function redirectToUnansweredQuestion(conditions?: ShouldDisplayCondition[]): import("express").Handler;
|
|
11
|
+
export type ShouldDisplayCondition = (arg0: import("../questions/question.js").Question, arg1: import("#journey-response").JourneyResponse) => boolean;
|
|
12
|
+
//# sourceMappingURL=redirect-to-unanswered-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-to-unanswered-question.d.ts","sourceRoot":"","sources":["redirect-to-unanswered-question.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,0DAHW,sBAAsB,EAAE,GACtB,OAAO,SAAS,EAAE,OAAO,CA8BrC;qCArCY,CAAS,IAA2C,EAA3C,OAAO,0BAA0B,EAAE,QAAQ,EAAE,IAA2C,EAA3C,OAAO,mBAAmB,EAAE,eAAe,KAAG,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {function(import('../
|
|
2
|
+
* @typedef {function(import('../questions/question.js').Question, import('#journey-response').JourneyResponse): boolean} ShouldDisplayCondition
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template {string} K Question keys in questionPropsRecord
|
|
3
|
+
* @template {import('#typedefs/question-props.d.ts').BaseQuestionProps} T
|
|
4
|
+
* @param {{[questionName in K]: T}} questionPropsRecord
|
|
5
|
+
* @param {Record<string, import('#typedefs/question-types.d.ts').QuestionClass>} questionClasses
|
|
6
|
+
* @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
|
|
7
|
+
* @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
|
|
8
|
+
* @returns {{[questionName in K]: InstanceType<import('#typedefs/question-types.d.ts').QuestionClass>}} Returns the same question keys that were passed in with each value being an instantiated question
|
|
9
|
+
*/
|
|
10
|
+
export function createQuestions<K extends string, T extends import("#typedefs/question-props.d.ts").BaseQuestionProps>(questionPropsRecord: { [questionName in K]: T; }, questionClasses: Record<string, import("#typedefs/question-types.d.ts").QuestionClass>, questionMethodOverrides: {
|
|
11
|
+
[questionType: string]: Record<string, Function>;
|
|
12
|
+
}, textOverrides?: {
|
|
13
|
+
notStartedText?: string;
|
|
14
|
+
continueButtonText?: string;
|
|
15
|
+
changeActionText?: string;
|
|
16
|
+
answerActionText?: string;
|
|
17
|
+
}): { [questionName in K]: InstanceType<import("#typedefs/question-types.d.ts").QuestionClass>; };
|
|
18
|
+
//# sourceMappingURL=create-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-questions.d.ts","sourceRoot":"","sources":["create-questions.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,gCARsB,CAAC,SAAV,MAAQ,EACoD,CAAC,SAA7D,OAAQ,+BAA+B,EAAE,iBAAkB,uBAC7D,GAAE,YAAY,IAAI,CAAC,GAAG,CAAC,GAAC,mBACxB,MAAM,CAAC,MAAM,EAAE,OAAO,+BAA+B,EAAE,aAAa,CAAC,2BACrE;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,WAAW,CAAA;CAAC,kBAClD;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAC,GAC1G,GAAE,YAAY,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,+BAA+B,EAAE,aAAa,CAAC,GAAC,CAwBtG"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @template {
|
|
3
|
-
* @
|
|
4
|
-
* @param {
|
|
2
|
+
* @template {string} K Question keys in questionPropsRecord
|
|
3
|
+
* @template {import('#typedefs/question-props.d.ts').BaseQuestionProps} T
|
|
4
|
+
* @param {{[questionName in K]: T}} questionPropsRecord
|
|
5
|
+
* @param {Record<string, import('#typedefs/question-types.d.ts').QuestionClass>} questionClasses
|
|
5
6
|
* @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
|
|
6
7
|
* @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
|
|
7
|
-
* @returns {
|
|
8
|
+
* @returns {{[questionName in K]: InstanceType<import('#typedefs/question-types.d.ts').QuestionClass>}} Returns the same question keys that were passed in with each value being an instantiated question
|
|
8
9
|
*/
|
|
9
10
|
export function createQuestions(questionPropsRecord, questionClasses, questionMethodOverrides, textOverrides) {
|
|
10
11
|
return Object.fromEntries(
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
*}} Option
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
|
-
* @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
25
|
+
* @typedef {import('./question.js').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
26
26
|
*/
|
|
27
27
|
/**
|
|
28
|
-
* @typedef {import('#question-types').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
28
|
+
* @typedef {import('#typedefs/question-types.d.ts').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
29
29
|
*/
|
|
30
30
|
export class OptionsQuestion extends Question {
|
|
31
31
|
/**
|
|
@@ -41,10 +41,10 @@ export class OptionsQuestion extends Question {
|
|
|
41
41
|
* @param {import('#journey').Journey} journey - the journey we are in
|
|
42
42
|
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
43
43
|
* @param {Record<string, unknown>} [payload]
|
|
44
|
-
* @param {import('#question-types').PrepQuestionForRenderingOptions} options
|
|
45
|
-
* @returns {import('./question').QuestionViewModel} QuestionViewModel
|
|
44
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} options
|
|
45
|
+
* @returns {import('./question.js').QuestionViewModel} QuestionViewModel
|
|
46
46
|
*/
|
|
47
|
-
prepQuestionForRendering(section: import("#section").Section, journey: import("#journey").Journey, customViewData?: Record<string, unknown>, payload?: Record<string, unknown>, options: import("#question-types").PrepQuestionForRenderingOptions):
|
|
47
|
+
prepQuestionForRendering(section: import("#section").Section, journey: import("#journey").Journey, customViewData?: Record<string, unknown>, payload?: Record<string, unknown>, options: import("#typedefs/question-types.d.ts").PrepQuestionForRenderingOptions): import("./question.js").QuestionViewModel;
|
|
48
48
|
}
|
|
49
49
|
export default OptionsQuestion;
|
|
50
50
|
export type Option = {
|
|
@@ -68,12 +68,12 @@ export type Option = {
|
|
|
68
68
|
html: string;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
export type OptionsViewModel =
|
|
71
|
+
export type OptionsViewModel = import("./question.js").QuestionViewModel & {
|
|
72
72
|
question: {
|
|
73
73
|
options: Option[];
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
export type OptionsQuestionParameters = import("#question-types").QuestionParameters & {
|
|
76
|
+
export type OptionsQuestionParameters = import("#typedefs/question-types.d.ts").QuestionParameters & {
|
|
77
77
|
options: Array<Option>;
|
|
78
78
|
};
|
|
79
79
|
import { Question } from './question.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-question.d.ts","sourceRoot":"","sources":["options-question.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AACH;;GAEG;AAEH;IAIC;;OAEG;IACH,oBAFW,yBAAyB,EAenC;IAnBD,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CAChB;IAiBP,yBAA+C;IAGhD;;;;;;;;OAQG;IACH,kCAPW,OAAO,UAAU,EAAE,OAAO,WAC1B,OAAO,UAAU,EAAE,OAAO,mBAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACvB,OAAO,+BAA+B,EAAE,+BAA+B,GACrE,OAAO,eAAe,EAAE,iBAAiB,CAkDrD;CAmCD;;qBAhJY;IACR,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;KAClB,CAAC;IACA,eAAe,CAAC,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAA;CACH;+BAIU,OAAO,eAAe,EAAE,iBAAiB,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE;wCAG/E,OAAO,+BAA+B,EAAE,kBAAkB,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE;yBAnC3E,eAAe"}
|
|
@@ -31,10 +31,10 @@ const defaultOptionJoinString = ',';
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
34
|
+
* @typedef {import('./question.js').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
35
35
|
*/
|
|
36
36
|
/**
|
|
37
|
-
* @typedef {import('#question-types').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
37
|
+
* @typedef {import('#typedefs/question-types.d.ts').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
export class OptionsQuestion extends Question {
|
|
@@ -65,8 +65,8 @@ export class OptionsQuestion extends Question {
|
|
|
65
65
|
* @param {import('#journey').Journey} journey - the journey we are in
|
|
66
66
|
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
67
67
|
* @param {Record<string, unknown>} [payload]
|
|
68
|
-
* @param {import('#question-types').PrepQuestionForRenderingOptions} options
|
|
69
|
-
* @returns {import('./question').QuestionViewModel} QuestionViewModel
|
|
68
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} options
|
|
69
|
+
* @returns {import('./question.js').QuestionViewModel} QuestionViewModel
|
|
70
70
|
*/
|
|
71
71
|
prepQuestionForRendering(section, journey, customViewData, payload, options) {
|
|
72
72
|
const viewModel = super.prepQuestionForRendering(section, journey, customViewData, payload, options);
|
|
@@ -1,39 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import {BaseValidator} from "#base-validator"
|
|
3
|
-
* @import {ActionView} from "../controller.js"
|
|
4
|
-
* @import {ActionLink} from "./question-types.js"
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} PreppedQuestion
|
|
8
|
-
* @property {Object} value
|
|
9
|
-
* @property {string} question
|
|
10
|
-
* @property {string} fieldName
|
|
11
|
-
* @property {string} pageTitle
|
|
12
|
-
* @property {string} [description]
|
|
13
|
-
* @property {string} [html]
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Record<string, any>} QuestionViewModel
|
|
17
|
-
* @property {PreppedQuestion} question
|
|
18
|
-
* @property {string} layoutTemplate
|
|
19
|
-
* @property {string} pageCaption
|
|
20
|
-
* @property {string} [continueButtonText]
|
|
21
|
-
* @property {string} backLink
|
|
22
|
-
* @property {boolean} showBackToListLink
|
|
23
|
-
* @property {string} listLink
|
|
24
|
-
* @property {Object} util
|
|
25
|
-
* @property {function(string): string} util.trimTrailingSlash
|
|
26
|
-
*/
|
|
27
1
|
/**
|
|
28
2
|
* A specific question within a journey which is made up of one (usually) or many (sometimes) components and their required content.
|
|
29
3
|
* @class
|
|
30
4
|
*/
|
|
31
5
|
export class Question {
|
|
32
6
|
/**
|
|
33
|
-
* @param {import('
|
|
7
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionParameters} params
|
|
34
8
|
* @param {Record<string, Function>} [methodOverrides]
|
|
35
9
|
*/
|
|
36
|
-
constructor({ title, question, viewFolder, fieldName, url, pageTitle, description, validators, html, hint, interfaceType, shouldDisplay, autocomplete, editable, actionLink, viewData }: import("
|
|
10
|
+
constructor({ title, question, viewFolder, fieldName, url, pageTitle, description, validators, html, hint, interfaceType, shouldDisplay, autocomplete, editable, actionLink, viewData }: import("#typedefs/question-types.d.ts").QuestionParameters, methodOverrides?: Record<string, Function>);
|
|
37
11
|
/** @type {string} - html page title, defaults to question if not provided */
|
|
38
12
|
pageTitle: string;
|
|
39
13
|
/** @type {string} - title used in the summary list */
|
|
@@ -48,8 +22,8 @@ export class Question {
|
|
|
48
22
|
fieldName: string;
|
|
49
23
|
/** @type {boolean} if the question should appear in the journey overview task list or not */
|
|
50
24
|
taskList: boolean;
|
|
51
|
-
/** @type {Array.<BaseValidator>} array of validators that a question uses to validate answers */
|
|
52
|
-
validators: Array<BaseValidator>;
|
|
25
|
+
/** @type {Array.<import('../validator/base-validator.js').BaseValidator>} array of validators that a question uses to validate answers */
|
|
26
|
+
validators: Array<import("../validator/base-validator.js").BaseValidator>;
|
|
53
27
|
/** @type {string|undefined} hint text displayed to user */
|
|
54
28
|
hint: string | undefined;
|
|
55
29
|
/** @type {boolean} show return to listing page link after question */
|
|
@@ -60,8 +34,8 @@ export class Question {
|
|
|
60
34
|
html: string | undefined;
|
|
61
35
|
/** @type {string|undefined} optional question type */
|
|
62
36
|
interfaceType: string | undefined;
|
|
63
|
-
/** @type {ActionLink|undefined} override action link */
|
|
64
|
-
actionLink: ActionLink | undefined;
|
|
37
|
+
/** @type {import('#typedefs/question-types.d.ts').ActionLink|undefined} override action link */
|
|
38
|
+
actionLink: import("#typedefs/question-types.d.ts").ActionLink | undefined;
|
|
65
39
|
/** @type {string} 'not started' text to display (if a question has no answer) */
|
|
66
40
|
notStartedText: string;
|
|
67
41
|
/** @type {string} button text to display */
|
|
@@ -76,7 +50,7 @@ export class Question {
|
|
|
76
50
|
* @param {import('../journey/journey-response.js').JourneyResponse} [response]
|
|
77
51
|
* @returns {boolean}
|
|
78
52
|
*/
|
|
79
|
-
shouldDisplay: () => boolean;
|
|
53
|
+
shouldDisplay: (response?: import("../journey/journey-response.js").JourneyResponse) => boolean;
|
|
80
54
|
details: {
|
|
81
55
|
title: string;
|
|
82
56
|
text: string;
|
|
@@ -93,8 +67,8 @@ export class Question {
|
|
|
93
67
|
editable: boolean;
|
|
94
68
|
viewData: {
|
|
95
69
|
[key: string]: any;
|
|
96
|
-
extraActionButtons?: import("
|
|
97
|
-
secondaryActions?: import("
|
|
70
|
+
extraActionButtons?: import("#typedefs/question-types.d.ts").SecondaryAction[];
|
|
71
|
+
secondaryActions?: import("#typedefs/question-types.d.ts").SecondaryAction[];
|
|
98
72
|
};
|
|
99
73
|
/**
|
|
100
74
|
* Is this question a manage list question?
|
|
@@ -126,22 +100,22 @@ export class Question {
|
|
|
126
100
|
* that prepQuestionForRendering doesn't need
|
|
127
101
|
*
|
|
128
102
|
* @param {Object} options
|
|
129
|
-
* @param {import('
|
|
103
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} options.params
|
|
130
104
|
* @param {import('../components/manage-list/question.js')} [options.manageListQuestion]
|
|
131
105
|
* @param {import('../section.js').Section} options.section - the current section
|
|
132
106
|
* @param {import('../journey/journey.js').Journey} options.journey - the journey we are in
|
|
133
107
|
* @param {Record<string, unknown>} [options.customViewData] additional data to send to view
|
|
134
108
|
* @param {unknown} [options.payload]
|
|
135
|
-
* @returns {QuestionViewModel}
|
|
109
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel}
|
|
136
110
|
*/
|
|
137
111
|
toViewModel({ params, manageListQuestion, section, journey, customViewData, payload }: {
|
|
138
|
-
params: import("
|
|
112
|
+
params: import("#typedefs/journey-types.d.ts").RouteParams;
|
|
139
113
|
manageListQuestion?: typeof import("../components/manage-list/question.js") | undefined;
|
|
140
114
|
section: import("../section.js").Section;
|
|
141
115
|
journey: import("../journey/journey.js").Journey;
|
|
142
116
|
customViewData?: Record<string, unknown> | undefined;
|
|
143
117
|
payload?: unknown;
|
|
144
|
-
}): QuestionViewModel;
|
|
118
|
+
}): import("#typedefs/question-types.d.ts").QuestionViewModel;
|
|
145
119
|
/**
|
|
146
120
|
* gets the base view model for this question
|
|
147
121
|
*
|
|
@@ -149,10 +123,10 @@ export class Question {
|
|
|
149
123
|
* @param {import('../journey/journey.js').Journey} journey - the journey we are in
|
|
150
124
|
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
151
125
|
* @param {unknown} [payload]
|
|
152
|
-
* @param {import('
|
|
153
|
-
* @returns {QuestionViewModel}
|
|
126
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} [options] - required to support manage list question
|
|
127
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel}
|
|
154
128
|
*/
|
|
155
|
-
prepQuestionForRendering(section: import("../section.js").Section, journey: import("../journey/journey.js").Journey, customViewData?: Record<string, unknown>, payload?: unknown, options?: import("
|
|
129
|
+
prepQuestionForRendering(section: import("../section.js").Section, journey: import("../journey/journey.js").Journey, customViewData?: Record<string, unknown>, payload?: unknown, options?: import("#typedefs/question-types.d.ts").PrepQuestionForRenderingOptions): import("#typedefs/question-types.d.ts").QuestionViewModel;
|
|
156
130
|
/**
|
|
157
131
|
* The answer to this question for use in the viewModel
|
|
158
132
|
*
|
|
@@ -167,32 +141,32 @@ export class Question {
|
|
|
167
141
|
*
|
|
168
142
|
* If possible override this method instead of prepQuestionForRendering for simple changes to the view model
|
|
169
143
|
*
|
|
170
|
-
* @param {QuestionViewModel} viewModel
|
|
171
|
-
*/ addCustomDataToViewModel(viewModel: QuestionViewModel): void;
|
|
144
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
145
|
+
*/ addCustomDataToViewModel(viewModel: import("#typedefs/question-types.d.ts").QuestionViewModel): void;
|
|
172
146
|
/**
|
|
173
147
|
* Get the answers object from the journey response, which may be nested in an array for manage list questions
|
|
174
148
|
*
|
|
175
149
|
* @param {import('../journey/journey-response.js').JourneyResponse} response
|
|
176
|
-
* @param {import('
|
|
150
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} [options]
|
|
177
151
|
* @returns {Record<string, any>}
|
|
178
152
|
*/
|
|
179
|
-
answerObjectFromJourneyResponse(response: import("../journey/journey-response.js").JourneyResponse, { params, manageListQuestion }?: import("
|
|
153
|
+
answerObjectFromJourneyResponse(response: import("../journey/journey-response.js").JourneyResponse, { params, manageListQuestion }?: import("#typedefs/question-types.d.ts").PrepQuestionForRenderingOptions): Record<string, any>;
|
|
180
154
|
/**
|
|
181
155
|
* renders the question
|
|
182
156
|
* @param {import('express').Response} res - the express response
|
|
183
|
-
* @param {QuestionViewModel} viewModel additional data to send to view
|
|
157
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel additional data to send to view
|
|
184
158
|
* @returns {void}
|
|
185
159
|
*/
|
|
186
|
-
renderAction(res: import("express").Response, viewModel: QuestionViewModel): void;
|
|
160
|
+
renderAction(res: import("express").Response, viewModel: import("#typedefs/question-types.d.ts").QuestionViewModel): void;
|
|
187
161
|
/**
|
|
188
162
|
* check for validation errors
|
|
189
163
|
* @param {import('express').Request} req
|
|
190
164
|
* @param {import('../journey/journey.js').Journey} journey
|
|
191
165
|
* @param {import('../section.js').Section} section
|
|
192
166
|
* @param {import('../components/manage-list/question.js')} [manageListQuestion]
|
|
193
|
-
* @returns {QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
167
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
194
168
|
*/
|
|
195
|
-
checkForValidationErrors(req: import("express").Request, section: import("../section.js").Section, journey: import("../journey/journey.js").Journey, manageListQuestion?: typeof import("../components/manage-list/question.js")): QuestionViewModel | undefined;
|
|
169
|
+
checkForValidationErrors(req: import("express").Request, section: import("../section.js").Section, journey: import("../journey/journey.js").Journey, manageListQuestion?: typeof import("../components/manage-list/question.js")): import("#typedefs/question-types.d.ts").QuestionViewModel | undefined;
|
|
196
170
|
/**
|
|
197
171
|
* Get the data to save from the request, returns an object of answers
|
|
198
172
|
*
|
|
@@ -207,8 +181,8 @@ export class Question {
|
|
|
207
181
|
* @param {import('express').Request} req
|
|
208
182
|
* @param {import('../journey/journey.js').Journey} journey
|
|
209
183
|
* @param {import('../section.js').Section} sectionObj
|
|
210
|
-
* @returns {QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
211
|
-
*/ checkForSavingErrors(req: import("express").Request, sectionObj: import("../section.js").Section, journey: import("../journey/journey.js").Journey): QuestionViewModel | undefined;
|
|
184
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
185
|
+
*/ checkForSavingErrors(req: import("express").Request, sectionObj: import("../section.js").Section, journey: import("../journey/journey.js").Journey): import("#typedefs/question-types.d.ts").QuestionViewModel | undefined;
|
|
212
186
|
/**
|
|
213
187
|
* Handles redirect after saving. Kept around for backwards compatibility.
|
|
214
188
|
*
|
|
@@ -222,28 +196,20 @@ export class Question {
|
|
|
222
196
|
handleNextQuestion(res: import("express").Response, journey: import("../journey/journey.js").Journey, sectionSegment: string, questionSegment: string): void;
|
|
223
197
|
/**
|
|
224
198
|
* returns the formatted answers values to be used to build task list elements
|
|
225
|
-
* @param {
|
|
199
|
+
* @param {string} sectionSegment
|
|
226
200
|
* @param {import('../journey/journey.js').Journey} journey
|
|
227
201
|
* @param {unknown} answer
|
|
228
|
-
* @returns {
|
|
229
|
-
* key: string;
|
|
230
|
-
* value: string | Object;
|
|
231
|
-
* action?: ActionView | ActionView[];
|
|
232
|
-
* }>}
|
|
202
|
+
* @returns {import('#typedefs/question-types.d.ts').SummaryRow[]}
|
|
233
203
|
*/
|
|
234
|
-
formatAnswerForSummary(sectionSegment: string, journey: import("../journey/journey.js").Journey, answer: unknown, capitals?: boolean):
|
|
235
|
-
key: string;
|
|
236
|
-
value: string | Object;
|
|
237
|
-
action?: ActionView | ActionView[];
|
|
238
|
-
}>;
|
|
204
|
+
formatAnswerForSummary(sectionSegment: string, journey: import("../journey/journey.js").Journey, answer: unknown, capitals?: boolean): import("#typedefs/question-types.d.ts").SummaryRow[];
|
|
239
205
|
/**
|
|
240
206
|
* Returns the action link for the question
|
|
241
|
-
* @param {
|
|
207
|
+
* @param {string} sectionSegment
|
|
242
208
|
* @param {import('../journey/journey.js').Journey} journey
|
|
243
|
-
* @param {
|
|
244
|
-
* @returns {ActionView|ActionView[]|undefined}
|
|
209
|
+
* @param {unknown} answer
|
|
210
|
+
* @returns {import('#typedefs/question-types.d.ts').ActionView | import('#typedefs/question-types.d.ts').ActionView[] | undefined}
|
|
245
211
|
*/
|
|
246
|
-
getAction(sectionSegment: string, journey: import("../journey/journey.js").Journey, answer: unknown): ActionView | ActionView[] | undefined;
|
|
212
|
+
getAction(sectionSegment: string, journey: import("../journey/journey.js").Journey, answer: unknown): import("#typedefs/question-types.d.ts").ActionView | import("#typedefs/question-types.d.ts").ActionView[] | undefined;
|
|
247
213
|
/**
|
|
248
214
|
* @param {unknown} answer
|
|
249
215
|
* @returns {unknown}
|
|
@@ -265,16 +231,4 @@ export class Question {
|
|
|
265
231
|
*/
|
|
266
232
|
isAnswered(journeyResponse: import("../journey/journey-response.js").JourneyResponse, fieldName?: string): boolean;
|
|
267
233
|
}
|
|
268
|
-
export type PreppedQuestion = {
|
|
269
|
-
value: Object;
|
|
270
|
-
question: string;
|
|
271
|
-
fieldName: string;
|
|
272
|
-
pageTitle: string;
|
|
273
|
-
description?: string | undefined;
|
|
274
|
-
html?: string | undefined;
|
|
275
|
-
};
|
|
276
|
-
export type QuestionViewModel = Record<string, any>;
|
|
277
|
-
import type { BaseValidator } from "#base-validator";
|
|
278
|
-
import type { ActionLink } from "./question-types.js";
|
|
279
|
-
import type { ActionView } from "../controller.js";
|
|
280
234
|
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"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"}
|
|
@@ -3,35 +3,6 @@ import { capitalize, nl2br, trimTrailingSlash } from '../lib/utils.js';
|
|
|
3
3
|
import MultiFieldInputValidator from '../validator/multi-field-input-validator.js';
|
|
4
4
|
import { answerObjectForManageList } from '#src/components/manage-list/utils.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @import {BaseValidator} from "#base-validator"
|
|
8
|
-
* @import {ActionView} from "../controller.js"
|
|
9
|
-
* @import {ActionLink} from "./question-types.js"
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Object} PreppedQuestion
|
|
14
|
-
* @property {Object} value
|
|
15
|
-
* @property {string} question
|
|
16
|
-
* @property {string} fieldName
|
|
17
|
-
* @property {string} pageTitle
|
|
18
|
-
* @property {string} [description]
|
|
19
|
-
* @property {string} [html]
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {Record<string, any>} QuestionViewModel
|
|
24
|
-
* @property {PreppedQuestion} question
|
|
25
|
-
* @property {string} layoutTemplate
|
|
26
|
-
* @property {string} pageCaption
|
|
27
|
-
* @property {string} [continueButtonText]
|
|
28
|
-
* @property {string} backLink
|
|
29
|
-
* @property {boolean} showBackToListLink
|
|
30
|
-
* @property {string} listLink
|
|
31
|
-
* @property {Object} util
|
|
32
|
-
* @property {function(string): string} util.trimTrailingSlash
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
6
|
/**
|
|
36
7
|
* A specific question within a journey which is made up of one (usually) or many (sometimes) components and their required content.
|
|
37
8
|
* @class
|
|
@@ -51,7 +22,7 @@ export class Question {
|
|
|
51
22
|
fieldName;
|
|
52
23
|
/** @type {boolean} if the question should appear in the journey overview task list or not */
|
|
53
24
|
taskList = true;
|
|
54
|
-
/** @type {Array.<BaseValidator>} array of validators that a question uses to validate answers */
|
|
25
|
+
/** @type {Array.<import('../validator/base-validator.js').BaseValidator>} array of validators that a question uses to validate answers */
|
|
55
26
|
validators = [];
|
|
56
27
|
/** @type {string|undefined} hint text displayed to user */
|
|
57
28
|
hint;
|
|
@@ -63,7 +34,7 @@ export class Question {
|
|
|
63
34
|
html;
|
|
64
35
|
/** @type {string|undefined} optional question type */
|
|
65
36
|
interfaceType;
|
|
66
|
-
/** @type {ActionLink|undefined} override action link */
|
|
37
|
+
/** @type {import('#typedefs/question-types.d.ts').ActionLink|undefined} override action link */
|
|
67
38
|
actionLink;
|
|
68
39
|
|
|
69
40
|
/** @type {string} 'not started' text to display (if a question has no answer) */
|
|
@@ -81,7 +52,8 @@ export class Question {
|
|
|
81
52
|
* @param {import('../journey/journey-response.js').JourneyResponse} [response]
|
|
82
53
|
* @returns {boolean}
|
|
83
54
|
*/
|
|
84
|
-
|
|
55
|
+
// eslint-disable-next-line no-unused-vars -- response will be used by extending classes
|
|
56
|
+
shouldDisplay = (response) => true;
|
|
85
57
|
|
|
86
58
|
details = {
|
|
87
59
|
title: '',
|
|
@@ -97,7 +69,7 @@ export class Question {
|
|
|
97
69
|
_isInManageListSection = false;
|
|
98
70
|
|
|
99
71
|
/**
|
|
100
|
-
* @param {import('
|
|
72
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionParameters} params
|
|
101
73
|
* @param {Record<string, Function>} [methodOverrides]
|
|
102
74
|
*/
|
|
103
75
|
constructor(
|
|
@@ -199,13 +171,13 @@ export class Question {
|
|
|
199
171
|
* that prepQuestionForRendering doesn't need
|
|
200
172
|
*
|
|
201
173
|
* @param {Object} options
|
|
202
|
-
* @param {import('
|
|
174
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} options.params
|
|
203
175
|
* @param {import('../components/manage-list/question.js')} [options.manageListQuestion]
|
|
204
176
|
* @param {import('../section.js').Section} options.section - the current section
|
|
205
177
|
* @param {import('../journey/journey.js').Journey} options.journey - the journey we are in
|
|
206
178
|
* @param {Record<string, unknown>} [options.customViewData] additional data to send to view
|
|
207
179
|
* @param {unknown} [options.payload]
|
|
208
|
-
* @returns {QuestionViewModel}
|
|
180
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel}
|
|
209
181
|
*/
|
|
210
182
|
toViewModel({ params, manageListQuestion, section, journey, customViewData, payload }) {
|
|
211
183
|
const viewModel = this.prepQuestionForRendering(section, journey, customViewData, payload, {
|
|
@@ -223,8 +195,8 @@ export class Question {
|
|
|
223
195
|
* @param {import('../journey/journey.js').Journey} journey - the journey we are in
|
|
224
196
|
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
225
197
|
* @param {unknown} [payload]
|
|
226
|
-
* @param {import('
|
|
227
|
-
* @returns {QuestionViewModel}
|
|
198
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} [options] - required to support manage list question
|
|
199
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel}
|
|
228
200
|
*/
|
|
229
201
|
prepQuestionForRendering(section, journey, customViewData, payload, options) {
|
|
230
202
|
const answers = payload || this.answerObjectFromJourneyResponse(journey.response, options);
|
|
@@ -283,7 +255,7 @@ export class Question {
|
|
|
283
255
|
*
|
|
284
256
|
* If possible override this method instead of prepQuestionForRendering for simple changes to the view model
|
|
285
257
|
*
|
|
286
|
-
* @param {QuestionViewModel} viewModel
|
|
258
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
287
259
|
*/ // eslint-disable-next-line no-unused-vars
|
|
288
260
|
addCustomDataToViewModel(viewModel) {}
|
|
289
261
|
|
|
@@ -291,7 +263,7 @@ export class Question {
|
|
|
291
263
|
* Get the answers object from the journey response, which may be nested in an array for manage list questions
|
|
292
264
|
*
|
|
293
265
|
* @param {import('../journey/journey-response.js').JourneyResponse} response
|
|
294
|
-
* @param {import('
|
|
266
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} [options]
|
|
295
267
|
* @returns {Record<string, any>}
|
|
296
268
|
*/
|
|
297
269
|
answerObjectFromJourneyResponse(response, { params, manageListQuestion } = {}) {
|
|
@@ -311,7 +283,7 @@ export class Question {
|
|
|
311
283
|
/**
|
|
312
284
|
* renders the question
|
|
313
285
|
* @param {import('express').Response} res - the express response
|
|
314
|
-
* @param {QuestionViewModel} viewModel additional data to send to view
|
|
286
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel additional data to send to view
|
|
315
287
|
* @returns {void}
|
|
316
288
|
*/
|
|
317
289
|
renderAction(res, viewModel) {
|
|
@@ -329,7 +301,7 @@ export class Question {
|
|
|
329
301
|
* @param {import('../journey/journey.js').Journey} journey
|
|
330
302
|
* @param {import('../section.js').Section} section
|
|
331
303
|
* @param {import('../components/manage-list/question.js')} [manageListQuestion]
|
|
332
|
-
* @returns {QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
304
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
333
305
|
*/
|
|
334
306
|
checkForValidationErrors(req, section, journey, manageListQuestion) {
|
|
335
307
|
const { body = {} } = req;
|
|
@@ -376,7 +348,7 @@ export class Question {
|
|
|
376
348
|
* @param {import('express').Request} req
|
|
377
349
|
* @param {import('../journey/journey.js').Journey} journey
|
|
378
350
|
* @param {import('../section.js').Section} sectionObj
|
|
379
|
-
* @returns {QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
351
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
380
352
|
*/ //eslint-disable-next-line no-unused-vars
|
|
381
353
|
checkForSavingErrors(req, sectionObj, journey) {
|
|
382
354
|
return;
|
|
@@ -401,14 +373,10 @@ export class Question {
|
|
|
401
373
|
|
|
402
374
|
/**
|
|
403
375
|
* returns the formatted answers values to be used to build task list elements
|
|
404
|
-
* @param {
|
|
376
|
+
* @param {string} sectionSegment
|
|
405
377
|
* @param {import('../journey/journey.js').Journey} journey
|
|
406
378
|
* @param {unknown} answer
|
|
407
|
-
* @returns {
|
|
408
|
-
* key: string;
|
|
409
|
-
* value: string | Object;
|
|
410
|
-
* action?: ActionView | ActionView[];
|
|
411
|
-
* }>}
|
|
379
|
+
* @returns {import('#typedefs/question-types.d.ts').SummaryRow[]}
|
|
412
380
|
*/
|
|
413
381
|
formatAnswerForSummary(sectionSegment, journey, answer, capitals = true) {
|
|
414
382
|
const formattedAnswer = capitals ? capitalize(answer ?? this.notStartedText) : (answer ?? this.notStartedText);
|
|
@@ -425,10 +393,10 @@ export class Question {
|
|
|
425
393
|
|
|
426
394
|
/**
|
|
427
395
|
* Returns the action link for the question
|
|
428
|
-
* @param {
|
|
396
|
+
* @param {string} sectionSegment
|
|
429
397
|
* @param {import('../journey/journey.js').Journey} journey
|
|
430
|
-
* @param {
|
|
431
|
-
* @returns {ActionView|ActionView[]|undefined}
|
|
398
|
+
* @param {unknown} answer
|
|
399
|
+
* @returns {import('#typedefs/question-types.d.ts').ActionView | import('#typedefs/question-types.d.ts').ActionView[] | undefined}
|
|
432
400
|
*/
|
|
433
401
|
getAction(sectionSegment, journey, answer) {
|
|
434
402
|
if (this.actionLink) {
|