@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
|
@@ -34,8 +34,8 @@ describe('getConditionalAnswer', () => {
|
|
|
34
34
|
|
|
35
35
|
it('returns conditional field value when it exists', () => {
|
|
36
36
|
const { answers, question } = setup();
|
|
37
|
-
const expectedResult = 'test';
|
|
38
|
-
assert.
|
|
37
|
+
const expectedResult = { yes: 'test' };
|
|
38
|
+
assert.deepStrictEqual(getConditionalAnswer(answers, question, 'yes'), expectedResult);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('returns null when option chosen does not have conditional value', () => {
|
|
@@ -49,4 +49,91 @@ describe('getConditionalAnswer', () => {
|
|
|
49
49
|
delete question.options[0].conditional;
|
|
50
50
|
assert.strictEqual(getConditionalAnswer(answers, question, 'yes'), null);
|
|
51
51
|
});
|
|
52
|
+
|
|
53
|
+
it('returns null when answer is null', () => {
|
|
54
|
+
const { answers, question } = setup();
|
|
55
|
+
assert.strictEqual(getConditionalAnswer(answers, question, null), null);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('returns null when answer is empty string', () => {
|
|
59
|
+
const { answers, question } = setup();
|
|
60
|
+
assert.strictEqual(getConditionalAnswer(answers, question, ''), null);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('returns null when question has no options', () => {
|
|
64
|
+
const { answers, question } = setup();
|
|
65
|
+
delete question.options;
|
|
66
|
+
assert.strictEqual(getConditionalAnswer(answers, question, 'yes'), null);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('multi-value answers (checkboxes)', () => {
|
|
70
|
+
const setupMultiValue = () => {
|
|
71
|
+
const answers = {
|
|
72
|
+
field: 'a,b,c',
|
|
73
|
+
field_detailsA: 'details for A',
|
|
74
|
+
field_detailsC: 'details for C'
|
|
75
|
+
};
|
|
76
|
+
const question = {
|
|
77
|
+
fieldName: 'field',
|
|
78
|
+
options: [
|
|
79
|
+
{
|
|
80
|
+
value: 'a',
|
|
81
|
+
conditional: {
|
|
82
|
+
fieldName: 'detailsA'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
value: 'b'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: 'c',
|
|
90
|
+
conditional: {
|
|
91
|
+
fieldName: 'detailsC'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
return { answers, question };
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
it('returns object with conditional values for multiple selected options', () => {
|
|
100
|
+
const { answers, question } = setupMultiValue();
|
|
101
|
+
const result = getConditionalAnswer(answers, question, 'a,c');
|
|
102
|
+
assert.deepStrictEqual(result, {
|
|
103
|
+
a: 'details for A',
|
|
104
|
+
c: 'details for C'
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('returns object with only options that have conditional values', () => {
|
|
109
|
+
const { answers, question } = setupMultiValue();
|
|
110
|
+
const result = getConditionalAnswer(answers, question, 'a,b');
|
|
111
|
+
assert.deepStrictEqual(result, {
|
|
112
|
+
a: 'details for A'
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('returns null when no selected options have conditional values', () => {
|
|
117
|
+
const { answers, question } = setupMultiValue();
|
|
118
|
+
const result = getConditionalAnswer(answers, question, 'b');
|
|
119
|
+
assert.strictEqual(result, null);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('returns null when conditional fields have no values', () => {
|
|
123
|
+
const { answers, question } = setupMultiValue();
|
|
124
|
+
delete answers.field_detailsA;
|
|
125
|
+
delete answers.field_detailsC;
|
|
126
|
+
const result = getConditionalAnswer(answers, question, 'a,c');
|
|
127
|
+
assert.strictEqual(result, null);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('handles whitespace in comma-separated values', () => {
|
|
131
|
+
const { answers, question } = setupMultiValue();
|
|
132
|
+
const result = getConditionalAnswer(answers, question, 'a , c');
|
|
133
|
+
assert.deepStrictEqual(result, {
|
|
134
|
+
a: 'details for A',
|
|
135
|
+
c: 'details for C'
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
52
139
|
});
|
|
@@ -33,7 +33,7 @@ export function question(req: import("express-serve-static-core").Request<import
|
|
|
33
33
|
export function buildSave(saveData: SaveDataFn, redirectToTaskListOnSuccess?: boolean): import("express").Handler;
|
|
34
34
|
export type Journey = import("./journey/journey.js").Journey;
|
|
35
35
|
export type Question = import("./questions/question.js").Question;
|
|
36
|
-
export type Section =
|
|
36
|
+
export type Section = import("./section.js").Section;
|
|
37
37
|
export type SectionView = {
|
|
38
38
|
heading: string;
|
|
39
39
|
status: string;
|
|
@@ -51,14 +51,9 @@ export type RowView = {
|
|
|
51
51
|
html: string;
|
|
52
52
|
};
|
|
53
53
|
actions?: {
|
|
54
|
-
items: ActionView[];
|
|
54
|
+
items: import("#typedefs/question-types.d.ts").ActionView[];
|
|
55
55
|
} | undefined;
|
|
56
56
|
};
|
|
57
|
-
export type ActionView = {
|
|
58
|
-
href: string;
|
|
59
|
-
text: string;
|
|
60
|
-
visuallyHiddenText?: string | undefined;
|
|
61
|
-
};
|
|
62
57
|
export type SaveParams = {
|
|
63
58
|
req: import("express").Request;
|
|
64
59
|
res: import("express").Response;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["controller.js"],"names":[],"mappings":"AA+DA;;;GAGG;AACH,qCAHW,MAAM,GACJ,OAAO,SAAS,EAAE,OAAO,CAIrC;AAED;;;;;GAKG;AACH,0BALW,OAAO,SAAS,EAAE,OAAO,OACzB,OAAO,SAAS,EAAE,QAAQ,eAC1B,MAAM,YACN,MAAM,iBA8DhB;;AAmDD;;;;;;;;;;GAUG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,oCAJW,UAAU,gCACV,OAAO,GACL,OAAO,SAAS,EAAE,OAAO,CAsFrC;sBA7RY,OAAO,sBAAsB,EAAE,OAAO;uBACtC,OAAO,yBAAyB,EAAE,QAAQ;sBAC1C,OAAO,cAAc,EAAE,OAAO;;aAK7B,MAAM;YACN,MAAM;UAEjB;QAAiC,IAAI,EAA1B,KAAK,CAAE,OAAO,CAAC;KAC5B;;;SAIa;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;WAChB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;eAC1B,OAAO,+BAA+B,EAAE,UAAU,EAAE;;;;SAqK7D,OAAO,SAAS,EAAE,OAAO;SACzB,OAAO,SAAS,EAAE,QAAQ;eAC1B,MAAM;iBACN,MAAM;sBACN,OAAO;;;;;;;yBAOR,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC"}
|
package/src/controller.js
CHANGED
|
@@ -8,7 +8,7 @@ import { toArray } from '#src/lib/utils.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('./journey/journey.js').Journey} Journey
|
|
10
10
|
* @typedef {import('./questions/question.js').Question} Question
|
|
11
|
-
* @typedef {import('./section').Section} Section
|
|
11
|
+
* @typedef {import('./section.js').Section} Section
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -23,14 +23,7 @@ import { toArray } from '#src/lib/utils.js';
|
|
|
23
23
|
* @typedef {Object} RowView
|
|
24
24
|
* @property {{ text: string }} key
|
|
25
25
|
* @property {{ text: string } | { html: string }} value
|
|
26
|
-
* @property {{ items: ActionView[] }} [actions]
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {Object} ActionView
|
|
31
|
-
* @property {string} href
|
|
32
|
-
* @property {string} text
|
|
33
|
-
* @property {string} [visuallyHiddenText]
|
|
26
|
+
* @property {{ items: import('#typedefs/question-types.d.ts').ActionView[] }} [actions]
|
|
34
27
|
*/
|
|
35
28
|
|
|
36
29
|
/**
|
|
@@ -53,7 +46,7 @@ function buildSectionViewModel(name, status = '') {
|
|
|
53
46
|
* build a view model for a row in the journey overview
|
|
54
47
|
* @param {string} key
|
|
55
48
|
* @param {string} value
|
|
56
|
-
* @param {ActionView|ActionView[]} [action]
|
|
49
|
+
* @param {import('#typedefs/question-types.d.ts').ActionView|import('#typedefs/question-types.d.ts').ActionView[]} [action]
|
|
57
50
|
* @returns {RowView} a representation of a row
|
|
58
51
|
*/
|
|
59
52
|
function buildSectionRowViewModel(key, value, action) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export * from "../typedefs/journey-types.js";
|
|
2
|
+
export * from "../typedefs/question-props.js";
|
|
3
|
+
export * from "../typedefs/question-types.js";
|
|
4
|
+
export * from "../typedefs/section-types.js";
|
|
1
5
|
export * from "./components/address/question.js";
|
|
2
6
|
export * from "./components/boolean/question.js";
|
|
3
7
|
export * from "./components/checkbox/question.js";
|
|
@@ -19,7 +23,6 @@ export * from "./components/utils/question-has-answer.js";
|
|
|
19
23
|
export * from "./components/utils/question-utils.js";
|
|
20
24
|
export * from "./components/utils/component-types.js";
|
|
21
25
|
export * from "./controller.js";
|
|
22
|
-
export * from "./journey/journey-types.js";
|
|
23
26
|
export * from "./lib/address.js";
|
|
24
27
|
export * from "./lib/address-utils.js";
|
|
25
28
|
export * from "./lib/date-utils.js";
|
|
@@ -28,8 +31,6 @@ export * from "./lib/utils.js";
|
|
|
28
31
|
export * from "./middleware/build-get-journey.js";
|
|
29
32
|
export * from "./middleware/redirect-to-unanswered-question.js";
|
|
30
33
|
export * from "./questions/options-question.js";
|
|
31
|
-
export * from "./questions/question-props.js";
|
|
32
|
-
export * from "./questions/question-types.js";
|
|
33
34
|
export * from "./validator/address-validator.js";
|
|
34
35
|
export * from "./validator/base-validator.js";
|
|
35
36
|
export * from "./validator/conditional-required-validator.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// Type declaration files
|
|
2
|
+
export * from '../typedefs/journey-types.js';
|
|
3
|
+
export * from '../typedefs/question-props.js';
|
|
4
|
+
export * from '../typedefs/question-types.js';
|
|
5
|
+
export * from '../typedefs/section-types.js';
|
|
6
|
+
|
|
1
7
|
// Components
|
|
2
8
|
export * from './components/address/question.js';
|
|
3
9
|
export * from './components/boolean/question.js';
|
|
@@ -29,7 +35,6 @@ export * from './controller.js';
|
|
|
29
35
|
// Journey
|
|
30
36
|
export { Journey } from './journey/journey.js';
|
|
31
37
|
export { JourneyResponse } from './journey/journey-response.js';
|
|
32
|
-
export * from './journey/journey-types.js';
|
|
33
38
|
|
|
34
39
|
// lib
|
|
35
40
|
export * from './lib/address.js';
|
|
@@ -48,9 +53,6 @@ export { createQuestions } from './questions/create-questions.js';
|
|
|
48
53
|
export * from './questions/options-question.js';
|
|
49
54
|
export { questionClasses } from './questions/questions.js';
|
|
50
55
|
|
|
51
|
-
export * from './questions/question-props.js';
|
|
52
|
-
export * from './questions/question-types.js';
|
|
53
|
-
|
|
54
56
|
// Section
|
|
55
57
|
export { Section } from './section.js';
|
|
56
58
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a response to a journey, a set of Answers to the questions
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export class JourneyResponse {
|
|
6
|
+
/**
|
|
7
|
+
* creates an instance of a JourneyResponse
|
|
8
|
+
* @param {string} journeyId
|
|
9
|
+
* @param {string} referenceId
|
|
10
|
+
* @param {import('#typedefs/journey-types.d.ts').JourneyAnswers | null} answers
|
|
11
|
+
* @param {string} [lpaCode]
|
|
12
|
+
*/
|
|
13
|
+
constructor(journeyId: string, referenceId: string, answers: import("#typedefs/journey-types.d.ts").JourneyAnswers | null, lpaCode?: string);
|
|
14
|
+
/**
|
|
15
|
+
* @type {string} - reference id used in the url for the journey e.g. appeal id - provides a unique lookup for responses in combination with formId
|
|
16
|
+
*/
|
|
17
|
+
referenceId: string;
|
|
18
|
+
/**
|
|
19
|
+
* @type {string} - a reference to the journey type e.g. has-questionnaire - provides a unique lookup for responses in combination with referenceId
|
|
20
|
+
*/
|
|
21
|
+
journeyId: string;
|
|
22
|
+
/**
|
|
23
|
+
* @type {import('#typedefs/journey-types.d.ts').JourneyAnswers} - answers to the journey
|
|
24
|
+
*/
|
|
25
|
+
answers: import("#typedefs/journey-types.d.ts").JourneyAnswers;
|
|
26
|
+
LPACode: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=journey-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey-response.d.ts","sourceRoot":"","sources":["journey-response.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAgBC;;;;;;OAMG;IACH,uBALW,MAAM,eACN,MAAM,WACN,OAAO,8BAA8B,EAAE,cAAc,GAAG,IAAI,YAC5D,MAAM,EAWhB;IA/BD;;OAEG;IACH,aAFU,MAAM,CAEJ;IAEZ;;OAEG;IACH,WAFU,MAAM,CAEN;IAEV;;OAEG;IACH,SAFU,OAAO,8BAA8B,EAAE,cAAc,CAEvD;IAiBP,4BAAsB;CAEvB"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import('./journey-factory').JourneyType} JourneyType
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Defines a response to a journey, a set of Answers to the questions
|
|
7
3
|
* @class
|
|
@@ -13,20 +9,20 @@ export class JourneyResponse {
|
|
|
13
9
|
referenceId;
|
|
14
10
|
|
|
15
11
|
/**
|
|
16
|
-
* @type {
|
|
12
|
+
* @type {string} - a reference to the journey type e.g. has-questionnaire - provides a unique lookup for responses in combination with referenceId
|
|
17
13
|
*/
|
|
18
14
|
journeyId;
|
|
19
15
|
|
|
20
16
|
/**
|
|
21
|
-
* @type {import('
|
|
17
|
+
* @type {import('#typedefs/journey-types.d.ts').JourneyAnswers} - answers to the journey
|
|
22
18
|
*/
|
|
23
19
|
answers;
|
|
24
20
|
|
|
25
21
|
/**
|
|
26
22
|
* creates an instance of a JourneyResponse
|
|
27
|
-
* @param {
|
|
23
|
+
* @param {string} journeyId
|
|
28
24
|
* @param {string} referenceId
|
|
29
|
-
* @param {import('
|
|
25
|
+
* @param {import('#typedefs/journey-types.d.ts').JourneyAnswers | null} answers
|
|
30
26
|
* @param {string} [lpaCode]
|
|
31
27
|
*/
|
|
32
28
|
constructor(journeyId, referenceId, answers, lpaCode) {
|
|
@@ -62,20 +62,20 @@ export class Journey {
|
|
|
62
62
|
getSection(sectionSegment: string): import("../section.js").Section | undefined;
|
|
63
63
|
/**
|
|
64
64
|
* gets a question from the object's sections based on a section + question names
|
|
65
|
-
* @param {import('
|
|
65
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
66
66
|
* @returns {import('../questions/question.js').Question | undefined} question found by lookup
|
|
67
67
|
*/
|
|
68
|
-
getQuestionByParams(params: import("
|
|
68
|
+
getQuestionByParams(params: import("#typedefs/journey-types.d.ts").RouteParams): import("../questions/question.js").Question | undefined;
|
|
69
69
|
/**
|
|
70
70
|
* Get the back link for the journey - e.g. the previous question
|
|
71
71
|
*
|
|
72
72
|
* @param {Object} options
|
|
73
|
-
* @param {import('
|
|
73
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} options.params
|
|
74
74
|
* @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
|
|
75
75
|
* @returns {string|null} url for the next question, or null if unmatched
|
|
76
76
|
*/
|
|
77
77
|
getBackLink({ params, manageListQuestion }: {
|
|
78
|
-
params: import("
|
|
78
|
+
params: import("#typedefs/journey-types.d.ts").RouteParams;
|
|
79
79
|
manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
|
|
80
80
|
}): string | null;
|
|
81
81
|
/**
|
|
@@ -83,21 +83,21 @@ export class Journey {
|
|
|
83
83
|
* Used after question post/saving
|
|
84
84
|
*
|
|
85
85
|
* @param {import('express').Response} res
|
|
86
|
-
* @param {import('
|
|
86
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
87
87
|
* @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
|
|
88
88
|
* @returns {void}
|
|
89
89
|
*/
|
|
90
|
-
redirectToNextQuestion(res: import("express").Response, params: import("
|
|
90
|
+
redirectToNextQuestion(res: import("express").Response, params: import("#typedefs/journey-types.d.ts").RouteParams, manageListQuestion?: typeof import("#src/components/manage-list/question.js")): void;
|
|
91
91
|
/**
|
|
92
92
|
* Get url for the next question in the journey
|
|
93
93
|
*
|
|
94
|
-
* @param {import('
|
|
94
|
+
* @param {import('#typedefs/journey-types.d.ts').RouteParams} params
|
|
95
95
|
* @param {Object} options
|
|
96
96
|
* @param {boolean} [options.reverse] - if passed in this will get the previous question
|
|
97
97
|
* @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
|
|
98
98
|
* @returns {string|null} url for the next question, or null if unmatched
|
|
99
99
|
*/
|
|
100
|
-
getNextQuestionUrl(params: import("
|
|
100
|
+
getNextQuestionUrl(params: import("#typedefs/journey-types.d.ts").RouteParams, { reverse, manageListQuestion }?: {
|
|
101
101
|
reverse?: boolean | undefined;
|
|
102
102
|
manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
|
|
103
103
|
}): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["journey.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH;IAwBC;;;;;;;;;;;;;;OAcG;IACH,qLAZG;QAAwB,SAAS,EAAzB,MAAM;QACyE,WAAW,EAA1F,CAAC,QAAQ,EAAE,OAAO,uBAAuB,EAAE,eAAe,KAAK,MAAM;QACpD,WAAW;QAC6B,QAAQ,EAAjE,OAAO,uBAAuB,EAAE,eAAe;QAC/B,eAAe,EAA/B,MAAM;QACU,gBAAgB,EAAhC,MAAM;QACW,uBAAuB;QACxB,YAAY,EAA5B,MAAM;QACY,eAAe;QACU,QAAQ,EAAnD,OAAO,eAAe,EAAE,OAAO,EAAE;QAChB,eAAe;KAC1C,EAoDA;IAzFD,8EAA8E;IAC9E,WADW,MAAM,CACP;IACV,6FAA6F;IAC7F,UADW,KAAK,CAAE,OAAO,eAAe,EAAE,OAAO,CAAC,CACpC;IACd,mHAAmH;IACnH,UADW,OAAO,uBAAuB,EAAE,eAAe,CACjD;IACT,wFAAwF;IACxF,SADW,MAAM,CACJ;IACb,sJAAsJ;IACtJ,aADW,CAAC,eAAe,EAAE,OAAO,uBAAuB,EAAE,eAAe,KAAK,MAAM,CAChE;IACvB,kEAAkE;IAClE,aADW,MAAM,CACA;IACjB,uEAAuE;IACvE,iBADW,MAAM,CACI;IACrB,qFAAqF;IACrF,kBADW,MAAM,CACK;IACtB,4GAA4G;IAC5G,yBADW,MAAM,CACY;IAC7B,qFAAqF;IACrF,iBADW,OAAO,CACM;IACxB,2DAA2D;IAC3D,cADU,MAAM,CACH;IAmEZ,+BAA8C;IA2C/C;;;;OAIG;IACH,2BAHW,MAAM,GACJ,OAAO,eAAe,EAAE,OAAO,GAAG,SAAS,CAMvD;IA8BD;;;;OAIG;IACH,4BAHW,OAAO,8BAA8B,EAAE,WAAW,GAChD,OAAO,0BAA0B,EAAE,QAAQ,GAAG,SAAS,CAiBnE;IAED;;;;;;;OAOG;IACH,4CAJG;QAAoE,MAAM,EAAlE,OAAO,8BAA8B,EAAE,WAAW;QACU,kBAAkB;KACtF,GAAU,MAAM,GAAC,IAAI,CAWvB;IAED;;;;;;;;OAQG;IACH,4BALW,OAAO,SAAS,EAAE,QAAQ,UAC1B,OAAO,8BAA8B,EAAE,WAAW,kFAEhD,IAAI,CAKhB;IAED;;;;;;;;OAQG;IACH,2BANW,OAAO,8BAA8B,EAAE,WAAW,oCAE1D;QAA0B,OAAO;QACmC,kBAAkB;KACtF,GAAU,MAAM,GAAC,IAAI,CAyEvB;IAED;;;;;OAKG;IACH,wBAAyB,gBAJd,MAI4B,EAAE,iBAH9B,MAG6C,KAF3C,MAAM,CAqBjB;IAEF;;;;OAIG;IACH,sCAAuC,iBAH5B,MAG2C,KAFzC,MAAM,CAIjB;IAEF;;;;;;OAMG;IACH,0BAA2B,gBALhB,MAK8B,EAAE,iBAJhC,MAI+C,EAAE,UAHjD,MAGyD,KAFvD,MAAM,CAuBjB;IAEF;;;OAGG;IACH,cAFa,OAAO,CAInB;IAED;;OAEG;IACH,6BAFW,OAAO,uBAAuB,EAAE,eAAe,QAKzD;;CACD"}
|
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,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @template {string} K Question keys in questionPropsRecord
|
|
3
|
-
* @template {import('
|
|
3
|
+
* @template {import('#typedefs/question-props.d.ts').BaseQuestionProps} T
|
|
4
4
|
* @param {{[questionName in K]: T}} questionPropsRecord
|
|
5
|
-
* @param {Record<string, import('
|
|
5
|
+
* @param {Record<string, import('#typedefs/question-types.d.ts').QuestionClass>} questionClasses
|
|
6
6
|
* @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
|
|
7
7
|
* @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
|
|
8
|
-
* @returns {{[questionName in K]: InstanceType<import('
|
|
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
9
|
*/
|
|
10
10
|
export function createQuestions(questionPropsRecord, questionClasses, questionMethodOverrides, textOverrides) {
|
|
11
11
|
return Object.fromEntries(
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
*}} Option
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
|
-
* @typedef {import('
|
|
25
|
+
* @typedef {import('#typedefs/question-types.d.ts').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('
|
|
44
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} options
|
|
45
|
+
* @returns {import('#typedefs/question-types.d.ts').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("#typedefs/question-types.d.ts").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("#typedefs/question-types.d.ts").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":"AASA;;;;;;;;;;;;;;;;;;;;;;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,+BAA+B,EAAE,iBAAiB,CAkDrE;CA2DD;;qBAxKY;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,+BAA+B,EAAE,iBAAiB,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE;wCAG/F,OAAO,+BAA+B,EAAE,kBAAkB,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE;yBApC3E,eAAe"}
|
|
@@ -3,6 +3,7 @@ import { Question } from './question.js';
|
|
|
3
3
|
import ValidOptionValidator from '../validator/valid-option-validator.js';
|
|
4
4
|
import { getConditionalFieldName } from '../components/utils/question-utils.js';
|
|
5
5
|
import { toArray } from '#src/lib/utils.js';
|
|
6
|
+
import escape from 'escape-html';
|
|
6
7
|
|
|
7
8
|
const defaultOptionJoinString = ',';
|
|
8
9
|
|
|
@@ -31,10 +32,10 @@ const defaultOptionJoinString = ',';
|
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
|
-
* @typedef {import('
|
|
35
|
+
* @typedef {import('#typedefs/question-types.d.ts').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
35
36
|
*/
|
|
36
37
|
/**
|
|
37
|
-
* @typedef {import('#question-types').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
38
|
+
* @typedef {import('#typedefs/question-types.d.ts').QuestionParameters & { options: Array<Option> }} OptionsQuestionParameters
|
|
38
39
|
*/
|
|
39
40
|
|
|
40
41
|
export class OptionsQuestion extends Question {
|
|
@@ -65,8 +66,8 @@ export class OptionsQuestion extends Question {
|
|
|
65
66
|
* @param {import('#journey').Journey} journey - the journey we are in
|
|
66
67
|
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
67
68
|
* @param {Record<string, unknown>} [payload]
|
|
68
|
-
* @param {import('#question-types').PrepQuestionForRenderingOptions} options
|
|
69
|
-
* @returns {import('
|
|
69
|
+
* @param {import('#typedefs/question-types.d.ts').PrepQuestionForRenderingOptions} options
|
|
70
|
+
* @returns {import('#typedefs/question-types.d.ts').QuestionViewModel} QuestionViewModel
|
|
70
71
|
*/
|
|
71
72
|
prepQuestionForRendering(section, journey, customViewData, payload, options) {
|
|
72
73
|
const viewModel = super.prepQuestionForRendering(section, journey, customViewData, payload, options);
|
|
@@ -118,6 +119,29 @@ export class OptionsQuestion extends Question {
|
|
|
118
119
|
return viewModel;
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Formats an answer value for display in the summary.
|
|
124
|
+
* Looks up the option text for the given value(s).
|
|
125
|
+
*
|
|
126
|
+
* @param {unknown} answer - the raw answer value
|
|
127
|
+
* @returns {string} the formatted answer for display
|
|
128
|
+
*/
|
|
129
|
+
formatAnswer(answer) {
|
|
130
|
+
if (answer === null || answer === undefined || answer === '') {
|
|
131
|
+
return this.notStartedText;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const answerValues = String(answer)
|
|
135
|
+
.split(this.optionJoinString)
|
|
136
|
+
.map((value) => value.trim());
|
|
137
|
+
const texts = answerValues.map((value) => {
|
|
138
|
+
const option = this.options.find((opt) => opt.value === value);
|
|
139
|
+
return escape(option ? option.text : value);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return texts.join('<br>');
|
|
143
|
+
}
|
|
144
|
+
|
|
121
145
|
/**
|
|
122
146
|
* Get the data to save from the request, returns an object of answers
|
|
123
147
|
* @param {import('express').Request} req
|
|
@@ -137,6 +161,7 @@ export class OptionsQuestion extends Question {
|
|
|
137
161
|
if (selectedOptions.length !== fieldValues.length)
|
|
138
162
|
throw new Error(`User submitted option(s) did not correlate with valid answers to ${this.fieldName} question`);
|
|
139
163
|
|
|
164
|
+
// TODO DF-51 treat as an array
|
|
140
165
|
answers[this.fieldName] = fieldValues.join(this.optionJoinString);
|
|
141
166
|
|
|
142
167
|
this.options.forEach((option) => {
|