@truedat/dd 8.12.1 → 8.12.2
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 +3 -3
- package/src/components/GrantRequestTemplateForm.js +76 -0
- package/src/components/StructureGrantCartCheckout.js +122 -59
- package/src/components/StructureGrantCartInformation.js +38 -9
- package/src/components/__tests__/StructureGrantCartCheckout.grouping.spec.js +95 -0
- package/src/components/__tests__/StructureGrantCartCheckout.selection.spec.js +416 -0
- package/src/components/__tests__/StructureGrantCartCheckout.spec.js +177 -3
- package/src/components/__tests__/__snapshots__/StructureGrantCartCheckout.spec.js.snap +217 -1
- package/src/components/__tests__/__snapshots__/StructureGrantCartInformation.spec.js.snap +54 -0
- package/src/reducers/__tests__/grantRequestsCart.spec.js +69 -0
- package/src/reducers/grantRequestsCart.js +17 -2
|
@@ -62,6 +62,60 @@ exports[`StructureGrantCartCheckout matches snapshot when modification grant (si
|
|
|
62
62
|
>
|
|
63
63
|
structure.grant.cart.template
|
|
64
64
|
</div>
|
|
65
|
+
<div
|
|
66
|
+
class="required field"
|
|
67
|
+
>
|
|
68
|
+
<div
|
|
69
|
+
class="field"
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
aria-busy="false"
|
|
73
|
+
aria-expanded="false"
|
|
74
|
+
class="ui search selection dropdown"
|
|
75
|
+
name="template"
|
|
76
|
+
role="combobox"
|
|
77
|
+
>
|
|
78
|
+
<input
|
|
79
|
+
aria-autocomplete="list"
|
|
80
|
+
autocomplete="off"
|
|
81
|
+
class="search"
|
|
82
|
+
tabindex="0"
|
|
83
|
+
type="text"
|
|
84
|
+
value=""
|
|
85
|
+
/>
|
|
86
|
+
<div
|
|
87
|
+
aria-atomic="true"
|
|
88
|
+
aria-live="polite"
|
|
89
|
+
class="divider default text"
|
|
90
|
+
role="alert"
|
|
91
|
+
>
|
|
92
|
+
structure.grant.cart.template.placeholder
|
|
93
|
+
</div>
|
|
94
|
+
<i
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
class="dropdown icon"
|
|
97
|
+
/>
|
|
98
|
+
<div
|
|
99
|
+
class="menu transition"
|
|
100
|
+
role="listbox"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
aria-checked="false"
|
|
104
|
+
aria-selected="true"
|
|
105
|
+
class="selected item"
|
|
106
|
+
role="option"
|
|
107
|
+
style="pointer-events: all;"
|
|
108
|
+
>
|
|
109
|
+
<span
|
|
110
|
+
class="text"
|
|
111
|
+
>
|
|
112
|
+
template1
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
65
119
|
</form>
|
|
66
120
|
</div>
|
|
67
121
|
</div>
|
|
@@ -221,6 +275,60 @@ exports[`StructureGrantCartCheckout matches snapshot when multi-system (gr scope
|
|
|
221
275
|
>
|
|
222
276
|
structure.grant.cart.template
|
|
223
277
|
</div>
|
|
278
|
+
<div
|
|
279
|
+
class="required field"
|
|
280
|
+
>
|
|
281
|
+
<div
|
|
282
|
+
class="field"
|
|
283
|
+
>
|
|
284
|
+
<div
|
|
285
|
+
aria-busy="false"
|
|
286
|
+
aria-expanded="false"
|
|
287
|
+
class="ui search selection dropdown"
|
|
288
|
+
name="template"
|
|
289
|
+
role="combobox"
|
|
290
|
+
>
|
|
291
|
+
<input
|
|
292
|
+
aria-autocomplete="list"
|
|
293
|
+
autocomplete="off"
|
|
294
|
+
class="search"
|
|
295
|
+
tabindex="0"
|
|
296
|
+
type="text"
|
|
297
|
+
value=""
|
|
298
|
+
/>
|
|
299
|
+
<div
|
|
300
|
+
aria-atomic="true"
|
|
301
|
+
aria-live="polite"
|
|
302
|
+
class="divider default text"
|
|
303
|
+
role="alert"
|
|
304
|
+
>
|
|
305
|
+
structure.grant.cart.template.placeholder
|
|
306
|
+
</div>
|
|
307
|
+
<i
|
|
308
|
+
aria-hidden="true"
|
|
309
|
+
class="dropdown icon"
|
|
310
|
+
/>
|
|
311
|
+
<div
|
|
312
|
+
class="menu transition"
|
|
313
|
+
role="listbox"
|
|
314
|
+
>
|
|
315
|
+
<div
|
|
316
|
+
aria-checked="false"
|
|
317
|
+
aria-selected="true"
|
|
318
|
+
class="selected item"
|
|
319
|
+
role="option"
|
|
320
|
+
style="pointer-events: all;"
|
|
321
|
+
>
|
|
322
|
+
<span
|
|
323
|
+
class="text"
|
|
324
|
+
>
|
|
325
|
+
template1
|
|
326
|
+
</span>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
224
332
|
</form>
|
|
225
333
|
</div>
|
|
226
334
|
</div>
|
|
@@ -293,6 +401,60 @@ exports[`StructureGrantCartCheckout matches snapshot when single flow without mo
|
|
|
293
401
|
>
|
|
294
402
|
structure.grant.cart.template
|
|
295
403
|
</div>
|
|
404
|
+
<div
|
|
405
|
+
class="required field"
|
|
406
|
+
>
|
|
407
|
+
<div
|
|
408
|
+
class="field"
|
|
409
|
+
>
|
|
410
|
+
<div
|
|
411
|
+
aria-busy="false"
|
|
412
|
+
aria-expanded="false"
|
|
413
|
+
class="ui search selection dropdown"
|
|
414
|
+
name="template"
|
|
415
|
+
role="combobox"
|
|
416
|
+
>
|
|
417
|
+
<input
|
|
418
|
+
aria-autocomplete="list"
|
|
419
|
+
autocomplete="off"
|
|
420
|
+
class="search"
|
|
421
|
+
tabindex="0"
|
|
422
|
+
type="text"
|
|
423
|
+
value=""
|
|
424
|
+
/>
|
|
425
|
+
<div
|
|
426
|
+
aria-atomic="true"
|
|
427
|
+
aria-live="polite"
|
|
428
|
+
class="divider default text"
|
|
429
|
+
role="alert"
|
|
430
|
+
>
|
|
431
|
+
structure.grant.cart.template.placeholder
|
|
432
|
+
</div>
|
|
433
|
+
<i
|
|
434
|
+
aria-hidden="true"
|
|
435
|
+
class="dropdown icon"
|
|
436
|
+
/>
|
|
437
|
+
<div
|
|
438
|
+
class="menu transition"
|
|
439
|
+
role="listbox"
|
|
440
|
+
>
|
|
441
|
+
<div
|
|
442
|
+
aria-checked="false"
|
|
443
|
+
aria-selected="true"
|
|
444
|
+
class="selected item"
|
|
445
|
+
role="option"
|
|
446
|
+
style="pointer-events: all;"
|
|
447
|
+
>
|
|
448
|
+
<span
|
|
449
|
+
class="text"
|
|
450
|
+
>
|
|
451
|
+
template1
|
|
452
|
+
</span>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
296
458
|
</form>
|
|
297
459
|
</div>
|
|
298
460
|
</div>
|
|
@@ -806,7 +968,7 @@ exports[`StructureGrantCartCheckout matches snapshot with group_by_domain enable
|
|
|
806
968
|
</div>
|
|
807
969
|
`;
|
|
808
970
|
|
|
809
|
-
exports[`StructureGrantCartCheckout matches snapshot with single domain -
|
|
971
|
+
exports[`StructureGrantCartCheckout matches snapshot with single domain - uses single-group information panel 1`] = `
|
|
810
972
|
<div>
|
|
811
973
|
<div
|
|
812
974
|
class="ui segment structures"
|
|
@@ -1112,6 +1274,60 @@ exports[`StructureGrantCartCheckout matches snapshot without gr scope - does not
|
|
|
1112
1274
|
>
|
|
1113
1275
|
structure.grant.cart.template
|
|
1114
1276
|
</div>
|
|
1277
|
+
<div
|
|
1278
|
+
class="required field"
|
|
1279
|
+
>
|
|
1280
|
+
<div
|
|
1281
|
+
class="field"
|
|
1282
|
+
>
|
|
1283
|
+
<div
|
|
1284
|
+
aria-busy="false"
|
|
1285
|
+
aria-expanded="false"
|
|
1286
|
+
class="ui search selection dropdown"
|
|
1287
|
+
name="template"
|
|
1288
|
+
role="combobox"
|
|
1289
|
+
>
|
|
1290
|
+
<input
|
|
1291
|
+
aria-autocomplete="list"
|
|
1292
|
+
autocomplete="off"
|
|
1293
|
+
class="search"
|
|
1294
|
+
tabindex="0"
|
|
1295
|
+
type="text"
|
|
1296
|
+
value=""
|
|
1297
|
+
/>
|
|
1298
|
+
<div
|
|
1299
|
+
aria-atomic="true"
|
|
1300
|
+
aria-live="polite"
|
|
1301
|
+
class="divider default text"
|
|
1302
|
+
role="alert"
|
|
1303
|
+
>
|
|
1304
|
+
structure.grant.cart.template.placeholder
|
|
1305
|
+
</div>
|
|
1306
|
+
<i
|
|
1307
|
+
aria-hidden="true"
|
|
1308
|
+
class="dropdown icon"
|
|
1309
|
+
/>
|
|
1310
|
+
<div
|
|
1311
|
+
class="menu transition"
|
|
1312
|
+
role="listbox"
|
|
1313
|
+
>
|
|
1314
|
+
<div
|
|
1315
|
+
aria-checked="false"
|
|
1316
|
+
aria-selected="true"
|
|
1317
|
+
class="selected item"
|
|
1318
|
+
role="option"
|
|
1319
|
+
style="pointer-events: all;"
|
|
1320
|
+
>
|
|
1321
|
+
<span
|
|
1322
|
+
class="text"
|
|
1323
|
+
>
|
|
1324
|
+
template1
|
|
1325
|
+
</span>
|
|
1326
|
+
</div>
|
|
1327
|
+
</div>
|
|
1328
|
+
</div>
|
|
1329
|
+
</div>
|
|
1330
|
+
</div>
|
|
1115
1331
|
</form>
|
|
1116
1332
|
</div>
|
|
1117
1333
|
</div>
|
|
@@ -14,6 +14,60 @@ exports[`<StructureGrantCartInformation /> matches the latest snapshot 1`] = `
|
|
|
14
14
|
>
|
|
15
15
|
structure.grant.cart.template
|
|
16
16
|
</div>
|
|
17
|
+
<div
|
|
18
|
+
class="required field"
|
|
19
|
+
>
|
|
20
|
+
<div
|
|
21
|
+
class="field"
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
aria-busy="false"
|
|
25
|
+
aria-expanded="false"
|
|
26
|
+
class="ui search selection dropdown"
|
|
27
|
+
name="template"
|
|
28
|
+
role="combobox"
|
|
29
|
+
>
|
|
30
|
+
<input
|
|
31
|
+
aria-autocomplete="list"
|
|
32
|
+
autocomplete="off"
|
|
33
|
+
class="search"
|
|
34
|
+
tabindex="0"
|
|
35
|
+
type="text"
|
|
36
|
+
value=""
|
|
37
|
+
/>
|
|
38
|
+
<div
|
|
39
|
+
aria-atomic="true"
|
|
40
|
+
aria-live="polite"
|
|
41
|
+
class="divider default text"
|
|
42
|
+
role="alert"
|
|
43
|
+
>
|
|
44
|
+
structure.grant.cart.template.placeholder
|
|
45
|
+
</div>
|
|
46
|
+
<i
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
class="dropdown icon"
|
|
49
|
+
/>
|
|
50
|
+
<div
|
|
51
|
+
class="menu transition"
|
|
52
|
+
role="listbox"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
aria-checked="false"
|
|
56
|
+
aria-selected="true"
|
|
57
|
+
class="selected item"
|
|
58
|
+
role="option"
|
|
59
|
+
style="pointer-events: all;"
|
|
60
|
+
>
|
|
61
|
+
<span
|
|
62
|
+
class="text"
|
|
63
|
+
>
|
|
64
|
+
template1
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
17
71
|
</form>
|
|
18
72
|
</div>
|
|
19
73
|
</div>
|
|
@@ -132,6 +132,7 @@ describe("reducers: grantRequestsCart", () => {
|
|
|
132
132
|
const expectedState = {
|
|
133
133
|
...initialState,
|
|
134
134
|
template,
|
|
135
|
+
validCart: false,
|
|
135
136
|
};
|
|
136
137
|
expect(
|
|
137
138
|
grantRequestsCart(initialState, {
|
|
@@ -154,6 +155,7 @@ describe("reducers: grantRequestsCart", () => {
|
|
|
154
155
|
).toEqual({
|
|
155
156
|
...initialState,
|
|
156
157
|
template: "another_template",
|
|
158
|
+
validCart: false,
|
|
157
159
|
});
|
|
158
160
|
});
|
|
159
161
|
|
|
@@ -233,6 +235,31 @@ describe("reducers: grantRequestsCart", () => {
|
|
|
233
235
|
).toEqual(expectedState);
|
|
234
236
|
});
|
|
235
237
|
|
|
238
|
+
it("preserves the draft when reopening the same grant update", () => {
|
|
239
|
+
const previousGrant = { id: 2, detail: { old: "content" } };
|
|
240
|
+
const refreshedGrant = { id: "2", detail: { new: "content" } };
|
|
241
|
+
const structure = { id: 1 };
|
|
242
|
+
const state = {
|
|
243
|
+
...initialState,
|
|
244
|
+
modificationGrant: previousGrant,
|
|
245
|
+
structures: [{ id: 5 }],
|
|
246
|
+
template: "user selected template",
|
|
247
|
+
templateContent: { reason: { value: "draft", origin: "user" } },
|
|
248
|
+
validCart: true,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
expect(
|
|
252
|
+
grantRequestsCart(state, {
|
|
253
|
+
type: setGrantChangeRequestCart.TRIGGER,
|
|
254
|
+
payload: { structure, grant: refreshedGrant },
|
|
255
|
+
}),
|
|
256
|
+
).toEqual({
|
|
257
|
+
...state,
|
|
258
|
+
modificationGrant: refreshedGrant,
|
|
259
|
+
structures: [structure],
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
236
263
|
it("on setGrantChangeRequestCart.TRIGGER fill templateContent with grant.detail", () => {
|
|
237
264
|
const structure = { id: 1 };
|
|
238
265
|
const grantDetail = {
|
|
@@ -388,6 +415,48 @@ describe("reducers: grantRequestsCart", () => {
|
|
|
388
415
|
).toEqual(expectedState);
|
|
389
416
|
});
|
|
390
417
|
|
|
418
|
+
it("preserves content when the selected template is unchanged", () => {
|
|
419
|
+
const state = {
|
|
420
|
+
...initialState,
|
|
421
|
+
template: "T",
|
|
422
|
+
templateContent: { reason: { value: "draft", origin: "user" } },
|
|
423
|
+
validCart: true,
|
|
424
|
+
};
|
|
425
|
+
expect(
|
|
426
|
+
grantRequestsCart(state, {
|
|
427
|
+
type: selectGrantRequestTemplate.TRIGGER,
|
|
428
|
+
payload: "T",
|
|
429
|
+
}),
|
|
430
|
+
).toBe(state);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("invalidates and clears only the group whose template changes", () => {
|
|
434
|
+
const draft = {
|
|
435
|
+
template: "Old",
|
|
436
|
+
templateContent: { reason: { value: "draft", origin: "user" } },
|
|
437
|
+
valid: true,
|
|
438
|
+
};
|
|
439
|
+
const state = {
|
|
440
|
+
...initialState,
|
|
441
|
+
groupTemplates: { first: draft, second: draft },
|
|
442
|
+
};
|
|
443
|
+
expect(
|
|
444
|
+
grantRequestsCart(state, {
|
|
445
|
+
type: selectGrantRequestTemplateForGroup.TRIGGER,
|
|
446
|
+
payload: { key: "first", template: "Old" },
|
|
447
|
+
}),
|
|
448
|
+
).toBe(state);
|
|
449
|
+
expect(
|
|
450
|
+
grantRequestsCart(state, {
|
|
451
|
+
type: selectGrantRequestTemplateForGroup.TRIGGER,
|
|
452
|
+
payload: { key: "first", template: "New" },
|
|
453
|
+
}).groupTemplates,
|
|
454
|
+
).toEqual({
|
|
455
|
+
first: { template: "New", templateContent: {}, valid: false },
|
|
456
|
+
second: draft,
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
|
|
391
460
|
it("should handle updateGrantRequestTemplateContentForGroup.TRIGGER", () => {
|
|
392
461
|
const stateWithGroups = {
|
|
393
462
|
...initialState,
|
|
@@ -65,10 +65,12 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
65
65
|
)(state),
|
|
66
66
|
};
|
|
67
67
|
case selectGrantRequestTemplate.TRIGGER:
|
|
68
|
+
if (state.template === payload) return state;
|
|
68
69
|
return {
|
|
69
70
|
...state,
|
|
70
71
|
template: payload,
|
|
71
72
|
templateContent: modificationGrantContent(state.modificationGrant),
|
|
73
|
+
validCart: false,
|
|
72
74
|
};
|
|
73
75
|
case updateGrantRequestTemplateContent.TRIGGER:
|
|
74
76
|
const { content, valid } = payload;
|
|
@@ -107,14 +109,26 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
107
109
|
},
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
|
-
case setGrantChangeRequestCart.TRIGGER:
|
|
112
|
+
case setGrantChangeRequestCart.TRIGGER: {
|
|
111
113
|
const { structure, grant } = payload;
|
|
114
|
+
const isSameModification =
|
|
115
|
+
state.modificationGrant?.id != null &&
|
|
116
|
+
grant?.id != null &&
|
|
117
|
+
String(state.modificationGrant.id) === String(grant.id);
|
|
118
|
+
if (isSameModification) {
|
|
119
|
+
return {
|
|
120
|
+
...state,
|
|
121
|
+
modificationGrant: grant,
|
|
122
|
+
structures: [mapPayload(structure)],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
112
125
|
return {
|
|
113
126
|
...initialState,
|
|
114
127
|
templateContent: formatLegacyContent(grant.detail),
|
|
115
128
|
modificationGrant: grant,
|
|
116
129
|
structures: [mapPayload(structure)],
|
|
117
130
|
};
|
|
131
|
+
}
|
|
118
132
|
case updateGrantRequestFilter.TRIGGER:
|
|
119
133
|
const { index, value, structureId } = payload;
|
|
120
134
|
return {
|
|
@@ -140,11 +154,12 @@ const grantRequestsCart = (state = initialState, { type, payload }) => {
|
|
|
140
154
|
case selectGrantRequestTemplateForGroup.TRIGGER: {
|
|
141
155
|
const { key, template } = payload;
|
|
142
156
|
const groupTemplates = _.getOr({}, "groupTemplates", state);
|
|
157
|
+
if (groupTemplates[key]?.template === template) return state;
|
|
143
158
|
return {
|
|
144
159
|
...state,
|
|
145
160
|
groupTemplates: {
|
|
146
161
|
...groupTemplates,
|
|
147
|
-
[key]: {
|
|
162
|
+
[key]: { template, templateContent: {}, valid: false },
|
|
148
163
|
},
|
|
149
164
|
};
|
|
150
165
|
}
|