@ukhomeoffice/cop-react-form-renderer 5.90.0 → 5.90.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/dist/components/CollectionPage/CollectionPage.js +2 -1
- package/dist/components/FormComponent/Collection.js +2 -1
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +2 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -26
- package/dist/utils/CollectionPage/setCollectionPageData.js +2 -1
- package/package.json +3 -2
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _uuid = require("uuid");
|
|
10
11
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
11
12
|
var _FormPage = _interopRequireDefault(require("../FormPage"));
|
|
12
13
|
var _FormPage2 = require("../FormPage/FormPage");
|
|
@@ -104,7 +105,7 @@ var CollectionPage = function CollectionPage(_ref) {
|
|
|
104
105
|
// If there is no active entry in the collection, we create
|
|
105
106
|
// a new entry and generate a new ID for it.
|
|
106
107
|
// This ID becomes the active ID for the collection.
|
|
107
|
-
var newId =
|
|
108
|
+
var newId = (0, _uuid.v4)();
|
|
108
109
|
reportActiveIdChange(newId);
|
|
109
110
|
reportChange([].concat(data, [_defineProperty({
|
|
110
111
|
id: newId
|
|
@@ -8,6 +8,7 @@ exports.default = exports.DEFAULT_CLASS = void 0;
|
|
|
8
8
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _uuid = require("uuid");
|
|
11
12
|
var _models = require("../../models");
|
|
12
13
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
13
14
|
var _Container = _interopRequireDefault(require("./Container"));
|
|
@@ -78,7 +79,7 @@ var Collection = function Collection(_ref) {
|
|
|
78
79
|
while (1) switch (_context.prev = _context.next) {
|
|
79
80
|
case 0:
|
|
80
81
|
reportChange([].concat(value, [{
|
|
81
|
-
id:
|
|
82
|
+
id: (0, _uuid.v4)()
|
|
82
83
|
}]));
|
|
83
84
|
case 1:
|
|
84
85
|
case "end":
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _uuid = require("uuid");
|
|
7
8
|
var _getCollectionPageData = _interopRequireDefault(require("./getCollectionPageData"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
@@ -33,7 +34,7 @@ var duplicateCollectionPageEntry = function duplicateCollectionPageEntry(collect
|
|
|
33
34
|
if (!entryToDuplicate) {
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
|
-
var newEntryId =
|
|
37
|
+
var newEntryId = (0, _uuid.v4)();
|
|
37
38
|
var newEntry = _objectSpread(_objectSpread(_objectSpread({}, entryToDuplicate), fieldsToAdd), {}, {
|
|
38
39
|
id: newEntryId
|
|
39
40
|
});
|
|
@@ -23,32 +23,6 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
|
|
|
23
23
|
}];
|
|
24
24
|
expect((0, _mergeCollectionPages.default)(PAGES)).toEqual(PAGES);
|
|
25
25
|
});
|
|
26
|
-
it('should merge pages from the same collection into a single page', function () {
|
|
27
|
-
var PAGES = [{
|
|
28
|
-
id: 'page1',
|
|
29
|
-
collection: {
|
|
30
|
-
name: 'collection'
|
|
31
|
-
},
|
|
32
|
-
components: [TEXT_COMP]
|
|
33
|
-
}, {
|
|
34
|
-
id: 'page2',
|
|
35
|
-
collection: {
|
|
36
|
-
name: 'collection'
|
|
37
|
-
},
|
|
38
|
-
components: [DATE_COMP]
|
|
39
|
-
}];
|
|
40
|
-
var RESULT = (0, _mergeCollectionPages.default)(PAGES);
|
|
41
|
-
expect(RESULT.length).toEqual(1);
|
|
42
|
-
expect(RESULT[0]).toMatchObject({
|
|
43
|
-
id: 'page1',
|
|
44
|
-
collection: {
|
|
45
|
-
name: 'collection',
|
|
46
|
-
masterPage: true
|
|
47
|
-
},
|
|
48
|
-
formData: {},
|
|
49
|
-
childPages: PAGES
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
26
|
it('should correctly merge and nest child collection pages under their parents', function () {
|
|
53
27
|
var PAGES = [{
|
|
54
28
|
id: 'page1',
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _uuid = require("uuid");
|
|
7
8
|
var isValidIndex = function isValidIndex(value) {
|
|
8
9
|
return typeof value === 'number' && value >= 0;
|
|
9
10
|
};
|
|
@@ -36,7 +37,7 @@ var setCollectionPageData = function setCollectionPageData(collectionName, newDa
|
|
|
36
37
|
if (!data[name].find(function (e) {
|
|
37
38
|
return e.id === formData["".concat(name, "ActiveId")];
|
|
38
39
|
})) {
|
|
39
|
-
var newEntryId =
|
|
40
|
+
var newEntryId = (0, _uuid.v4)();
|
|
40
41
|
// eslint-disable-next-line no-param-reassign
|
|
41
42
|
formData["".concat(name, "ActiveId")] = formData["".concat(name, "ActiveId")] || newEntryId;
|
|
42
43
|
data[name].push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "5.90.
|
|
3
|
+
"version": "5.90.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|
|
23
|
-
"web-vitals": "^1.0.1"
|
|
23
|
+
"web-vitals": "^1.0.1",
|
|
24
|
+
"uuid": "^8.1.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@babel/cli": "^7.15.4",
|