@ukhomeoffice/cop-react-form-renderer 6.0.0 → 6.0.2-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 +139 -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
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
5
|
+
var _setupTests = require("../../setupTests");
|
|
6
|
+
var _SummaryCardDetails = _interopRequireWildcard(require("./SummaryCardDetails"));
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
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.
|
|
16
|
+
// Local imports.
|
|
17
|
+
describe('components.CollectionSummary.SummaryCardDetails', function () {
|
|
18
|
+
var classes = _copReactComponents.Utils.classBuilder(_SummaryCardDetails.DEFAULT_CLASS, [], '');
|
|
19
|
+
var ENTRY = {
|
|
20
|
+
id: '001',
|
|
21
|
+
bannerText: 'A banner',
|
|
22
|
+
titleText: 'A title',
|
|
23
|
+
detailsText: 'Some details',
|
|
24
|
+
index: 0,
|
|
25
|
+
summaryText: 'Full details',
|
|
26
|
+
childCollection: [{
|
|
27
|
+
id: '001',
|
|
28
|
+
childField1: 'alpha',
|
|
29
|
+
childField2: 'bravo'
|
|
30
|
+
}, {
|
|
31
|
+
id: '002',
|
|
32
|
+
childField1: 'alpha',
|
|
33
|
+
childField2: 'bravo'
|
|
34
|
+
}]
|
|
35
|
+
};
|
|
36
|
+
it('should render sections and fields based on summaryLayout config', function () {
|
|
37
|
+
var CHILD_PAGES = [{
|
|
38
|
+
summaryLayout: {
|
|
39
|
+
sections: [{
|
|
40
|
+
title: 'Section 1',
|
|
41
|
+
columns: 2,
|
|
42
|
+
fields: ['fieldA', 'fieldB']
|
|
43
|
+
}, {
|
|
44
|
+
title: 'Section 2',
|
|
45
|
+
columns: 1,
|
|
46
|
+
fields: ['fieldC']
|
|
47
|
+
}]
|
|
48
|
+
},
|
|
49
|
+
components: [{
|
|
50
|
+
fieldId: 'fieldA'
|
|
51
|
+
}, {
|
|
52
|
+
fieldId: 'fieldB'
|
|
53
|
+
}, {
|
|
54
|
+
fieldId: 'fieldC'
|
|
55
|
+
}]
|
|
56
|
+
}];
|
|
57
|
+
var MASTER_PAGE = {
|
|
58
|
+
childPages: CHILD_PAGES
|
|
59
|
+
};
|
|
60
|
+
var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
61
|
+
masterPage: MASTER_PAGE,
|
|
62
|
+
childMasterPages: [],
|
|
63
|
+
formData: {},
|
|
64
|
+
entryData: ENTRY
|
|
65
|
+
})),
|
|
66
|
+
container = _renderWithValidation.container;
|
|
67
|
+
|
|
68
|
+
// Function to find an element by its text content
|
|
69
|
+
function getByTextContent(parent, text) {
|
|
70
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
71
|
+
return el.textContent === text;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check for section titles
|
|
76
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
77
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
78
|
+
expect(section1Title).not.toBeUndefined();
|
|
79
|
+
expect(section2Title).not.toBeUndefined();
|
|
80
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
81
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
82
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
83
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
84
|
+
});
|
|
85
|
+
it('should render sections if they have show_when checks and pass them', function () {
|
|
86
|
+
var CHILD_PAGES = [{
|
|
87
|
+
summaryLayout: {
|
|
88
|
+
sections: [{
|
|
89
|
+
title: 'Section 1',
|
|
90
|
+
columns: 2,
|
|
91
|
+
fields: ['fieldA', 'fieldB'],
|
|
92
|
+
show_when: [{
|
|
93
|
+
field: 'showSection1',
|
|
94
|
+
op: "=",
|
|
95
|
+
value: true
|
|
96
|
+
}]
|
|
97
|
+
}, {
|
|
98
|
+
title: 'Section 2',
|
|
99
|
+
columns: 1,
|
|
100
|
+
fields: ['fieldC']
|
|
101
|
+
}]
|
|
102
|
+
},
|
|
103
|
+
components: [{
|
|
104
|
+
fieldId: 'fieldA'
|
|
105
|
+
}, {
|
|
106
|
+
fieldId: 'fieldB'
|
|
107
|
+
}, {
|
|
108
|
+
fieldId: 'fieldC'
|
|
109
|
+
}]
|
|
110
|
+
}];
|
|
111
|
+
var MASTER_PAGE = {
|
|
112
|
+
childPages: CHILD_PAGES
|
|
113
|
+
};
|
|
114
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
115
|
+
showSection1: true
|
|
116
|
+
});
|
|
117
|
+
var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
118
|
+
masterPage: MASTER_PAGE,
|
|
119
|
+
childMasterPages: [],
|
|
120
|
+
formData: {},
|
|
121
|
+
entryData: CUSTOM_ENTRY
|
|
122
|
+
})),
|
|
123
|
+
container = _renderWithValidation2.container;
|
|
124
|
+
|
|
125
|
+
// Function to find an element by its text content
|
|
126
|
+
function getByTextContent(parent, text) {
|
|
127
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
128
|
+
return el.textContent === text;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Check for section titles
|
|
133
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
134
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
135
|
+
expect(section1Title).not.toBeUndefined();
|
|
136
|
+
expect(section2Title).not.toBeUndefined();
|
|
137
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
138
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
139
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
140
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
141
|
+
});
|
|
142
|
+
it('should not render sections if they have show_when checks and fail them', function () {
|
|
143
|
+
var CHILD_PAGES = [{
|
|
144
|
+
summaryLayout: {
|
|
145
|
+
sections: [{
|
|
146
|
+
title: 'Section 1',
|
|
147
|
+
columns: 2,
|
|
148
|
+
fields: ['fieldA', 'fieldB'],
|
|
149
|
+
show_when: [{
|
|
150
|
+
field: 'showSection1',
|
|
151
|
+
op: "=",
|
|
152
|
+
value: true
|
|
153
|
+
}]
|
|
154
|
+
}, {
|
|
155
|
+
title: 'Section 2',
|
|
156
|
+
columns: 1,
|
|
157
|
+
fields: ['fieldC']
|
|
158
|
+
}]
|
|
159
|
+
},
|
|
160
|
+
components: [{
|
|
161
|
+
fieldId: 'fieldA'
|
|
162
|
+
}, {
|
|
163
|
+
fieldId: 'fieldB'
|
|
164
|
+
}, {
|
|
165
|
+
fieldId: 'fieldC'
|
|
166
|
+
}]
|
|
167
|
+
}];
|
|
168
|
+
var MASTER_PAGE = {
|
|
169
|
+
childPages: CHILD_PAGES
|
|
170
|
+
};
|
|
171
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
172
|
+
showSection1: false
|
|
173
|
+
});
|
|
174
|
+
var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
175
|
+
masterPage: MASTER_PAGE,
|
|
176
|
+
childMasterPages: [],
|
|
177
|
+
formData: {},
|
|
178
|
+
entryData: CUSTOM_ENTRY
|
|
179
|
+
})),
|
|
180
|
+
container = _renderWithValidation3.container;
|
|
181
|
+
|
|
182
|
+
// Function to find an element by its text content
|
|
183
|
+
function getByTextContent(parent, text) {
|
|
184
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
185
|
+
return el.textContent === text;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Check for section titles
|
|
190
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
191
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
192
|
+
expect(section1Title).toBeUndefined();
|
|
193
|
+
expect(section2Title).not.toBeUndefined();
|
|
194
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
195
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
196
|
+
});
|
|
197
|
+
it('should not render sections on pages that fail show_when checks', function () {
|
|
198
|
+
var CHILD_PAGES = [{
|
|
199
|
+
show_when: [{
|
|
200
|
+
field: 'testField',
|
|
201
|
+
op: '=',
|
|
202
|
+
value: true
|
|
203
|
+
}],
|
|
204
|
+
summaryLayout: {
|
|
205
|
+
sections: [{
|
|
206
|
+
title: 'Section 1',
|
|
207
|
+
columns: 2,
|
|
208
|
+
fields: ['fieldA', 'fieldB'],
|
|
209
|
+
show_when: [{
|
|
210
|
+
field: 'showSection1',
|
|
211
|
+
op: "=",
|
|
212
|
+
value: true
|
|
213
|
+
}]
|
|
214
|
+
}, {
|
|
215
|
+
title: 'Section 2',
|
|
216
|
+
columns: 1,
|
|
217
|
+
fields: ['fieldC']
|
|
218
|
+
}]
|
|
219
|
+
},
|
|
220
|
+
components: [{
|
|
221
|
+
fieldId: 'fieldA'
|
|
222
|
+
}, {
|
|
223
|
+
fieldId: 'fieldB'
|
|
224
|
+
}, {
|
|
225
|
+
fieldId: 'fieldC'
|
|
226
|
+
}]
|
|
227
|
+
}];
|
|
228
|
+
var MASTER_PAGE = {
|
|
229
|
+
childPages: CHILD_PAGES
|
|
230
|
+
};
|
|
231
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
232
|
+
showSection1: false
|
|
233
|
+
});
|
|
234
|
+
var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
235
|
+
masterPage: MASTER_PAGE,
|
|
236
|
+
childMasterPages: [],
|
|
237
|
+
formData: {
|
|
238
|
+
testField: false
|
|
239
|
+
},
|
|
240
|
+
entryData: CUSTOM_ENTRY
|
|
241
|
+
})),
|
|
242
|
+
container = _renderWithValidation4.container;
|
|
243
|
+
|
|
244
|
+
// Function to find an element by its text content
|
|
245
|
+
function getByTextContent(parent, text) {
|
|
246
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
247
|
+
return el.textContent === text;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Check for section titles
|
|
252
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
253
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
254
|
+
expect(section1Title).toBeUndefined();
|
|
255
|
+
expect(section2Title).toBeUndefined();
|
|
256
|
+
});
|
|
257
|
+
it('should render child collections', function () {
|
|
258
|
+
var CHILD_MASTER_PAGES = [{
|
|
259
|
+
collection: {
|
|
260
|
+
name: 'childCollection'
|
|
261
|
+
},
|
|
262
|
+
childPages: [{
|
|
263
|
+
components: [{
|
|
264
|
+
fieldId: 'childField1'
|
|
265
|
+
}, {
|
|
266
|
+
fieldId: 'childField2'
|
|
267
|
+
}],
|
|
268
|
+
summaryLayout: {
|
|
269
|
+
sections: [{
|
|
270
|
+
title: 'Hidden Title',
|
|
271
|
+
columns: 2,
|
|
272
|
+
fields: ['childfield1', 'childfield2']
|
|
273
|
+
}]
|
|
274
|
+
}
|
|
275
|
+
}]
|
|
276
|
+
}];
|
|
277
|
+
var CHILD_PAGES = [{
|
|
278
|
+
summaryLayout: {
|
|
279
|
+
sections: [{
|
|
280
|
+
type: 'childCollection',
|
|
281
|
+
collectionName: 'childCollection',
|
|
282
|
+
title: 'Children'
|
|
283
|
+
}]
|
|
284
|
+
},
|
|
285
|
+
components: [{
|
|
286
|
+
fieldId: 'fieldA'
|
|
287
|
+
}, {
|
|
288
|
+
fieldId: 'fieldB'
|
|
289
|
+
}, {
|
|
290
|
+
fieldId: 'fieldC'
|
|
291
|
+
}]
|
|
292
|
+
}];
|
|
293
|
+
var MASTER_PAGE = {
|
|
294
|
+
childPages: [].concat(CHILD_PAGES, CHILD_MASTER_PAGES)
|
|
295
|
+
};
|
|
296
|
+
var CHILD_COLLECTIONS = ['childCollection'];
|
|
297
|
+
var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
298
|
+
masterPage: MASTER_PAGE,
|
|
299
|
+
childCollections: CHILD_COLLECTIONS,
|
|
300
|
+
formData: {},
|
|
301
|
+
entryData: ENTRY
|
|
302
|
+
})),
|
|
303
|
+
container = _renderWithValidation5.container;
|
|
304
|
+
|
|
305
|
+
// Function to find an element by its text content
|
|
306
|
+
function getByTextContent(parent, text) {
|
|
307
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
308
|
+
return el.textContent === text;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
var childCollectionSectionTitle = getByTextContent(container, 'Children');
|
|
312
|
+
expect(childCollectionSectionTitle).not.toBeUndefined();
|
|
313
|
+
var childSectionTitles = getByTextContent(container, 'Hidden Title');
|
|
314
|
+
expect(childSectionTitles).toBeUndefined(); // Individual section title for child collections should be hidden.
|
|
315
|
+
|
|
316
|
+
var childFields = container.querySelectorAll(".".concat(classes('field')));
|
|
317
|
+
expect(childFields.length).toEqual(4); // Two for each entry in the child collection.
|
|
318
|
+
});
|
|
319
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"id": "componentA",
|
|
5
|
+
"type": "radios",
|
|
6
|
+
"label": "Field A",
|
|
7
|
+
"fieldId": "fieldA",
|
|
8
|
+
"required": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "componentB",
|
|
12
|
+
"type": "collection",
|
|
13
|
+
"label": "Component B",
|
|
14
|
+
"fieldId": "componentB"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"pages": [
|
|
18
|
+
{
|
|
19
|
+
"id": "pageA",
|
|
20
|
+
"show_when": {
|
|
21
|
+
"op": "=",
|
|
22
|
+
"field": "componentA",
|
|
23
|
+
"value": "hide"
|
|
24
|
+
},
|
|
25
|
+
"components": [
|
|
26
|
+
{
|
|
27
|
+
"id": "componentB",
|
|
28
|
+
"use": "componentB"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "pageB",
|
|
34
|
+
"show_when": {
|
|
35
|
+
"op": "=",
|
|
36
|
+
"field": "componentA",
|
|
37
|
+
"value": "show"
|
|
38
|
+
},
|
|
39
|
+
"components": [
|
|
40
|
+
{
|
|
41
|
+
"id": "componentB",
|
|
42
|
+
"use": "componentB"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "pageC",
|
|
48
|
+
"show_when": {
|
|
49
|
+
"op": "=",
|
|
50
|
+
"field": "componentA",
|
|
51
|
+
"value": "hide"
|
|
52
|
+
},
|
|
53
|
+
"components": [
|
|
54
|
+
{
|
|
55
|
+
"id": "componentB",
|
|
56
|
+
"use": "componentB"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "example-form",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"name": "example-form",
|
|
5
|
+
"title": "Example form",
|
|
6
|
+
"type": "form",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"id": "alpha",
|
|
10
|
+
"fieldId": "alpha",
|
|
11
|
+
"label": "Alpha",
|
|
12
|
+
"type": "text"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "bravo",
|
|
16
|
+
"fieldId": "bravo",
|
|
17
|
+
"label": "Bravo",
|
|
18
|
+
"type": "text"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "person",
|
|
22
|
+
"fieldId": "person",
|
|
23
|
+
"type": "container",
|
|
24
|
+
"components": [
|
|
25
|
+
{
|
|
26
|
+
"id": "charlie",
|
|
27
|
+
"fieldId": "charlie",
|
|
28
|
+
"label": "Charlie",
|
|
29
|
+
"type": "text",
|
|
30
|
+
"show_when": {
|
|
31
|
+
"op": "=",
|
|
32
|
+
"field": "bravo",
|
|
33
|
+
"value": "bravo"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "delta",
|
|
38
|
+
"fieldId": "delta",
|
|
39
|
+
"label": "Delta",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"show_when": {
|
|
42
|
+
"op": "=",
|
|
43
|
+
"field": "bravo",
|
|
44
|
+
"value": "another"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "gamma",
|
|
51
|
+
"fieldId": "gamma",
|
|
52
|
+
"label": "Gamma",
|
|
53
|
+
"type": "text"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "epsilon",
|
|
57
|
+
"fieldId": "epsilon",
|
|
58
|
+
"label": "Epsilon",
|
|
59
|
+
"type": "text"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"pages": [
|
|
63
|
+
{
|
|
64
|
+
"id": "general",
|
|
65
|
+
"name": "general",
|
|
66
|
+
"title": "General information",
|
|
67
|
+
"components": [
|
|
68
|
+
{
|
|
69
|
+
"use": "alpha"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"use": "bravo"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"use": "person"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"use": "gamma"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"use": "epsilon"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"actions": [
|
|
85
|
+
"submit",
|
|
86
|
+
{
|
|
87
|
+
"type": "cancel",
|
|
88
|
+
"page": "",
|
|
89
|
+
"validate": false,
|
|
90
|
+
"classModifiers": "secondary",
|
|
91
|
+
"label": "Cancel"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-with-collection",
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"id": "componentA",
|
|
6
|
+
"fieldId": "componentA"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "itemCategory",
|
|
10
|
+
"fieldId": "itemCategory"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"pages": [
|
|
14
|
+
{
|
|
15
|
+
"id": "pageA",
|
|
16
|
+
"name": "Page A",
|
|
17
|
+
"components": [
|
|
18
|
+
{
|
|
19
|
+
"use": "componentA"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "pageB",
|
|
25
|
+
"deleteCollectionWhenHidden": true,
|
|
26
|
+
"collection": {
|
|
27
|
+
"name": "componentAs",
|
|
28
|
+
"labels": {
|
|
29
|
+
"item": "Component A ${index}"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"name": "pageB",
|
|
33
|
+
"show_when": [
|
|
34
|
+
{
|
|
35
|
+
"op": "=",
|
|
36
|
+
"field": "componentA",
|
|
37
|
+
"value": true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"components": [
|
|
41
|
+
{
|
|
42
|
+
"use": "itemCategory"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "form-with-collection",
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"id": "componentA",
|
|
6
|
+
"fieldId": "componentA"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "itemCategory",
|
|
10
|
+
"fieldId": "itemCategory"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"pages": [
|
|
14
|
+
{
|
|
15
|
+
"id": "pageA",
|
|
16
|
+
"name": "Page A",
|
|
17
|
+
"components": [
|
|
18
|
+
{
|
|
19
|
+
"use": "componentA"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "pageB",
|
|
25
|
+
"collection": {
|
|
26
|
+
"name": "componentAs",
|
|
27
|
+
"labels": {
|
|
28
|
+
"item": "Component A ${index}"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"name": "pageB",
|
|
32
|
+
"show_when": [
|
|
33
|
+
{
|
|
34
|
+
"op": "=",
|
|
35
|
+
"field": "componentA",
|
|
36
|
+
"value": true
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"components": [
|
|
40
|
+
{
|
|
41
|
+
"use": "itemCategory"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|