@planning-inspectorate/dynamic-forms 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/date-period/index.njk +12 -4
- package/src/components/date-period/question.js +7 -1
- package/src/components/date-period/question.test.js +22 -0
- package/test/snapshots/holiday-period.html +2 -0
- package/types/src/components/date-period/question.d.ts +6 -1
- package/types/src/components/date-period/question.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -33,6 +33,14 @@
|
|
|
33
33
|
}
|
|
34
34
|
}) }}
|
|
35
35
|
|
|
36
|
+
{% if question.hint %}
|
|
37
|
+
<div class="govuk-hint">{{ question.hint }}</div>
|
|
38
|
+
{% endif %}
|
|
39
|
+
|
|
40
|
+
{% if question.html %}
|
|
41
|
+
{% include question.html ignore missing %}
|
|
42
|
+
{% endif %}
|
|
43
|
+
|
|
36
44
|
{{ govukDateInput({
|
|
37
45
|
id: startFieldName,
|
|
38
46
|
fieldset: {
|
|
@@ -40,8 +48,8 @@
|
|
|
40
48
|
text: labels.start
|
|
41
49
|
}
|
|
42
50
|
},
|
|
43
|
-
hint: question.
|
|
44
|
-
text: question.
|
|
51
|
+
hint: question.hintStart and {
|
|
52
|
+
text: question.hintStart
|
|
45
53
|
},
|
|
46
54
|
errorMessage: errorSummary and {
|
|
47
55
|
text: errors[question.fieldName].msg or errors[startFieldName].msg or errors[startDayFieldName].msg or errors[startMonthFieldName].msg or errors[startYearFieldName].msg
|
|
@@ -78,8 +86,8 @@
|
|
|
78
86
|
text: labels.end
|
|
79
87
|
}
|
|
80
88
|
},
|
|
81
|
-
hint: question.
|
|
82
|
-
|
|
89
|
+
hint: question.hintEnd and {
|
|
90
|
+
text: question.hintEnd
|
|
83
91
|
},
|
|
84
92
|
errorMessage: errorSummary and {
|
|
85
93
|
text: errors[question.fieldName].msg or errors[endFieldName].msg or errors[endDayFieldName].msg or errors[endMonthFieldName].msg or errors[endYearFieldName].msg
|
|
@@ -14,16 +14,22 @@ export default class DatePeriodQuestion extends Question {
|
|
|
14
14
|
* @param {import('#question-types').QuestionParameters} params
|
|
15
15
|
* @param {string} [params.dateFormat]
|
|
16
16
|
* @param {{start: string, end: string}} [params.labels]
|
|
17
|
+
* @param {string} [params.hint]
|
|
18
|
+
* @param {string} [params.hintStart]
|
|
19
|
+
* @param {string} [params.hintEnd]
|
|
17
20
|
* @param {{hour: number, minute: number, second: number}} [params.startTime]
|
|
18
21
|
* @param {{hour: number, minute: number, second: number}} [params.endTime]
|
|
19
22
|
*/
|
|
20
|
-
constructor({ dateFormat = DEFAULT_DATE_FORMAT, labels, startTime, endTime, ...params }) {
|
|
23
|
+
constructor({ dateFormat = DEFAULT_DATE_FORMAT, hint, labels, hintStart, startTime, hintEnd, endTime, ...params }) {
|
|
21
24
|
super({
|
|
22
25
|
...params,
|
|
23
26
|
viewFolder: 'date-period'
|
|
24
27
|
});
|
|
25
28
|
this.dateFormat = dateFormat;
|
|
26
29
|
this.labels = labels || { start: 'Start', end: 'End' };
|
|
30
|
+
this.hint = hint;
|
|
31
|
+
this.hintStart = hintStart;
|
|
32
|
+
this.hintEnd = hintEnd;
|
|
27
33
|
this.startTime = startTime || { hour: 0, minute: 0, second: 0 };
|
|
28
34
|
this.endTime = endTime || { hour: 0, minute: 0, second: 0 };
|
|
29
35
|
}
|
|
@@ -10,6 +10,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
10
10
|
const FIELDNAME = 'fieldName';
|
|
11
11
|
const HINT = 'hint hint';
|
|
12
12
|
const VALIDATORS = [];
|
|
13
|
+
const HINTSTART = 'Start date hint';
|
|
14
|
+
const HINTEND = 'End date hint';
|
|
13
15
|
|
|
14
16
|
describe('constructor', () => {
|
|
15
17
|
it('should instantiate and inherit from Question', () => {
|
|
@@ -18,6 +20,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
18
20
|
question: QUESTION,
|
|
19
21
|
fieldName: FIELDNAME,
|
|
20
22
|
hint: HINT,
|
|
23
|
+
hintStart: HINTSTART,
|
|
24
|
+
hintEnd: HINTEND,
|
|
21
25
|
validators: VALIDATORS
|
|
22
26
|
});
|
|
23
27
|
assert.strictEqual(dateQuestion instanceof DatePeriodQuestion, true);
|
|
@@ -33,6 +37,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
33
37
|
question: QUESTION,
|
|
34
38
|
fieldName: FIELDNAME,
|
|
35
39
|
hint: HINT,
|
|
40
|
+
hintStart: HINTSTART,
|
|
41
|
+
hintEnd: HINTEND,
|
|
36
42
|
validators: VALIDATORS
|
|
37
43
|
});
|
|
38
44
|
|
|
@@ -63,6 +69,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
63
69
|
question: QUESTION,
|
|
64
70
|
fieldName: FIELDNAME,
|
|
65
71
|
hint: HINT,
|
|
72
|
+
hintStart: HINTSTART,
|
|
73
|
+
hintEnd: HINTEND,
|
|
66
74
|
validators: VALIDATORS,
|
|
67
75
|
startTime: { hour: 3, minute: 24, second: 0 },
|
|
68
76
|
endTime: { hour: 23, minute: 59, second: 0 }
|
|
@@ -98,6 +106,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
98
106
|
question: QUESTION,
|
|
99
107
|
fieldName: FIELDNAME,
|
|
100
108
|
hint: HINT,
|
|
109
|
+
hintStart: HINTSTART,
|
|
110
|
+
hintEnd: HINTEND,
|
|
101
111
|
validators: VALIDATORS
|
|
102
112
|
});
|
|
103
113
|
|
|
@@ -142,6 +152,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
142
152
|
question: QUESTION,
|
|
143
153
|
fieldName: FIELDNAME,
|
|
144
154
|
hint: HINT,
|
|
155
|
+
hintStart: HINTSTART,
|
|
156
|
+
hintEnd: HINTEND,
|
|
145
157
|
validators: VALIDATORS
|
|
146
158
|
});
|
|
147
159
|
|
|
@@ -189,6 +201,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
189
201
|
question: QUESTION,
|
|
190
202
|
fieldName: FIELDNAME,
|
|
191
203
|
hint: HINT,
|
|
204
|
+
hintStart: HINTSTART,
|
|
205
|
+
hintEnd: HINTEND,
|
|
192
206
|
validators: VALIDATORS
|
|
193
207
|
});
|
|
194
208
|
|
|
@@ -231,6 +245,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
231
245
|
question: QUESTION,
|
|
232
246
|
fieldName: FIELDNAME,
|
|
233
247
|
hint: HINT,
|
|
248
|
+
hintStart: HINTSTART,
|
|
249
|
+
hintEnd: HINTEND,
|
|
234
250
|
validators: VALIDATORS
|
|
235
251
|
});
|
|
236
252
|
|
|
@@ -260,6 +276,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
260
276
|
question: QUESTION,
|
|
261
277
|
fieldName: FIELDNAME,
|
|
262
278
|
hint: HINT,
|
|
279
|
+
hintStart: HINTSTART,
|
|
280
|
+
hintEnd: HINTEND,
|
|
263
281
|
validators: VALIDATORS
|
|
264
282
|
});
|
|
265
283
|
|
|
@@ -289,6 +307,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
289
307
|
question: QUESTION,
|
|
290
308
|
fieldName: FIELDNAME,
|
|
291
309
|
hint: HINT,
|
|
310
|
+
hintStart: HINTSTART,
|
|
311
|
+
hintEnd: HINTEND,
|
|
292
312
|
validators: VALIDATORS,
|
|
293
313
|
labels: { start: 'Open', end: 'Close' }
|
|
294
314
|
});
|
|
@@ -320,6 +340,8 @@ describe('DatePeriodQuestion', () => {
|
|
|
320
340
|
question: QUESTION,
|
|
321
341
|
fieldName: FIELDNAME,
|
|
322
342
|
hint: HINT,
|
|
343
|
+
hintStart: HINTSTART,
|
|
344
|
+
hintEnd: HINTEND,
|
|
323
345
|
validators: VALIDATORS
|
|
324
346
|
});
|
|
325
347
|
|
|
@@ -7,12 +7,17 @@ export default class DatePeriodQuestion extends Question {
|
|
|
7
7
|
* @param {import('#question-types').QuestionParameters} params
|
|
8
8
|
* @param {string} [params.dateFormat]
|
|
9
9
|
* @param {{start: string, end: string}} [params.labels]
|
|
10
|
+
* @param {string} [params.hint]
|
|
11
|
+
* @param {string} [params.hintStart]
|
|
12
|
+
* @param {string} [params.hintEnd]
|
|
10
13
|
* @param {{hour: number, minute: number, second: number}} [params.startTime]
|
|
11
14
|
* @param {{hour: number, minute: number, second: number}} [params.endTime]
|
|
12
15
|
*/
|
|
13
|
-
constructor({ dateFormat, labels, startTime, endTime, ...params }: import("#question-types").QuestionParameters);
|
|
16
|
+
constructor({ dateFormat, hint, labels, hintStart, startTime, hintEnd, endTime, ...params }: import("#question-types").QuestionParameters);
|
|
14
17
|
dateFormat: any;
|
|
15
18
|
labels: any;
|
|
19
|
+
hintStart: any;
|
|
20
|
+
hintEnd: any;
|
|
16
21
|
startTime: any;
|
|
17
22
|
endTime: any;
|
|
18
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;OASG;IACH,6FATW,OAAO,iBAAiB,EAAE,kBAAkB,EAqBtD;IAPA,gBAA4B;IAC5B,YAAsD;IAEtD,eAA0B;IAC1B,aAAsB;IACtB,eAA+D;IAC/D,aAA2D;IAG5D;;;;;OAKG,CACH,yCAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAgC5B;IAED;;MAuCC;CAuCD;yBAvJwB,WAAW"}
|