@ukhomeoffice/cop-react-form-renderer 5.72.0 → 5.73.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,7 +92,7 @@ var RenderListView = function RenderListView(_ref) {
|
|
|
92
92
|
var component = elevatedComponents.find(function (comp) {
|
|
93
93
|
return comp.fieldId === fieldId;
|
|
94
94
|
});
|
|
95
|
-
if (!component
|
|
95
|
+
if (!component) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
98
|
return (0, _getComponentRowForCYA.default)(childPage, component, listClass, entryData);
|
|
@@ -10,6 +10,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
10
10
|
/**
|
|
11
11
|
* @param {*} value - the value to check.
|
|
12
12
|
* @param {string} config.collectionPath - the path to the collection within formData
|
|
13
|
+
* @param {string} config.caseInsensitive - true to ignore case, assumes string values
|
|
13
14
|
* @param {object} component - the component definition
|
|
14
15
|
* @param {object} formData - the current form data
|
|
15
16
|
* @returns true if components value is not the same in any other entry in the collection
|
|
@@ -28,6 +29,9 @@ var mustBeUniqueInCollection = function mustBeUniqueInCollection(value, config,
|
|
|
28
29
|
return false;
|
|
29
30
|
}
|
|
30
31
|
;
|
|
32
|
+
if (config.caseInsensitive && typeof value === 'string' && typeof entry[component.id] === 'string') {
|
|
33
|
+
return entry[component.id].toUpperCase() === value.toUpperCase();
|
|
34
|
+
}
|
|
31
35
|
return entry[component.id] === value;
|
|
32
36
|
});
|
|
33
37
|
return !result;
|
|
@@ -121,6 +121,42 @@ describe('utils', function () {
|
|
|
121
121
|
}), COMPONENT_NESTED, FORM_DATA);
|
|
122
122
|
expect(result).toBeFalsy();
|
|
123
123
|
});
|
|
124
|
+
test('should return true if other entries have the same value for this field in a different case', function () {
|
|
125
|
+
var FORM_DATA = {
|
|
126
|
+
namesActiveId: 2,
|
|
127
|
+
names: [{
|
|
128
|
+
id: 1,
|
|
129
|
+
firstName: 'ALPHA'
|
|
130
|
+
}, {
|
|
131
|
+
id: 2,
|
|
132
|
+
firstName: 'alpha'
|
|
133
|
+
}, {
|
|
134
|
+
id: 3,
|
|
135
|
+
firstName: 'bravo'
|
|
136
|
+
}]
|
|
137
|
+
};
|
|
138
|
+
var result = (0, _mustBeUniqueInCollection.default)('alpha', CONFIG, COMPONENT, FORM_DATA);
|
|
139
|
+
expect(result).toBeTruthy();
|
|
140
|
+
});
|
|
141
|
+
test('should return false if other entries have the same value for this field in a different case and caseInsensitive is true', function () {
|
|
142
|
+
var FORM_DATA = {
|
|
143
|
+
namesActiveId: 2,
|
|
144
|
+
names: [{
|
|
145
|
+
id: 1,
|
|
146
|
+
firstName: 'ALPHA'
|
|
147
|
+
}, {
|
|
148
|
+
id: 2,
|
|
149
|
+
firstName: 'alpha'
|
|
150
|
+
}, {
|
|
151
|
+
id: 3,
|
|
152
|
+
firstName: 'bravo'
|
|
153
|
+
}]
|
|
154
|
+
};
|
|
155
|
+
var result = (0, _mustBeUniqueInCollection.default)('alpha', _objectSpread(_objectSpread({}, CONFIG), {}, {
|
|
156
|
+
caseInsensitive: true
|
|
157
|
+
}), COMPONENT, FORM_DATA);
|
|
158
|
+
expect(result).toBeFalsy();
|
|
159
|
+
});
|
|
124
160
|
});
|
|
125
161
|
});
|
|
126
162
|
});
|