@ukhomeoffice/cop-react-form-renderer 4.9.1 → 4.10.0
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.
|
@@ -9,6 +9,8 @@ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
|
9
9
|
|
|
10
10
|
var _models = require("../../models");
|
|
11
11
|
|
|
12
|
+
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
13
|
+
|
|
12
14
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
13
15
|
|
|
14
16
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
@@ -28,12 +30,7 @@ var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
|
|
|
28
30
|
pageId: page.id,
|
|
29
31
|
key: ((_page$components$0$la = page.components[0].labels) === null || _page$components$0$la === void 0 ? void 0 : _page$components$0$la.empty) || 'Nothing entered',
|
|
30
32
|
required: page.required,
|
|
31
|
-
action:
|
|
32
|
-
page: page.id,
|
|
33
|
-
label: "Change",
|
|
34
|
-
aria_suffix: page.cya_link.aria_suffix,
|
|
35
|
-
onAction: onAction
|
|
36
|
-
}
|
|
33
|
+
action: (0, _getCYAAction.default)(false, page, onAction)
|
|
37
34
|
}];
|
|
38
35
|
};
|
|
39
36
|
|
|
@@ -54,9 +54,19 @@ var getIndexOfMatchingValueIn = function getIndexOfMatchingValueIn(config, data)
|
|
|
54
54
|
|
|
55
55
|
if (index === ignore) {
|
|
56
56
|
return true;
|
|
57
|
-
}
|
|
57
|
+
} // Here we're simply checking if value matches the entry itself. This
|
|
58
|
+
// will be enough of a check for arrays of simple values.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if (entry === value) {
|
|
62
|
+
result = index;
|
|
63
|
+
return false;
|
|
64
|
+
} // If the last check failed and there is a config.key defined, then
|
|
65
|
+
// we're most likely checking an array of objects and should use the
|
|
66
|
+
// key to index in and find a matching value.
|
|
67
|
+
|
|
58
68
|
|
|
59
|
-
if (
|
|
69
|
+
if (config.key && (0, _getSourceData.default)(entry, config.key) === value) {
|
|
60
70
|
result = index;
|
|
61
71
|
return false;
|
|
62
72
|
}
|
|
@@ -6,7 +6,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
6
6
|
|
|
7
7
|
describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
8
8
|
var DATA = {
|
|
9
|
-
arrayOfValues: ['abc', 'bcd', 'cde', 'def'
|
|
9
|
+
arrayOfValues: ['abc', 'bcd', 'cde', 'def', {
|
|
10
|
+
root: {
|
|
11
|
+
branch: 'leaf'
|
|
12
|
+
}
|
|
13
|
+
}],
|
|
10
14
|
cutoffIndex: 1,
|
|
11
15
|
ignoreIndex: 2,
|
|
12
16
|
valueToSearchFor: 'cde',
|
|
@@ -40,6 +44,16 @@ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
|
40
44
|
var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
|
|
41
45
|
expect(result).toEqual('2');
|
|
42
46
|
});
|
|
47
|
+
it('Should handle interpolated string for key', function () {
|
|
48
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
49
|
+
var CONFIG = {
|
|
50
|
+
target: 'arrayOfValues',
|
|
51
|
+
key: 'root.branch',
|
|
52
|
+
value: 'leaf'
|
|
53
|
+
};
|
|
54
|
+
var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
|
|
55
|
+
expect(result).toEqual('4');
|
|
56
|
+
});
|
|
43
57
|
it('Should handle a cutoff value being specified', function () {
|
|
44
58
|
var CONFIG = {
|
|
45
59
|
target: 'arrayOfValues',
|