@ukhomeoffice/cop-react-form-renderer 4.21.0 → 4.22.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.
|
@@ -102,9 +102,9 @@ var FormPage = function FormPage(_ref) {
|
|
|
102
102
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
103
103
|
className: classes('page'),
|
|
104
104
|
key: page.id
|
|
105
|
-
},
|
|
105
|
+
}, (errors === null || errors === void 0 ? void 0 : errors.length) > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
|
|
106
106
|
errors: errors
|
|
107
|
-
}), page.components.filter(function (c) {
|
|
107
|
+
}), page.title && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, null, _utils.default.interpolateString(page.title, page.formData)), page.components.filter(function (c) {
|
|
108
108
|
return _utils.default.Component.show(c, page.formData);
|
|
109
109
|
}).map(function (component, index) {
|
|
110
110
|
return /*#__PURE__*/_react.default.createElement(_FormComponent.default, {
|
|
@@ -354,8 +354,19 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
354
354
|
|
|
355
355
|
case _models.PageAction.TYPES.COLLECTION_REMOVE:
|
|
356
356
|
var activeId = formState.page.formData["".concat(action.collection, "ActiveId")];
|
|
357
|
-
formState.page.formData["".concat(action.collection)] = formState.page.formData["".concat(action.collection)].
|
|
358
|
-
|
|
357
|
+
formState.page.formData["".concat(action.collection)] = formState.page.formData["".concat(action.collection)].map(function (entry) {
|
|
358
|
+
if (entry.id === activeId) {
|
|
359
|
+
// Store the entry.
|
|
360
|
+
if (action.recordRemoval) {
|
|
361
|
+
formState.page.formData["".concat(action.collection, "LastRemoved")] = _objectSpread({}, entry);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return entry;
|
|
368
|
+
}).filter(function (e) {
|
|
369
|
+
return !!e;
|
|
359
370
|
});
|
|
360
371
|
break;
|
|
361
372
|
|
|
@@ -395,7 +395,7 @@ describe('components', function () {
|
|
|
395
395
|
|
|
396
396
|
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
397
397
|
|
|
398
|
-
pageHeading = form.childNodes[0].childNodes[
|
|
398
|
+
pageHeading = form.childNodes[0].childNodes[1];
|
|
399
399
|
expect(pageHeading.tagName).toEqual('H1');
|
|
400
400
|
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
401
401
|
|