@ukhomeoffice/cop-react-form-renderer 4.71.0 → 4.72.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.
|
@@ -115,7 +115,7 @@ var onPageAction = function onPageAction(action, patch, patchLabel, hooks, data,
|
|
|
115
115
|
}, function (errors) {
|
|
116
116
|
_handlers.default.submissionError(errors, addErrors);
|
|
117
117
|
setData(_objectSpread({}, preSubmitData));
|
|
118
|
-
}, changedFieldName, changedFieldValue);
|
|
118
|
+
}, changedFieldName, changedFieldValue, pageId);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
};
|
|
@@ -88,7 +88,10 @@ var getChangeActionForPage = function getChangeActionForPage(page, item, onActio
|
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
90
|
var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction) {
|
|
91
|
-
var _page$formData, _page$formData$page$c
|
|
91
|
+
var _page$formData, _page$formData$page$c, _page$formData2, _page$formData2$page$;
|
|
92
|
+
if (!((_page$formData = page.formData) !== null && _page$formData !== void 0 && (_page$formData$page$c = _page$formData[page.collection.name]) !== null && _page$formData$page$c !== void 0 && _page$formData$page$c.length)) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
92
95
|
var rows = [];
|
|
93
96
|
if (!page.collection.hideNameFromCYA) {
|
|
94
97
|
rows.push({
|
|
@@ -100,7 +103,7 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
100
103
|
size: 'm'
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
|
-
(_page$
|
|
106
|
+
(_page$formData2 = page.formData) === null || _page$formData2 === void 0 ? void 0 : (_page$formData2$page$ = _page$formData2[page.collection.name]) === null || _page$formData2$page$ === void 0 ? void 0 : _page$formData2$page$.forEach(function (item, index) {
|
|
104
107
|
var _page$collection2;
|
|
105
108
|
var labelCount = index + 1;
|
|
106
109
|
var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
|
|
@@ -55,25 +55,39 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
55
55
|
},
|
|
56
56
|
collectionPages: PAGES
|
|
57
57
|
};
|
|
58
|
-
it('should return
|
|
58
|
+
it('should return no rows for a collection if it does not exist in formData', function () {
|
|
59
59
|
var FORM_DATA = {};
|
|
60
60
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
61
61
|
formData: FORM_DATA
|
|
62
62
|
});
|
|
63
63
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
64
|
-
expect(ROWS.length).toEqual(
|
|
65
|
-
|
|
64
|
+
expect(ROWS.length).toEqual(0);
|
|
65
|
+
});
|
|
66
|
+
it('should return no rows for a collection if it has no entries', function () {
|
|
67
|
+
var FORM_DATA = {
|
|
68
|
+
collection: []
|
|
69
|
+
};
|
|
70
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
71
|
+
formData: FORM_DATA
|
|
72
|
+
});
|
|
73
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
74
|
+
expect(ROWS.length).toEqual(0);
|
|
66
75
|
});
|
|
67
76
|
it('should accept the hideNameFromCYA collection flag', function () {
|
|
68
|
-
var FORM_DATA = {
|
|
77
|
+
var FORM_DATA = {
|
|
78
|
+
collection: [{
|
|
79
|
+
testText: 'hello'
|
|
80
|
+
}]
|
|
81
|
+
};
|
|
69
82
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
70
83
|
formData: FORM_DATA,
|
|
71
84
|
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
72
85
|
hideNameFromCYA: true
|
|
73
86
|
})
|
|
74
87
|
});
|
|
88
|
+
var TITLE_FIELD_ID = "".concat(PAGE.collection.name, "Title");
|
|
75
89
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
76
|
-
expect(ROWS.
|
|
90
|
+
expect(ROWS[0].fieldId).not.toEqual(TITLE_FIELD_ID);
|
|
77
91
|
});
|
|
78
92
|
it('should format titles correctly when collection.labels.item is specified', function () {
|
|
79
93
|
var FORM_DATA = {
|