@ukhomeoffice/cop-react-form-renderer 3.10.0 → 3.11.1-alpha
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.
|
@@ -21,6 +21,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
21
|
|
|
22
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
23
|
|
|
24
|
+
var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
|
|
25
|
+
return [{
|
|
26
|
+
pageId: page.id,
|
|
27
|
+
key: page.components[0].labels.empty || 'Nothing entered',
|
|
28
|
+
required: page.required,
|
|
29
|
+
action: {
|
|
30
|
+
page: page.id,
|
|
31
|
+
label: "Change",
|
|
32
|
+
aria_suffix: page.cya_link.aria_suffix,
|
|
33
|
+
onAction: onAction
|
|
34
|
+
}
|
|
35
|
+
}];
|
|
36
|
+
};
|
|
37
|
+
|
|
24
38
|
var getContainerForItem = function getContainerForItem(collection, item, labelCount, full_path) {
|
|
25
39
|
return {
|
|
26
40
|
id: item.id,
|
|
@@ -59,7 +73,7 @@ var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, l
|
|
|
59
73
|
};
|
|
60
74
|
|
|
61
75
|
var getCYARowsForCollection = function getCYARowsForCollection(page, collection, items, onAction) {
|
|
62
|
-
if (Array.isArray(items) && (0, _showComponentCYA.default)(collection, page.formData)) {
|
|
76
|
+
if (Array.isArray(items) && items.length && (0, _showComponentCYA.default)(collection, page.formData)) {
|
|
63
77
|
return items.flatMap(function (item, index) {
|
|
64
78
|
var labelCount = (collection.countOffset || 0) + index + 1;
|
|
65
79
|
var full_path = "".concat(collection.full_path || collection.fieldId, "[").concat(index, "]");
|
|
@@ -70,7 +84,7 @@ var getCYARowsForCollection = function getCYARowsForCollection(page, collection,
|
|
|
70
84
|
});
|
|
71
85
|
}
|
|
72
86
|
|
|
73
|
-
return
|
|
87
|
+
return getEntryToCollectionRow(page, onAction);
|
|
74
88
|
};
|
|
75
89
|
|
|
76
90
|
var _default = getCYARowsForCollection;
|
|
@@ -15,10 +15,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
15
15
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
16
|
|
|
17
17
|
describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
18
|
-
it('should get
|
|
18
|
+
it('should get a single placeholder row when there are no items', function () {
|
|
19
19
|
var FORM_DATA = undefined;
|
|
20
20
|
var PAGE = {
|
|
21
21
|
id: 'page',
|
|
22
|
+
components: [{
|
|
23
|
+
labels: {
|
|
24
|
+
add: 'Add'
|
|
25
|
+
}
|
|
26
|
+
}],
|
|
22
27
|
formData: FORM_DATA,
|
|
23
28
|
cya_link: {}
|
|
24
29
|
};
|
|
@@ -39,7 +44,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
39
44
|
var ON_ACTION = function ON_ACTION() {};
|
|
40
45
|
|
|
41
46
|
var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
|
|
42
|
-
expect(ROWS.length).toEqual(
|
|
47
|
+
expect(ROWS.length).toEqual(1);
|
|
43
48
|
});
|
|
44
49
|
it('should get an appropriate row for a collection with a single readonly text component', function () {
|
|
45
50
|
var FORM_DATA = {
|