@planning-inspectorate/dynamic-forms 3.15.6 → 3.17.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 +123 -4
- package/package.json +6 -4
- package/{types/src → src}/components/address/question.d.ts +6 -2
- package/src/components/address/question.d.ts.map +1 -0
- package/src/components/address/question.js +7 -19
- 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 +9 -0
- package/src/components/checkbox/question.d.ts.map +1 -0
- package/src/components/checkbox/question.js +37 -54
- package/src/components/checkbox/question.test.js +170 -27
- package/{types/src → src}/components/date/question.d.ts +2 -2
- package/src/components/date/question.d.ts.map +1 -0
- package/src/components/date/question.js +7 -16
- package/{types/src → src}/components/date-period/question.d.ts +12 -4
- package/src/components/date-period/question.d.ts.map +1 -0
- package/src/components/date-period/question.js +2 -3
- package/{types/src → src}/components/date-time/question.d.ts +2 -2
- package/src/components/date-time/question.d.ts.map +1 -0
- package/src/components/date-time/question.js +5 -14
- 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/answer-summary-list.njk +1 -1
- 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 +6 -3
- package/src/components/manage-list/question.d.ts.map +1 -0
- package/src/components/manage-list/question.js +5 -2
- 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/src/components/number-entry/question.d.ts +12 -0
- package/src/components/number-entry/question.d.ts.map +1 -0
- package/src/components/number-entry/question.js +4 -22
- package/src/components/radio/question.d.ts +11 -0
- package/src/components/radio/question.d.ts.map +1 -0
- package/src/components/radio/question.js +30 -51
- package/src/components/radio/question.test.js +139 -60
- package/src/components/select/question.d.ts +12 -0
- package/src/components/select/question.d.ts.map +1 -0
- package/src/components/select/question.js +5 -48
- package/{types/src → src}/components/single-line-input/question.d.ts +2 -2
- package/src/components/single-line-input/question.d.ts.map +1 -0
- package/src/components/single-line-input/question.js +2 -2
- package/{types/src → src}/components/text-entry/question.d.ts +3 -3
- package/src/components/text-entry/question.d.ts.map +1 -0
- package/src/components/text-entry/question.js +2 -2
- package/{types/src → src}/components/text-entry-redact/question.d.ts +8 -9
- package/src/components/text-entry-redact/question.d.ts.map +1 -0
- package/src/components/text-entry-redact/question.js +5 -2
- 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-has-answer.js +1 -1
- package/src/components/utils/question-utils.d.ts +33 -0
- package/src/components/utils/question-utils.d.ts.map +1 -0
- package/src/components/utils/question-utils.js +31 -2
- package/src/components/utils/question-utils.test.js +89 -2
- 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 +3 -3
- 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 +29 -4
- package/src/questions/options-question.test.js +106 -0
- package/{types/src → src}/questions/question.d.ts +48 -79
- package/src/questions/question.d.ts.map +1 -0
- package/src/questions/question.js +83 -60
- package/src/questions/question.test.js +86 -0
- 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/journey.js +2 -0
- package/test/questions.js +51 -1
- package/test/secondary-actions.test.js +1 -1
- package/test/snapshots/check-your-answers-not-started.html +22 -0
- package/test/snapshots/check-your-answers-with-answers.html +22 -0
- package/test/snapshots/favourite-activity-reason.html +54 -0
- package/test/snapshots/travel-requirements.html +48 -0
- package/test/utils/question-test-utils.js +36 -6
- package/tsconfig.json +11 -4
- package/{types/src/questions → typedefs}/question-props.d.ts +28 -26
- package/typedefs/question-types.d.ts +141 -0
- package/{src → typedefs}/section-types.d.ts +1 -1
- package/typedefs/section-types.js +1 -0
- package/move-types.js +0 -12
- package/src/questions/question-props.d.ts +0 -295
- package/src/questions/question-types.d.ts +0 -86
- 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/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 +0 -36
- 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 +0 -22
- package/types/src/components/select/question.d.ts.map +0 -1
- 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 +0 -15
- 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 -18
- 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.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}/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
|
@@ -8,7 +8,7 @@ const DEFAULT_DATE_FORMAT = 'd MMMM yyyy';
|
|
|
8
8
|
*/
|
|
9
9
|
export class DateQuestion extends Question {
|
|
10
10
|
/**
|
|
11
|
-
* @param {import('
|
|
11
|
+
* @param {import('#typedefs/question-props.d.ts').DateQuestionParams} params
|
|
12
12
|
*/
|
|
13
13
|
constructor({ dateFormat = DEFAULT_DATE_FORMAT, ...parentParams }) {
|
|
14
14
|
super({
|
|
@@ -71,22 +71,13 @@ export class DateQuestion extends Question {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
74
|
+
* Formats a date answer for display in the summary.
|
|
75
|
+
* @param {unknown} answer - the date value
|
|
76
|
+
* @returns {string} the formatted date
|
|
76
77
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (answer) {
|
|
81
|
-
formattedAnswer = formatDateForDisplay(answer, { format: this.dateFormat });
|
|
82
|
-
} else {
|
|
83
|
-
formattedAnswer = this.notStartedText;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const action = this.getAction(sectionSegment, journey, answer);
|
|
87
|
-
const key = this.title ?? this.question;
|
|
88
|
-
|
|
89
|
-
return [{ key: key, value: formattedAnswer, action: action }];
|
|
78
|
+
formatAnswer(answer) {
|
|
79
|
+
if (!answer) return this.notStartedText;
|
|
80
|
+
return formatDateForDisplay(answer, { format: this.dateFormat });
|
|
90
81
|
}
|
|
91
82
|
}
|
|
92
83
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export class DatePeriodQuestion extends Question {
|
|
6
6
|
/**
|
|
7
|
-
* @param {import('
|
|
7
|
+
* @param {import('#typedefs/question-props.d.ts').DatePeriodQuestionParams} params
|
|
8
8
|
*/
|
|
9
|
-
constructor({ dateFormat, hint, labels, hintStart, startTime, hintEnd, endTime, ...parentParams }: import("
|
|
9
|
+
constructor({ dateFormat, hint, labels, hintStart, startTime, hintEnd, endTime, ...parentParams }: import("#typedefs/question-props.d.ts").DatePeriodQuestionParams);
|
|
10
10
|
dateFormat: string;
|
|
11
11
|
labels: {
|
|
12
12
|
start: string;
|
|
@@ -14,8 +14,8 @@ export class DatePeriodQuestion extends Question {
|
|
|
14
14
|
};
|
|
15
15
|
hintStart: string | undefined;
|
|
16
16
|
hintEnd: string | undefined;
|
|
17
|
-
startTime: import("
|
|
18
|
-
endTime: import("
|
|
17
|
+
startTime: import("#typedefs/question-props.d.ts").TimeComponents;
|
|
18
|
+
endTime: import("#typedefs/question-props.d.ts").TimeComponents;
|
|
19
19
|
/**
|
|
20
20
|
* Get the data to save from the request, returns an object of answers
|
|
21
21
|
* @param {import('express').Request} req
|
|
@@ -25,6 +25,14 @@ export class DatePeriodQuestion extends Question {
|
|
|
25
25
|
answerForViewModel(answers: any, isPayload: any): {
|
|
26
26
|
[x: string]: any;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* returns the formatted answers values to be used to build task list elements
|
|
30
|
+
*/
|
|
31
|
+
formatAnswerForSummary(sectionSegment: any, journey: any, answer: any): {
|
|
32
|
+
key: string;
|
|
33
|
+
value: string;
|
|
34
|
+
action: import("#typedefs/question-types.d.ts").ActionView | import("#typedefs/question-types.d.ts").ActionView[] | undefined;
|
|
35
|
+
}[];
|
|
28
36
|
}
|
|
29
37
|
export default DatePeriodQuestion;
|
|
30
38
|
import { Question } from '#question';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;OAEG;IACH,mGAFW,OAAO,+BAA+B,EAAE,wBAAwB,EAuB1E;IAPA,mBAA4B;IAC5B;;;MAAsD;IAEtD,8BAA0B;IAC1B,4BAAsB;IACtB,kEAA+D;IAC/D,gEAA2D;IAkB5D;;;;;OAKG,CACH,mBAJW,OAAO,SAAS,EAAE,OAAO,mBACzB,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAgC5B;IAED;;MAuCC;IAWD;;OAEG;IACH;;;;QAyBC;CACD;;yBAzKwB,WAAW"}
|
|
@@ -11,7 +11,7 @@ const DEFAULT_DATE_FORMAT = 'HH:mm d MMMM yyyy';
|
|
|
11
11
|
*/
|
|
12
12
|
export class DatePeriodQuestion extends Question {
|
|
13
13
|
/**
|
|
14
|
-
* @param {import('
|
|
14
|
+
* @param {import('#typedefs/question-props.d.ts').DatePeriodQuestionParams} params
|
|
15
15
|
*/
|
|
16
16
|
constructor({
|
|
17
17
|
dateFormat = DEFAULT_DATE_FORMAT,
|
|
@@ -131,7 +131,7 @@ export class DatePeriodQuestion extends Question {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
* @param {import('#question').QuestionViewModel} viewModel
|
|
134
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
135
135
|
*/
|
|
136
136
|
addCustomDataToViewModel(viewModel) {
|
|
137
137
|
viewModel.labels = this.labels;
|
|
@@ -141,7 +141,6 @@ export class DatePeriodQuestion extends Question {
|
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* returns the formatted answers values to be used to build task list elements
|
|
144
|
-
* @type {Question['formatAnswerForSummary']}
|
|
145
144
|
*/
|
|
146
145
|
formatAnswerForSummary(sectionSegment, journey, answer) {
|
|
147
146
|
let formattedAnswer;
|
|
@@ -2,9 +2,9 @@ export class DateTimeQuestion extends Question {
|
|
|
2
2
|
static AM: string;
|
|
3
3
|
static PM: string;
|
|
4
4
|
/**
|
|
5
|
-
* @param {import('
|
|
5
|
+
* @param {import('#typedefs/question-props.d.ts').DateTimeQuestionParams} params
|
|
6
6
|
*/
|
|
7
|
-
constructor({ dateFormat, timeFormat, ...parentParams }: import("
|
|
7
|
+
constructor({ dateFormat, timeFormat, ...parentParams }: import("#typedefs/question-props.d.ts").DateTimeQuestionParams);
|
|
8
8
|
dateFormat: string;
|
|
9
9
|
timeFormat: string;
|
|
10
10
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAMA;IACC,kBAAiB;IACjB,kBAAiB;IAEjB;;OAEG;IACH,yDAFW,OAAO,+BAA+B,EAAE,sBAAsB,EASxE;IAFA,mBAA4B;IAC5B,mBAA4B;IAkB7B;;;;;OAKG,CACH,mBAJW,OAAO,SAAS,EAAE,OAAO,mBACzB,eAAe,GACb,OAAO,CAAE,MAAM,CAAC,CAqB5B;IAED;;MAqCC;;CA2BD;;yBAhIwB,6BAA6B"}
|
|
@@ -9,7 +9,7 @@ export class DateTimeQuestion extends Question {
|
|
|
9
9
|
static PM = 'pm';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @param {import('
|
|
12
|
+
* @param {import('#typedefs/question-props.d.ts').DateTimeQuestionParams} params
|
|
13
13
|
*/
|
|
14
14
|
constructor({ dateFormat = DEFAULT_DATE_FORMAT, timeFormat = DEFAULT_TIME_FORMAT, ...parentParams }) {
|
|
15
15
|
super({
|
|
@@ -102,20 +102,11 @@ export class DateTimeQuestion extends Question {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
105
|
+
* Formats a date-time answer for display in the summary.
|
|
106
|
+
* @param {unknown} answer - the date value
|
|
107
|
+
* @returns {string} the formatted date and time
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
-
return [
|
|
110
|
-
{
|
|
111
|
-
key: this.title,
|
|
112
|
-
value: this.#formatDateTimeValue(answer),
|
|
113
|
-
action: this.getAction(sectionSegment, journey, answer)
|
|
114
|
-
}
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
#formatDateTimeValue(answer) {
|
|
109
|
+
formatAnswer(answer) {
|
|
119
110
|
if (!answer) return this.notStartedText;
|
|
120
111
|
|
|
121
112
|
const formattedDate = formatDateForDisplay(answer, { format: this.dateFormat });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email input question that extends SingleLineInputQuestion
|
|
3
|
+
* Automatically sets the input type to "email" and adds appropriate attributes
|
|
4
|
+
* @class
|
|
5
|
+
*/
|
|
6
|
+
export class EmailQuestion extends SingleLineInputQuestion {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('#typedefs/question-props.d.ts').EmailQuestionParams} params
|
|
9
|
+
*/
|
|
10
|
+
constructor(params: import("#typedefs/question-props.d.ts").EmailQuestionParams);
|
|
11
|
+
/**
|
|
12
|
+
* Override formatAnswerForSummary to prevent capitalization of email addresses
|
|
13
|
+
* Email addresses should remain in their original case (typically lowercase)
|
|
14
|
+
* @param {string} sectionSegment
|
|
15
|
+
* @param {import('#journey').Journey} journey
|
|
16
|
+
* @param {string} answer
|
|
17
|
+
* @returns {Array}
|
|
18
|
+
*/
|
|
19
|
+
formatAnswerForSummary(sectionSegment: string, journey: import("#journey").Journey, answer: string): any[];
|
|
20
|
+
}
|
|
21
|
+
export default EmailQuestion;
|
|
22
|
+
import SingleLineInputQuestion from '../single-line-input/question.js';
|
|
23
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH;IACC;;OAEG;IACH,oBAFW,OAAO,+BAA+B,EAAE,mBAAmB,EAmBrE;IAED;;;;;;;OAOG;IACH,uCALW,MAAM,WACN,OAAO,UAAU,EAAE,OAAO,UAC1B,MAAM,SAMhB;CACD;;oCA1CmC,kCAAkC"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import SingleLineInputQuestion from '../single-line-input/question.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {import('#question').QuestionViewModel} QuestionViewModel
|
|
5
|
-
* @typedef {import('#journey').Journey} Journey
|
|
6
|
-
* @typedef {import('#journey-response').JourneyResponse} JourneyResponse
|
|
7
|
-
* @typedef {import('../../section').Section} Section
|
|
8
|
-
* @typedef {import('../../validator/base-validator')} BaseValidator
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
3
|
/**
|
|
12
4
|
* Email input question that extends SingleLineInputQuestion
|
|
13
5
|
* Automatically sets the input type to "email" and adds appropriate attributes
|
|
@@ -15,7 +7,7 @@ import SingleLineInputQuestion from '../single-line-input/question.js';
|
|
|
15
7
|
*/
|
|
16
8
|
export class EmailQuestion extends SingleLineInputQuestion {
|
|
17
9
|
/**
|
|
18
|
-
* @param {import('
|
|
10
|
+
* @param {import('#typedefs/question-props.d.ts').EmailQuestionParams} params
|
|
19
11
|
*/
|
|
20
12
|
constructor(params) {
|
|
21
13
|
// Set default input attributes for email
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-list-actions.d.ts","sourceRoot":"","sources":["manage-list-actions.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,kCAFU,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC,CAM5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-list-section.d.ts","sourceRoot":"","sources":["manage-list-section.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACC,cAEC;IAED;;;;;;OAMG;IACH,2BAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,sBAJW,OAAO,6BAA6B,EAAE,QAAQ,sBAC9C,OAAO,0BAA0B,EAAE,iBAAiB,GAClD,IAAI,CAYhB;CACD;wBAtCuB,kBAAkB"}
|
|
@@ -7,19 +7,22 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export class ManageListQuestion extends Question {
|
|
9
9
|
/**
|
|
10
|
-
* @param {import('
|
|
10
|
+
* @param {import('#typedefs/question-props.d.ts').ManageListQuestionParams} params
|
|
11
11
|
*/
|
|
12
|
-
constructor(params: import("
|
|
12
|
+
constructor(params: import("#typedefs/question-props.d.ts").ManageListQuestionParams);
|
|
13
13
|
get confirmationQuestionParam(): string;
|
|
14
14
|
getDataToSave(req: any, journeyResponse: any): Promise<{
|
|
15
15
|
answers: {
|
|
16
16
|
[x: string]: any;
|
|
17
17
|
};
|
|
18
18
|
}>;
|
|
19
|
+
/**
|
|
20
|
+
* returns the formatted answers values to be used to build task list elements
|
|
21
|
+
*/
|
|
19
22
|
formatAnswerForSummary(sectionSegment: any, journey: any, answer: any): {
|
|
20
23
|
key: string;
|
|
21
24
|
value: string;
|
|
22
|
-
action: import("
|
|
25
|
+
action: import("#typedefs/question-types.d.ts").ActionView | import("#typedefs/question-types.d.ts").ActionView[] | undefined;
|
|
23
26
|
}[];
|
|
24
27
|
renderConfirmationAction(res: any, itemToRemove: any, viewModel: any): void;
|
|
25
28
|
set section(section: import("../../section.js").Section);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IAOC;;OAEG;IACH,oBAFW,OAAO,+BAA+B,EAAE,wBAAwB,EAe1E;IAcD,wCAEC;IAyDD;;;;OAMC;IAED;;OAEG;IACH;;;;QAsBC;IAED,4EAQC;IAoCD,yDAEC;IATD,kDAKC;;CAKD;;;;;;mBAxLa,MAAM;;;;;;;;;;;;;;yBAPK,WAAW"}
|
|
@@ -19,7 +19,7 @@ export class ManageListQuestion extends Question {
|
|
|
19
19
|
#confirmationQuestionParam;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* @param {import('
|
|
22
|
+
* @param {import('#typedefs/question-props.d.ts').ManageListQuestionParams} params
|
|
23
23
|
*/
|
|
24
24
|
constructor(params) {
|
|
25
25
|
super({
|
|
@@ -53,7 +53,7 @@ export class ManageListQuestion extends Question {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* @param {import('#question').QuestionViewModel} viewModel
|
|
56
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
57
57
|
*/
|
|
58
58
|
addCustomDataToViewModel(viewModel) {
|
|
59
59
|
viewModel.question.addAnotherLink = this.#addAnotherLink;
|
|
@@ -115,6 +115,9 @@ export class ManageListQuestion extends Question {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* returns the formatted answers values to be used to build task list elements
|
|
120
|
+
*/
|
|
118
121
|
formatAnswerForSummary(sectionSegment, journey, answer) {
|
|
119
122
|
let formattedAnswer = this.notStartedText;
|
|
120
123
|
if (answer && Array.isArray(answer)) {
|
|
@@ -11,8 +11,8 @@ export function answerObjectForManageList(response: import("../../journey/journe
|
|
|
11
11
|
*
|
|
12
12
|
* @param {import('../../journey/journey-response.js').JourneyResponse} response
|
|
13
13
|
* @param {import('./question.js')} manageListQuestion
|
|
14
|
-
* @param {import('
|
|
15
|
-
* @returns {import('
|
|
14
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
15
|
+
* @returns {import('#typedefs/journey-types.d.ts').ManageListAnswers}
|
|
16
16
|
*/
|
|
17
|
-
export function answerObjectForManageListSaving(response: import("../../journey/journey-response.js").JourneyResponse, manageListQuestion: typeof import("./question.js"), params: import("
|
|
17
|
+
export function answerObjectForManageListSaving(response: import("../../journey/journey-response.js").JourneyResponse, manageListQuestion: typeof import("./question.js"), params: import("#typedefs/journey-types.d.ts").RouteParams): import("#typedefs/journey-types.d.ts").ManageListAnswers;
|
|
18
18
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oDALW,OAAO,mCAAmC,EAAE,eAAe,wEAE3D,MAAM,GACJ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQnC;AAED;;;;;;;GAOG;AACH,0DALW,OAAO,mCAAmC,EAAE,eAAe,8DAE3D,OAAO,8BAA8B,EAAE,WAAW,GAChD,OAAO,8BAA8B,EAAE,iBAAiB,CAapE"}
|
|
@@ -18,8 +18,8 @@ export function answerObjectForManageList(response, manageListQuestion, manageLi
|
|
|
18
18
|
*
|
|
19
19
|
* @param {import('../../journey/journey-response.js').JourneyResponse} response
|
|
20
20
|
* @param {import('./question.js')} manageListQuestion
|
|
21
|
-
* @param {import('
|
|
22
|
-
* @returns {import('
|
|
21
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
22
|
+
* @returns {import('#typedefs/journey-types.d.ts').ManageListAnswers}
|
|
23
23
|
*/
|
|
24
24
|
export function answerObjectForManageListSaving(response, manageListQuestion, params) {
|
|
25
25
|
const answersList =
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export class MultiFieldInputQuestion extends Question {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('#typedefs/question-props.d.ts').MultiFieldInputQuestionParams} params
|
|
7
|
+
*/
|
|
8
|
+
constructor({ inputFields, ...parentParams }: import("#typedefs/question-props.d.ts").MultiFieldInputQuestionParams);
|
|
9
|
+
inputFields: import("#typedefs/question-props.d.ts").InputField[];
|
|
10
|
+
answerForViewModel(answers: any): {
|
|
11
|
+
value: string;
|
|
12
|
+
fieldName: string;
|
|
13
|
+
label: string;
|
|
14
|
+
formatJoinString?: string;
|
|
15
|
+
formatPrefix?: string;
|
|
16
|
+
formatTextFunction?: (text: string) => string;
|
|
17
|
+
attributes?: Record<string, string>;
|
|
18
|
+
suffix?: import("#typedefs/question-props.d.ts").Affix;
|
|
19
|
+
prefix?: import("#typedefs/question-props.d.ts").Affix;
|
|
20
|
+
hint?: string;
|
|
21
|
+
classes?: string;
|
|
22
|
+
inputmode?: "decimal" | "numeric";
|
|
23
|
+
pattern?: string;
|
|
24
|
+
}[];
|
|
25
|
+
/**
|
|
26
|
+
* returns the formatted answers values to be used to build task list elements
|
|
27
|
+
* @param {import('#journey').Journey} journey
|
|
28
|
+
* @param {string} sectionSegment
|
|
29
|
+
* @returns {Array<{
|
|
30
|
+
* key: string;
|
|
31
|
+
* value: string | Object;
|
|
32
|
+
* action: {
|
|
33
|
+
* href: string;
|
|
34
|
+
* text: string;
|
|
35
|
+
* visuallyHiddenText: string;
|
|
36
|
+
* };
|
|
37
|
+
* }>}
|
|
38
|
+
*/
|
|
39
|
+
formatAnswerForSummary(sectionSegment: string, journey: import("#journey").Journey): Array<{
|
|
40
|
+
key: string;
|
|
41
|
+
value: string | Object;
|
|
42
|
+
action: {
|
|
43
|
+
href: string;
|
|
44
|
+
text: string;
|
|
45
|
+
visuallyHiddenText: string;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
#private;
|
|
49
|
+
}
|
|
50
|
+
export default MultiFieldInputQuestion;
|
|
51
|
+
import { Question } from '#question';
|
|
52
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACC;;OAEG;IACH,8CAFW,OAAO,+BAA+B,EAAE,6BAA6B,EAa/E;IAJC,kEAA8B;IAchC;;;;;;;;;;;;;;QAOC;IAsBD;;;;;;;;;;;;;OAaG;IACH,uCAXW,MAAM,WADN,OAAO,UAAU,EAAE,OAAO,GAExB,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,kBAAkB,EAAE,MAAM,CAAC;SAC5B,CAAC;KACH,CAAC,CAkBJ;;CAyBD;;yBApHwB,WAAW"}
|
|
@@ -2,20 +2,12 @@ import { Question } from '#question';
|
|
|
2
2
|
import escape from 'escape-html';
|
|
3
3
|
import { nl2br } from '../../lib/utils.js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {import('#question').QuestionViewModel} QuestionViewModel
|
|
7
|
-
* @typedef {import('#journey').Journey} Journey
|
|
8
|
-
* @typedef {import('#journey-response').JourneyResponse} JourneyResponse
|
|
9
|
-
* @typedef {import('../../section').Section} Section
|
|
10
|
-
* @typedef {import('../../validator/base-validator')} BaseValidator
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
5
|
/**
|
|
14
6
|
* @class
|
|
15
7
|
*/
|
|
16
8
|
export class MultiFieldInputQuestion extends Question {
|
|
17
9
|
/**
|
|
18
|
-
* @param {import('
|
|
10
|
+
* @param {import('#typedefs/question-props.d.ts').MultiFieldInputQuestionParams} params
|
|
19
11
|
*/
|
|
20
12
|
constructor({ inputFields, ...parentParams }) {
|
|
21
13
|
super({
|
|
@@ -50,7 +42,7 @@ export class MultiFieldInputQuestion extends Question {
|
|
|
50
42
|
/**
|
|
51
43
|
* Get the data to save from the request, returns an object of answers
|
|
52
44
|
* @param {import('express').Request} req
|
|
53
|
-
* @param {JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
45
|
+
* @param {import('#journey-response').JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
54
46
|
* @returns {Promise<{ answers: Record<string, unknown> }>}
|
|
55
47
|
*/ //eslint-disable-next-line no-unused-vars -- journeyResponse kept for other questions to use
|
|
56
48
|
async getDataToSave(req, journeyResponse) {
|
|
@@ -69,8 +61,8 @@ export class MultiFieldInputQuestion extends Question {
|
|
|
69
61
|
|
|
70
62
|
/**
|
|
71
63
|
* returns the formatted answers values to be used to build task list elements
|
|
72
|
-
* @param {Journey} journey
|
|
73
|
-
* @param {
|
|
64
|
+
* @param {import('#journey').Journey} journey
|
|
65
|
+
* @param {string} sectionSegment
|
|
74
66
|
* @returns {Array<{
|
|
75
67
|
* key: string;
|
|
76
68
|
* value: string | Object;
|
|
@@ -101,7 +93,7 @@ export class MultiFieldInputQuestion extends Question {
|
|
|
101
93
|
|
|
102
94
|
/**
|
|
103
95
|
* checks whether any answers have been provided for input field questions
|
|
104
|
-
* @param {Journey} journey
|
|
96
|
+
* @param {import('#journey').Journey} journey
|
|
105
97
|
* @returns {boolean}
|
|
106
98
|
*/
|
|
107
99
|
#allQuestionsUnanswered(journey) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class NumberEntryQuestion extends Question {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import('#typedefs/question-props.d.ts').NumberEntryQuestionParams} params
|
|
4
|
+
*/
|
|
5
|
+
constructor({ label, suffix, ...parentParams }: import("#typedefs/question-props.d.ts").NumberEntryQuestionParams);
|
|
6
|
+
suffix: string | undefined;
|
|
7
|
+
label: string | undefined;
|
|
8
|
+
answerForViewModel(answers: any): string | number;
|
|
9
|
+
}
|
|
10
|
+
export default NumberEntryQuestion;
|
|
11
|
+
import { Question } from '#question';
|
|
12
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAGA;IACC;;OAEG;IACH,gDAFW,OAAO,+BAA+B,EAAE,yBAAyB,EAW3E;IAFA,2BAAoB;IACpB,0BAAkB;IAGnB,kDAEC;CASD;;yBA7BwB,WAAW"}
|
|
@@ -3,12 +3,13 @@ import { getPersistedNumberAnswer } from '../utils/persisted-number-answer.js';
|
|
|
3
3
|
|
|
4
4
|
export class NumberEntryQuestion extends Question {
|
|
5
5
|
/**
|
|
6
|
-
* @param {import('
|
|
6
|
+
* @param {import('#typedefs/question-props.d.ts').NumberEntryQuestionParams} params
|
|
7
7
|
*/
|
|
8
8
|
constructor({ label, suffix, ...parentParams }) {
|
|
9
9
|
super({
|
|
10
10
|
...parentParams,
|
|
11
|
-
viewFolder: 'number-entry'
|
|
11
|
+
viewFolder: 'number-entry',
|
|
12
|
+
capitaliseAnswer: false
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
this.suffix = suffix;
|
|
@@ -20,31 +21,12 @@ export class NumberEntryQuestion extends Question {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* @param {import('#question').QuestionViewModel} viewModel
|
|
24
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
24
25
|
*/
|
|
25
26
|
addCustomDataToViewModel(viewModel) {
|
|
26
27
|
viewModel.question.label = this.label;
|
|
27
28
|
viewModel.question.suffix = this.suffix;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* returns the formatted answers values to be used to build task list elements
|
|
32
|
-
* @param {unknown} answer
|
|
33
|
-
* @param {import('#journey').Journey} journey
|
|
34
|
-
* @param {String} sectionSegment
|
|
35
|
-
* @returns {Array<{
|
|
36
|
-
* key: string;
|
|
37
|
-
* value: string | Object;
|
|
38
|
-
* action: {
|
|
39
|
-
* href: string;
|
|
40
|
-
* text: string;
|
|
41
|
-
* visuallyHiddenText: string;
|
|
42
|
-
* };
|
|
43
|
-
* }>}
|
|
44
|
-
*/
|
|
45
|
-
formatAnswerForSummary(sectionSegment, journey, answer) {
|
|
46
|
-
return super.formatAnswerForSummary(sectionSegment, journey, answer, false);
|
|
47
|
-
}
|
|
48
30
|
}
|
|
49
31
|
|
|
50
32
|
export default NumberEntryQuestion;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class RadioQuestion extends OptionsQuestion {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import('#typedefs/question-props.d.ts').RadioQuestionParams} params
|
|
4
|
+
*/
|
|
5
|
+
constructor({ label, html, legend, viewFolder, ...parentParams }: import("#typedefs/question-props.d.ts").RadioQuestionParams);
|
|
6
|
+
label: string | undefined;
|
|
7
|
+
legend: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export default RadioQuestion;
|
|
10
|
+
import OptionsQuestion from '../../questions/options-question.js';
|
|
11
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["question.js"],"names":[],"mappings":"AAGA;IACC;;OAEG;IACH,kEAFW,OAAO,+BAA+B,EAAE,mBAAmB,EAWrE;IAFA,0BAAkB;IAClB,2BAAoB;CAuCrB;;4BArD2B,qCAAqC"}
|
|
@@ -1,41 +1,14 @@
|
|
|
1
|
+
import escape from 'escape-html';
|
|
1
2
|
import OptionsQuestion from '../../questions/options-question.js';
|
|
2
3
|
|
|
3
4
|
export class RadioQuestion extends OptionsQuestion {
|
|
4
5
|
/**
|
|
5
|
-
* @param {import('
|
|
6
|
+
* @param {import('#typedefs/question-props.d.ts').RadioQuestionParams} params
|
|
6
7
|
*/
|
|
7
|
-
constructor({
|
|
8
|
-
title,
|
|
9
|
-
question,
|
|
10
|
-
fieldName,
|
|
11
|
-
viewFolder,
|
|
12
|
-
url,
|
|
13
|
-
hint,
|
|
14
|
-
pageTitle,
|
|
15
|
-
description,
|
|
16
|
-
label,
|
|
17
|
-
html,
|
|
18
|
-
legend,
|
|
19
|
-
options,
|
|
20
|
-
validators,
|
|
21
|
-
actionLink,
|
|
22
|
-
editable,
|
|
23
|
-
viewData
|
|
24
|
-
}) {
|
|
8
|
+
constructor({ label, html, legend, viewFolder, ...parentParams }) {
|
|
25
9
|
super({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
viewFolder: !viewFolder ? 'radio' : viewFolder,
|
|
29
|
-
fieldName,
|
|
30
|
-
url,
|
|
31
|
-
hint,
|
|
32
|
-
pageTitle,
|
|
33
|
-
description,
|
|
34
|
-
options,
|
|
35
|
-
validators,
|
|
36
|
-
actionLink,
|
|
37
|
-
editable,
|
|
38
|
-
viewData
|
|
10
|
+
...parentParams,
|
|
11
|
+
viewFolder: viewFolder || 'radio'
|
|
39
12
|
});
|
|
40
13
|
|
|
41
14
|
this.html = html;
|
|
@@ -44,7 +17,7 @@ export class RadioQuestion extends OptionsQuestion {
|
|
|
44
17
|
}
|
|
45
18
|
|
|
46
19
|
/**
|
|
47
|
-
* @param {import('#question').QuestionViewModel} viewModel
|
|
20
|
+
* @param {import('#typedefs/question-types.d.ts').QuestionViewModel} viewModel
|
|
48
21
|
*/
|
|
49
22
|
addCustomDataToViewModel(viewModel) {
|
|
50
23
|
viewModel.question.label = this.label;
|
|
@@ -52,26 +25,32 @@ export class RadioQuestion extends OptionsQuestion {
|
|
|
52
25
|
}
|
|
53
26
|
|
|
54
27
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @returns {
|
|
28
|
+
* Formats an answer value for display in the summary.
|
|
29
|
+
* Handles object answers with conditional fields (e.g. { value: 'yes', conditional: { yes: 'details' } })
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} answer - the raw answer value
|
|
32
|
+
* @returns {string} the formatted answer for display
|
|
60
33
|
*/
|
|
61
|
-
|
|
62
|
-
if (answer
|
|
63
|
-
|
|
64
|
-
const conditionalAnswerText = selectedOption.conditional?.label
|
|
65
|
-
? `${selectedOption.conditional.label} ${answer.conditional}`
|
|
66
|
-
: answer.conditional;
|
|
67
|
-
const formattedAnswer = [selectedOption.text, conditionalAnswerText].join('\n');
|
|
68
|
-
return super.formatAnswerForSummary(sectionSegment, journey, formattedAnswer, false);
|
|
69
|
-
} else if (answer) {
|
|
70
|
-
const selectedOption = this.options.find((option) => option.value === answer);
|
|
71
|
-
const selectedText = selectedOption?.text || '';
|
|
72
|
-
return super.formatAnswerForSummary(sectionSegment, journey, selectedText, false);
|
|
34
|
+
formatAnswer(answer) {
|
|
35
|
+
if (answer === null || answer === undefined || answer === '') {
|
|
36
|
+
return this.notStartedText;
|
|
73
37
|
}
|
|
74
|
-
|
|
38
|
+
|
|
39
|
+
// Handle simple string answers
|
|
40
|
+
if (typeof answer !== 'object' || answer.value === undefined) {
|
|
41
|
+
return super.formatAnswer(answer);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Handle object answers with conditional fields
|
|
45
|
+
const option = this.options.find((opt) => opt.value === answer.value);
|
|
46
|
+
const optionText = escape(option ? option.text : answer.value);
|
|
47
|
+
|
|
48
|
+
const conditionalValue = answer.conditional?.[answer.value];
|
|
49
|
+
if (conditionalValue) {
|
|
50
|
+
const label = option?.conditional?.label ? `${escape(option.conditional.label)} ` : '';
|
|
51
|
+
return `${optionText}<br>${label}${escape(conditionalValue)}`;
|
|
52
|
+
}
|
|
53
|
+
return optionText;
|
|
75
54
|
}
|
|
76
55
|
}
|
|
77
56
|
|