@ukhomeoffice/cop-react-form-renderer 4.56.1 → 4.58.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.
|
@@ -92,6 +92,19 @@ var getActionRows = function getActionRows(page, item, onAction, labelCount) {
|
|
|
92
92
|
return actions;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
+
var getChangeActionForPage = function getChangeActionForPage(page, item, onAction) {
|
|
96
|
+
return function () {
|
|
97
|
+
var changeCallback = function changeCallback(data) {
|
|
98
|
+
data["".concat(page.collection.name, "ActiveId")] = item.id;
|
|
99
|
+
return data;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
onAction({
|
|
103
|
+
pageId: page.id
|
|
104
|
+
}, changeCallback);
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
95
108
|
var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction) {
|
|
96
109
|
var _page$formData, _page$formData$page$c;
|
|
97
110
|
|
|
@@ -135,7 +148,8 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
135
148
|
}
|
|
136
149
|
|
|
137
150
|
var container = getContainerForPage(p, item, labelCount, full_path);
|
|
138
|
-
var
|
|
151
|
+
var rowChangeAction = getChangeActionForPage(p, item, onAction);
|
|
152
|
+
var containerRows = (0, _getCYARowsForContainer.default)(p, container, item, rowChangeAction);
|
|
139
153
|
rows = rows.concat(containerRows);
|
|
140
154
|
}
|
|
141
155
|
});
|
|
@@ -21,11 +21,13 @@ var _mustBeLongerThan = _interopRequireDefault(require("./mustBeLongerThan"));
|
|
|
21
21
|
|
|
22
22
|
var _mustBeShorterThan = _interopRequireDefault(require("./mustBeShorterThan"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _mustBeGreaterThan = _interopRequireDefault(require("./mustBeGreaterThan"));
|
|
25
|
+
|
|
26
|
+
var _mustBeLessThan = _interopRequireDefault(require("./mustBeLessThan"));
|
|
25
27
|
|
|
26
28
|
var _mustBeNumbersOnly = _interopRequireDefault(require("./mustBeNumbersOnly"));
|
|
27
29
|
|
|
28
|
-
var
|
|
30
|
+
var _mustEnterAtLeastOne = _interopRequireDefault(require("./mustEnterAtLeastOne"));
|
|
29
31
|
|
|
30
32
|
var _mustHaveLessThanDecimalPlaces = _interopRequireDefault(require("./mustHaveLessThanDecimalPlaces"));
|
|
31
33
|
|
|
@@ -46,6 +48,7 @@ var functions = {
|
|
|
46
48
|
mustEnterAtLeastOne: _mustEnterAtLeastOne.default,
|
|
47
49
|
mustBeNumbersOnly: _mustBeNumbersOnly.default,
|
|
48
50
|
mustBeLessThan: _mustBeLessThan.default,
|
|
51
|
+
mustBeGreaterThan: _mustBeGreaterThan.default,
|
|
49
52
|
mustHaveLessThanDecimalPlaces: _mustHaveLessThanDecimalPlaces.default,
|
|
50
53
|
mustSelectOnlyOne: _mustSelectOnlyOne.default
|
|
51
54
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} string - the string to check value.
|
|
10
|
+
* @param {number} config.value - the string.value must be greater than config.value.
|
|
11
|
+
* @returns true if string value is greater than config.value, false if not.
|
|
12
|
+
*/
|
|
13
|
+
var mustBeGreaterThan = function mustBeGreaterThan(string, config) {
|
|
14
|
+
if (!string) {
|
|
15
|
+
// null, undefined and empty strings should be picked up by the required flag
|
|
16
|
+
// and not considered here as they would be valid for optional fields.
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return parseFloat(string) > config.value;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var _default = mustBeGreaterThan;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _mustBeGreaterThan = _interopRequireDefault(require("./mustBeGreaterThan"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
+
|
|
7
|
+
describe('utils', function () {
|
|
8
|
+
describe('Validate', function () {
|
|
9
|
+
describe('additional', function () {
|
|
10
|
+
describe('mustBeGreaterThan', function () {
|
|
11
|
+
test('should return true given a number greater than 10', function () {
|
|
12
|
+
var result = (0, _mustBeGreaterThan.default)('11', {
|
|
13
|
+
value: 10
|
|
14
|
+
});
|
|
15
|
+
expect(result).toEqual(true);
|
|
16
|
+
});
|
|
17
|
+
test('should return false if provided value less than or equal to 10', function () {
|
|
18
|
+
var result1 = (0, _mustBeGreaterThan.default)('9', {
|
|
19
|
+
value: 10
|
|
20
|
+
});
|
|
21
|
+
expect(result1).toBeFalsy();
|
|
22
|
+
var result2 = (0, _mustBeGreaterThan.default)('10', {
|
|
23
|
+
value: 10
|
|
24
|
+
});
|
|
25
|
+
expect(result2).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
test('should return true when string is undefined', function () {
|
|
28
|
+
var result = (0, _mustBeGreaterThan.default)(undefined, {
|
|
29
|
+
value: 10
|
|
30
|
+
});
|
|
31
|
+
expect(result).toEqual(true);
|
|
32
|
+
});
|
|
33
|
+
test('should return true when string is empty', function () {
|
|
34
|
+
var result = (0, _mustBeGreaterThan.default)('', {
|
|
35
|
+
value: 10
|
|
36
|
+
});
|
|
37
|
+
expect(result).toEqual(true);
|
|
38
|
+
});
|
|
39
|
+
test('should return true when string is null', function () {
|
|
40
|
+
var result = (0, _mustBeGreaterThan.default)(null, {
|
|
41
|
+
value: 10
|
|
42
|
+
});
|
|
43
|
+
expect(result).toEqual(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|