@ukhomeoffice/cop-react-form-renderer 5.97.0 → 5.97.1
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.
|
@@ -18,7 +18,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
18
18
|
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); } // Local imports
|
|
19
19
|
var getCYARowsForContainer = function getCYARowsForContainer(page, container, formData, onAction, fnOverride) {
|
|
20
20
|
if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
|
|
21
|
-
var allComponents = (0, _elevateNestedComponents.default)(container.components
|
|
21
|
+
var allComponents = (0, _elevateNestedComponents.default)(container.components.filter(function (component) {
|
|
22
|
+
return component.show_on_cya === undefined || component.show_on_cya;
|
|
23
|
+
}), formData);
|
|
22
24
|
return allComponents.filter(function (c) {
|
|
23
25
|
return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
|
|
24
26
|
}).flatMap(function (component) {
|
|
@@ -151,6 +151,48 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
|
+
it('should not display nested input components when passed a value of false for "show_on_cya" at the parent component level', function () {
|
|
155
|
+
var FORM_DATA = {
|
|
156
|
+
container: {
|
|
157
|
+
topLevelInput: 'A',
|
|
158
|
+
nestedInput: 'Bravo'
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var PAGE = {
|
|
162
|
+
id: 'page',
|
|
163
|
+
formData: FORM_DATA,
|
|
164
|
+
cya_link: {}
|
|
165
|
+
};
|
|
166
|
+
var NESTED_COMPONENT = {
|
|
167
|
+
type: 'text',
|
|
168
|
+
id: 'nestedInput',
|
|
169
|
+
fieldId: 'nestedInput',
|
|
170
|
+
label: 'Nested input',
|
|
171
|
+
value: 'Bravo'
|
|
172
|
+
};
|
|
173
|
+
var COMPONENT = {
|
|
174
|
+
type: 'checkboxes',
|
|
175
|
+
id: 'topLevelInput',
|
|
176
|
+
fieldId: 'topLevelInput',
|
|
177
|
+
label: 'Top level input',
|
|
178
|
+
show_on_cya: false,
|
|
179
|
+
options: [{
|
|
180
|
+
value: 'A',
|
|
181
|
+
label: 'Option Alpha',
|
|
182
|
+
nested: [NESTED_COMPONENT]
|
|
183
|
+
}]
|
|
184
|
+
};
|
|
185
|
+
var CONTAINER = {
|
|
186
|
+
id: 'container',
|
|
187
|
+
fieldId: 'container',
|
|
188
|
+
type: _models.ComponentTypes.CONTAINER,
|
|
189
|
+
components: [COMPONENT],
|
|
190
|
+
value: FORM_DATA
|
|
191
|
+
};
|
|
192
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
193
|
+
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
194
|
+
expect(ROWS.length).toEqual(0);
|
|
195
|
+
});
|
|
154
196
|
it('should get an appropriate row for a container with a single readonly text component inside a nested container', function () {
|
|
155
197
|
var FORM_DATA = {
|
|
156
198
|
container: {
|