@ukhomeoffice/cop-react-form-renderer 6.0.0 → 6.0.1-peter
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/CheckYourAnswers/CheckYourAnswers.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.js +3 -1
- package/dist/components/CollectionSummary/BannerStrip.scss +7 -3
- package/dist/components/CollectionSummary/CollectionSummary.js +34 -7
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +82 -4
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.js +9 -5
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +24 -3
- package/dist/components/CollectionSummary/SummaryCard.js +18 -45
- package/dist/components/CollectionSummary/SummaryCard.scss +4 -147
- package/dist/components/CollectionSummary/SummaryCard.test.js +53 -191
- package/dist/components/CollectionSummary/SummaryCardDetails.js +117 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +158 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +319 -0
- package/dist/components/FormPage/FormPage.scss +1 -1
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +4 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +61 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +4 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +8 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +3 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +5 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +3 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +10 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +11 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +96 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +47 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +46 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +48 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +134 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +113 -0
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +20 -0
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +56 -0
- package/dist/components/FormRenderer/helpers/index.js +3 -1
- package/dist/components/FormRenderer/onPageAction.js +8 -2
- package/dist/components/FormRenderer/onPageAction.test.js +5 -0
- package/dist/components/SummaryList/SummaryList.scss +2 -2
- package/dist/components/TaskList/TaskList.scss +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +15 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +48 -1
- package/dist/utils/CollectionPage/setCollectionPageData.js +2 -2
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +31 -0
- package/dist/utils/FormPage/getConditionalText.js +54 -0
- package/dist/utils/FormPage/getConditionalText.test.js +162 -0
- package/dist/utils/FormPage/index.js +5 -2
- package/package.json +4 -4
- package/dist/utils/FormPage/getPageTitle.js +0 -32
- package/dist/utils/FormPage/getPageTitle.test.js +0 -138
|
@@ -1231,14 +1231,30 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1231
1231
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
1232
1232
|
expect(headerDetails.textContent).toEqual(DETAILS);
|
|
1233
1233
|
});
|
|
1234
|
-
it('should
|
|
1234
|
+
it('should render conditional details', function () {
|
|
1235
1235
|
var CONFIG = {
|
|
1236
1236
|
title: 'Title',
|
|
1237
|
-
details:
|
|
1237
|
+
details: [{
|
|
1238
|
+
text: 'Details A',
|
|
1239
|
+
show_when: [{
|
|
1240
|
+
field: 'field',
|
|
1241
|
+
op: '!=',
|
|
1242
|
+
value: true
|
|
1243
|
+
}]
|
|
1244
|
+
}, {
|
|
1245
|
+
text: 'Details B',
|
|
1246
|
+
show_when: [{
|
|
1247
|
+
field: 'field',
|
|
1248
|
+
op: '=',
|
|
1249
|
+
value: true
|
|
1250
|
+
}]
|
|
1251
|
+
}]
|
|
1238
1252
|
};
|
|
1239
1253
|
var _renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1240
1254
|
id: ID,
|
|
1241
|
-
entryData: ENTRY,
|
|
1255
|
+
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1256
|
+
field: true
|
|
1257
|
+
}),
|
|
1242
1258
|
config: CONFIG,
|
|
1243
1259
|
parentCollectionName: "parent",
|
|
1244
1260
|
pages: [],
|
|
@@ -1250,6 +1266,30 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1250
1266
|
container = _renderWithValidation31.container;
|
|
1251
1267
|
var _checkSetup30 = checkSetup(container),
|
|
1252
1268
|
headerContentDiv = _checkSetup30.headerContentDiv;
|
|
1269
|
+
var headerDetails = headerContentDiv.children[1];
|
|
1270
|
+
expect(headerDetails.tagName).toEqual('DIV');
|
|
1271
|
+
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
1272
|
+
expect(headerDetails.textContent).toEqual('Details B');
|
|
1273
|
+
});
|
|
1274
|
+
it('should not render details when they are empty', function () {
|
|
1275
|
+
var CONFIG = {
|
|
1276
|
+
title: 'Title',
|
|
1277
|
+
details: ''
|
|
1278
|
+
};
|
|
1279
|
+
var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1280
|
+
id: ID,
|
|
1281
|
+
entryData: ENTRY,
|
|
1282
|
+
config: CONFIG,
|
|
1283
|
+
parentCollectionName: "parent",
|
|
1284
|
+
pages: [],
|
|
1285
|
+
formData: {},
|
|
1286
|
+
masterPage: {
|
|
1287
|
+
childPages: []
|
|
1288
|
+
}
|
|
1289
|
+
})),
|
|
1290
|
+
container = _renderWithValidation32.container;
|
|
1291
|
+
var _checkSetup31 = checkSetup(container),
|
|
1292
|
+
headerContentDiv = _checkSetup31.headerContentDiv;
|
|
1253
1293
|
// If no details are provided, we expect only the header title to be rendered.
|
|
1254
1294
|
expect(headerContentDiv.children.length).toEqual(1);
|
|
1255
1295
|
var headerTitle = headerContentDiv.children[0];
|
|
@@ -1264,7 +1304,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1264
1304
|
title: 'Title',
|
|
1265
1305
|
details: DETAILS
|
|
1266
1306
|
};
|
|
1267
|
-
var
|
|
1307
|
+
var _renderWithValidation33 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1268
1308
|
id: ID,
|
|
1269
1309
|
entryData: INTERPOLATED_ENTRY,
|
|
1270
1310
|
config: CONFIG,
|
|
@@ -1275,9 +1315,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1275
1315
|
childPages: []
|
|
1276
1316
|
}
|
|
1277
1317
|
})),
|
|
1278
|
-
container =
|
|
1279
|
-
var
|
|
1280
|
-
headerContentDiv =
|
|
1318
|
+
container = _renderWithValidation33.container;
|
|
1319
|
+
var _checkSetup32 = checkSetup(container),
|
|
1320
|
+
headerContentDiv = _checkSetup32.headerContentDiv;
|
|
1281
1321
|
var headerDetails = headerContentDiv.children[1];
|
|
1282
1322
|
var expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
|
|
1283
1323
|
expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
|
|
@@ -1286,7 +1326,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1286
1326
|
var CONFIG = {
|
|
1287
1327
|
title: 'Title'
|
|
1288
1328
|
};
|
|
1289
|
-
var
|
|
1329
|
+
var _renderWithValidation34 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1290
1330
|
id: ID,
|
|
1291
1331
|
entryData: ENTRY,
|
|
1292
1332
|
config: CONFIG,
|
|
@@ -1297,9 +1337,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1297
1337
|
childPages: []
|
|
1298
1338
|
}
|
|
1299
1339
|
})),
|
|
1300
|
-
container =
|
|
1301
|
-
var
|
|
1302
|
-
headerContentDiv =
|
|
1340
|
+
container = _renderWithValidation34.container;
|
|
1341
|
+
var _checkSetup33 = checkSetup(container),
|
|
1342
|
+
headerContentDiv = _checkSetup33.headerContentDiv;
|
|
1303
1343
|
var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
1304
1344
|
expect(headerDetails).toBeNull();
|
|
1305
1345
|
});
|
|
@@ -1309,7 +1349,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1309
1349
|
title: 'Title',
|
|
1310
1350
|
details: DETAILS
|
|
1311
1351
|
};
|
|
1312
|
-
var
|
|
1352
|
+
var _renderWithValidation35 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1313
1353
|
id: ID,
|
|
1314
1354
|
entryData: ENTRY,
|
|
1315
1355
|
config: CONFIG,
|
|
@@ -1321,187 +1361,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1321
1361
|
childPages: []
|
|
1322
1362
|
}
|
|
1323
1363
|
})),
|
|
1324
|
-
container =
|
|
1364
|
+
container = _renderWithValidation35.container;
|
|
1325
1365
|
var detailsComponent = container.querySelector('.details');
|
|
1326
1366
|
expect(detailsComponent).toBeNull();
|
|
1327
1367
|
});
|
|
1328
1368
|
});
|
|
1329
|
-
describe('SummaryLayout config behavior', function () {
|
|
1330
|
-
it('should render sections and fields based on summaryLayout config', function () {
|
|
1331
|
-
var CHILD_PAGES = [{
|
|
1332
|
-
summaryLayout: {
|
|
1333
|
-
sections: [{
|
|
1334
|
-
title: 'Section 1',
|
|
1335
|
-
columns: 2,
|
|
1336
|
-
fields: ['fieldA', 'fieldB']
|
|
1337
|
-
}, {
|
|
1338
|
-
title: 'Section 2',
|
|
1339
|
-
columns: 1,
|
|
1340
|
-
fields: ['fieldC']
|
|
1341
|
-
}]
|
|
1342
|
-
},
|
|
1343
|
-
components: [{
|
|
1344
|
-
fieldId: 'fieldA'
|
|
1345
|
-
}, {
|
|
1346
|
-
fieldId: 'fieldB'
|
|
1347
|
-
}, {
|
|
1348
|
-
fieldId: 'fieldC'
|
|
1349
|
-
}]
|
|
1350
|
-
}];
|
|
1351
|
-
var CONFIG = {
|
|
1352
|
-
title: 'Title'
|
|
1353
|
-
};
|
|
1354
|
-
var _renderWithValidation35 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1355
|
-
id: ID,
|
|
1356
|
-
entryData: ENTRY,
|
|
1357
|
-
config: CONFIG,
|
|
1358
|
-
parentCollectionName: "parent",
|
|
1359
|
-
pages: CHILD_PAGES,
|
|
1360
|
-
formData: {},
|
|
1361
|
-
masterPage: {
|
|
1362
|
-
childPages: CHILD_PAGES
|
|
1363
|
-
}
|
|
1364
|
-
})),
|
|
1365
|
-
container = _renderWithValidation35.container;
|
|
1366
|
-
|
|
1367
|
-
// Function to find an element by its text content
|
|
1368
|
-
function getByTextContent(parent, text) {
|
|
1369
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
1370
|
-
return el.textContent === text;
|
|
1371
|
-
});
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
// Check for section titles
|
|
1375
|
-
var section1Title = getByTextContent(container, 'Section 1');
|
|
1376
|
-
var section2Title = getByTextContent(container, 'Section 2');
|
|
1377
|
-
expect(section1Title).not.toBeUndefined();
|
|
1378
|
-
expect(section2Title).not.toBeUndefined();
|
|
1379
|
-
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1380
|
-
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
1381
|
-
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1382
|
-
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1383
|
-
});
|
|
1384
|
-
it('should render sections if they have show_when checks and pass them', function () {
|
|
1385
|
-
var CHILD_PAGES = [{
|
|
1386
|
-
summaryLayout: {
|
|
1387
|
-
sections: [{
|
|
1388
|
-
title: 'Section 1',
|
|
1389
|
-
columns: 2,
|
|
1390
|
-
fields: ['fieldA', 'fieldB'],
|
|
1391
|
-
show_when: [{
|
|
1392
|
-
field: 'showSection1',
|
|
1393
|
-
op: "=",
|
|
1394
|
-
value: true
|
|
1395
|
-
}]
|
|
1396
|
-
}, {
|
|
1397
|
-
title: 'Section 2',
|
|
1398
|
-
columns: 1,
|
|
1399
|
-
fields: ['fieldC']
|
|
1400
|
-
}]
|
|
1401
|
-
},
|
|
1402
|
-
components: [{
|
|
1403
|
-
fieldId: 'fieldA'
|
|
1404
|
-
}, {
|
|
1405
|
-
fieldId: 'fieldB'
|
|
1406
|
-
}, {
|
|
1407
|
-
fieldId: 'fieldC'
|
|
1408
|
-
}]
|
|
1409
|
-
}];
|
|
1410
|
-
var CONFIG = {
|
|
1411
|
-
title: 'Title'
|
|
1412
|
-
};
|
|
1413
|
-
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1414
|
-
showSection1: true
|
|
1415
|
-
});
|
|
1416
|
-
var _renderWithValidation36 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1417
|
-
id: ID,
|
|
1418
|
-
entryData: CUSTOM_ENTRY,
|
|
1419
|
-
config: CONFIG,
|
|
1420
|
-
parentCollectionName: "parent",
|
|
1421
|
-
pages: CHILD_PAGES,
|
|
1422
|
-
formData: {},
|
|
1423
|
-
masterPage: {
|
|
1424
|
-
childPages: CHILD_PAGES
|
|
1425
|
-
}
|
|
1426
|
-
})),
|
|
1427
|
-
container = _renderWithValidation36.container;
|
|
1428
|
-
|
|
1429
|
-
// Function to find an element by its text content
|
|
1430
|
-
function getByTextContent(parent, text) {
|
|
1431
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
1432
|
-
return el.textContent === text;
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
// Check for section titles
|
|
1437
|
-
var section1Title = getByTextContent(container, 'Section 1');
|
|
1438
|
-
var section2Title = getByTextContent(container, 'Section 2');
|
|
1439
|
-
expect(section1Title).not.toBeUndefined();
|
|
1440
|
-
expect(section2Title).not.toBeUndefined();
|
|
1441
|
-
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1442
|
-
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
1443
|
-
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1444
|
-
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1445
|
-
});
|
|
1446
|
-
it('should not render sections if they have show_when checks and fail them', function () {
|
|
1447
|
-
var CHILD_PAGES = [{
|
|
1448
|
-
summaryLayout: {
|
|
1449
|
-
sections: [{
|
|
1450
|
-
title: 'Section 1',
|
|
1451
|
-
columns: 2,
|
|
1452
|
-
fields: ['fieldA', 'fieldB'],
|
|
1453
|
-
show_when: [{
|
|
1454
|
-
field: 'showSection1',
|
|
1455
|
-
op: "=",
|
|
1456
|
-
value: true
|
|
1457
|
-
}]
|
|
1458
|
-
}, {
|
|
1459
|
-
title: 'Section 2',
|
|
1460
|
-
columns: 1,
|
|
1461
|
-
fields: ['fieldC']
|
|
1462
|
-
}]
|
|
1463
|
-
},
|
|
1464
|
-
components: [{
|
|
1465
|
-
fieldId: 'fieldA'
|
|
1466
|
-
}, {
|
|
1467
|
-
fieldId: 'fieldB'
|
|
1468
|
-
}, {
|
|
1469
|
-
fieldId: 'fieldC'
|
|
1470
|
-
}]
|
|
1471
|
-
}];
|
|
1472
|
-
var CONFIG = {
|
|
1473
|
-
title: 'Title'
|
|
1474
|
-
};
|
|
1475
|
-
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1476
|
-
showSection1: false
|
|
1477
|
-
});
|
|
1478
|
-
var _renderWithValidation37 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1479
|
-
id: ID,
|
|
1480
|
-
entryData: CUSTOM_ENTRY,
|
|
1481
|
-
config: CONFIG,
|
|
1482
|
-
parentCollectionName: "parent",
|
|
1483
|
-
pages: CHILD_PAGES,
|
|
1484
|
-
formData: {},
|
|
1485
|
-
masterPage: {
|
|
1486
|
-
childPages: CHILD_PAGES
|
|
1487
|
-
}
|
|
1488
|
-
})),
|
|
1489
|
-
container = _renderWithValidation37.container;
|
|
1490
|
-
|
|
1491
|
-
// Function to find an element by its text content
|
|
1492
|
-
function getByTextContent(parent, text) {
|
|
1493
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
1494
|
-
return el.textContent === text;
|
|
1495
|
-
});
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
// Check for section titles
|
|
1499
|
-
var section1Title = getByTextContent(container, 'Section 1');
|
|
1500
|
-
var section2Title = getByTextContent(container, 'Section 2');
|
|
1501
|
-
expect(section1Title).toBeUndefined();
|
|
1502
|
-
expect(section2Title).not.toBeUndefined();
|
|
1503
|
-
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1504
|
-
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1505
|
-
});
|
|
1506
|
-
});
|
|
1507
1369
|
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _utils = _interopRequireDefault(require("../../utils"));
|
|
10
|
+
var _FormComponent = _interopRequireDefault(require("../FormComponent"));
|
|
11
|
+
require("./SummaryCardDetails.scss");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Global imports.
|
|
21
|
+
// Local imports.
|
|
22
|
+
// Styles.
|
|
23
|
+
var DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-form-summary-card-details';
|
|
24
|
+
var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
25
|
+
var _masterPage$childPage;
|
|
26
|
+
var masterPage = _ref.masterPage,
|
|
27
|
+
childCollections = _ref.childCollections,
|
|
28
|
+
formData = _ref.formData,
|
|
29
|
+
entryData = _ref.entryData,
|
|
30
|
+
classModifiers = _ref.classModifiers,
|
|
31
|
+
hideChildSectionTitles = _ref.hideChildSectionTitles;
|
|
32
|
+
var classes = _utils.default.classBuilder(DEFAULT_CLASS, classModifiers);
|
|
33
|
+
var childMasterPages = (0, _react.useMemo)(function () {
|
|
34
|
+
return childCollections.map(function (childName) {
|
|
35
|
+
return masterPage.childPages.find(function (page) {
|
|
36
|
+
var _page$collection;
|
|
37
|
+
return ((_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : _page$collection.name) === childName;
|
|
38
|
+
});
|
|
39
|
+
}).filter(function (e) {
|
|
40
|
+
return !!e;
|
|
41
|
+
});
|
|
42
|
+
}, [masterPage, childCollections]);
|
|
43
|
+
return (masterPage === null || masterPage === void 0 || (_masterPage$childPage = masterPage.childPages) === null || _masterPage$childPage === void 0 ? void 0 : _masterPage$childPage.filter(function (p) {
|
|
44
|
+
return _utils.default.FormPage.show(p, _objectSpread(_objectSpread({}, formData), entryData));
|
|
45
|
+
}).map(function (childPage) {
|
|
46
|
+
var _childPage$summaryLay;
|
|
47
|
+
var allPageComponents = _utils.default.Component.elevateNested(childPage === null || childPage === void 0 ? void 0 : childPage.components, entryData);
|
|
48
|
+
return (_childPage$summaryLay = childPage.summaryLayout) === null || _childPage$summaryLay === void 0 ? void 0 : _childPage$summaryLay.sections.map(function (section) {
|
|
49
|
+
var _section$fields;
|
|
50
|
+
if (section.show_when && !_utils.default.Condition.meetsAll(section.show_when, _objectSpread(_objectSpread({}, formData), entryData))) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (section.type === 'childCollection') {
|
|
54
|
+
var childMasterPage = childMasterPages.find(function (p) {
|
|
55
|
+
return p.collection.name === section.collectionName;
|
|
56
|
+
});
|
|
57
|
+
var childFormData = entryData[section.collectionName.split('.').pop()] || [];
|
|
58
|
+
if (childMasterPage && childFormData.length > 0) {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h3", {
|
|
60
|
+
className: classes('section-title')
|
|
61
|
+
}, section.title), childFormData.map(function (entry) {
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(SummaryCardDetails, {
|
|
63
|
+
masterPage: childMasterPage,
|
|
64
|
+
childMasterPages: [],
|
|
65
|
+
formData: _objectSpread(_objectSpread(_objectSpread({}, formData), entryData), entry),
|
|
66
|
+
entryData: entry,
|
|
67
|
+
hideChildSectionTitles: true
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
+
key: section.title,
|
|
75
|
+
className: classes('section')
|
|
76
|
+
}, !hideChildSectionTitles && /*#__PURE__*/_react.default.createElement("h3", {
|
|
77
|
+
className: classes('section-title')
|
|
78
|
+
}, section.title), /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
className: classes('section-content', "columns-".concat(section.columns))
|
|
80
|
+
}, (_section$fields = section.fields) === null || _section$fields === void 0 ? void 0 : _section$fields.map(function (fieldId) {
|
|
81
|
+
var component = allPageComponents.find(function (comp) {
|
|
82
|
+
return comp.fieldId === fieldId;
|
|
83
|
+
});
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
key: fieldId,
|
|
86
|
+
className: classes('field')
|
|
87
|
+
}, /*#__PURE__*/_react.default.createElement(_FormComponent.default, {
|
|
88
|
+
component: _objectSpread(_objectSpread({}, component), {}, {
|
|
89
|
+
hint: ''
|
|
90
|
+
}),
|
|
91
|
+
value: entryData[component === null || component === void 0 ? void 0 : component.fieldId],
|
|
92
|
+
formData: entryData,
|
|
93
|
+
wrap: true,
|
|
94
|
+
readonly: true
|
|
95
|
+
}));
|
|
96
|
+
})));
|
|
97
|
+
});
|
|
98
|
+
}).filter(function (e) {
|
|
99
|
+
return !!e;
|
|
100
|
+
})) || null;
|
|
101
|
+
};
|
|
102
|
+
SummaryCardDetails.propTypes = {
|
|
103
|
+
childCollections: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
104
|
+
masterPage: _propTypes.default.shape({
|
|
105
|
+
childPages: _propTypes.default.arrayOf(_propTypes.default.shape({})).isRequired
|
|
106
|
+
}).isRequired,
|
|
107
|
+
formData: _propTypes.default.shape({}).isRequired,
|
|
108
|
+
entryData: _propTypes.default.shape({}).isRequired,
|
|
109
|
+
classModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
110
|
+
hideChildSectionTitles: _propTypes.default.bool
|
|
111
|
+
};
|
|
112
|
+
SummaryCardDetails.defaultProps = {
|
|
113
|
+
childCollections: [],
|
|
114
|
+
classModifiers: null,
|
|
115
|
+
hideChildSectionTitles: false
|
|
116
|
+
};
|
|
117
|
+
var _default = exports.default = SummaryCardDetails;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
$govuk-font-family: 'Roboto', arial, sans-serif;
|
|
2
|
+
|
|
3
|
+
@import "node_modules/govuk-frontend/govuk/_base";
|
|
4
|
+
|
|
5
|
+
.govuk-grid-column-two-thirds:has(.hods-form-summary-card-details) {
|
|
6
|
+
width: 100% !important;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.hods-form-summary-card-details {
|
|
10
|
+
&__section {
|
|
11
|
+
border-bottom: 2px solid #E9EBED;
|
|
12
|
+
|
|
13
|
+
&-title {
|
|
14
|
+
font-weight: bold;
|
|
15
|
+
margin: govuk-spacing(2) 0 govuk-spacing(6) 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-content {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
gap: govuk-spacing(2);
|
|
22
|
+
|
|
23
|
+
.hods-form-summary-card-details__field {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
margin-bottom: govuk-spacing(4);
|
|
26
|
+
|
|
27
|
+
.govuk-label,
|
|
28
|
+
.govuk-fieldset__legend {
|
|
29
|
+
font-weight: bold;
|
|
30
|
+
margin-bottom: govuk-spacing(1) !important;
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
content: " :";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
div.govuk-form-group div:has(img){
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
|
|
41
|
+
.hods-readonly.hods-readonly--success {
|
|
42
|
+
font-size: 0;
|
|
43
|
+
line-height: 0;
|
|
44
|
+
|
|
45
|
+
.cop-upload-preview__thumb {
|
|
46
|
+
display: inline-block;
|
|
47
|
+
margin-right: govuk-spacing(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&--columns-1,
|
|
55
|
+
&--columns-2,
|
|
56
|
+
&--columns-3 {
|
|
57
|
+
position: relative;
|
|
58
|
+
margin-bottom: govuk-spacing(1);
|
|
59
|
+
|
|
60
|
+
&::before {
|
|
61
|
+
content: "";
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
width: 2px;
|
|
65
|
+
height: 100%;
|
|
66
|
+
background-color: #E9EBED;
|
|
67
|
+
left: 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&--columns-2 {
|
|
72
|
+
&::after {
|
|
73
|
+
content: "";
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
width: 2px;
|
|
77
|
+
height: 100%;
|
|
78
|
+
background-color: #E9EBED;
|
|
79
|
+
left: 50%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.hods-form-summary-card-details__field {
|
|
83
|
+
flex: 0 0 calc(50% - 10px);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--columns-3 {
|
|
88
|
+
&::after {
|
|
89
|
+
content: "";
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 0;
|
|
92
|
+
left: 33.333%;
|
|
93
|
+
width: 2px;
|
|
94
|
+
height: 100%;
|
|
95
|
+
background-color: #E9EBED;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.hods-form-summary-card-details__field {
|
|
99
|
+
flex: 0 0 calc(33.333% - 10px);
|
|
100
|
+
|
|
101
|
+
&:nth-child(2)::after {
|
|
102
|
+
content: "";
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 0;
|
|
105
|
+
right: 33.333%;
|
|
106
|
+
width: 2px;
|
|
107
|
+
height: 100%;
|
|
108
|
+
background-color: #E9EBED;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@media (max-width: 640px) {
|
|
117
|
+
.hods-form-summary-card-details {
|
|
118
|
+
&__section {
|
|
119
|
+
&-content {
|
|
120
|
+
display: block;
|
|
121
|
+
|
|
122
|
+
.hods-form-summary-card-details__field {
|
|
123
|
+
width: 100%;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.hods-form-summary-card-details__field:nth-child(2)::after {
|
|
127
|
+
display: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&--columns-2,
|
|
131
|
+
&--columns-3 {
|
|
132
|
+
position: relative;
|
|
133
|
+
margin-bottom: govuk-spacing(1);
|
|
134
|
+
|
|
135
|
+
&::before {
|
|
136
|
+
content: '';
|
|
137
|
+
position: absolute;
|
|
138
|
+
top: 0;
|
|
139
|
+
width: 2px;
|
|
140
|
+
height: 100%;
|
|
141
|
+
background-color: #A9A9A9;
|
|
142
|
+
left: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&::after {
|
|
146
|
+
display: none;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&--columns-3 {
|
|
151
|
+
.hods-form-summary-card-details__field:nth-child(2)::after {
|
|
152
|
+
content: none;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|