@ukhomeoffice/cop-react-form-renderer 5.85.2 → 5.86.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.
- package/dist/components/CollectionSummary/CollectionSummary.js +6 -4
- package/dist/components/CollectionSummary/CollectionSummary.scss +5 -0
- package/dist/components/CollectionSummary/CollectionSummary.test.js +60 -36
- package/dist/components/CollectionSummary/SummaryCard.js +1 -1
- package/dist/components/CollectionSummary/SummaryCard.scss +6 -0
- package/dist/components/CollectionSummary/SummaryCard.test.js +5 -5
- package/dist/components/CollectionSummary/SummaryCardDetails.js +3 -3
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +2 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +1 -1
- package/package.json +1 -1
|
@@ -252,7 +252,9 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
252
252
|
classModifiers: ['secondary']
|
|
253
253
|
},
|
|
254
254
|
onAction: onAction
|
|
255
|
-
}),
|
|
255
|
+
}), /*#__PURE__*/_react.default.createElement("ul", {
|
|
256
|
+
className: "collection-summary-card-list"
|
|
257
|
+
}, data.map(function (entry, index) {
|
|
256
258
|
var isInError = errors.filter(function (e) {
|
|
257
259
|
return e.entryId === entry.id;
|
|
258
260
|
}).length > 0;
|
|
@@ -260,7 +262,7 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
260
262
|
focusOn: (toFocusOn === null || toFocusOn === void 0 ? void 0 : toFocusOn.id) === entry.id
|
|
261
263
|
});
|
|
262
264
|
var key = "".concat(config.fieldId, ".summaryCard").concat(entry.id);
|
|
263
|
-
return /*#__PURE__*/_react.default.createElement(_SummaryCardValidationContext.default, {
|
|
265
|
+
return /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_SummaryCardValidationContext.default, {
|
|
264
266
|
entryId: entry.id,
|
|
265
267
|
topLevelErrors: errors,
|
|
266
268
|
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {
|
|
@@ -296,8 +298,8 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
296
298
|
inError: errors.filter(function (e) {
|
|
297
299
|
return e.entryId === entry.id;
|
|
298
300
|
}).length > 0
|
|
299
|
-
}));
|
|
300
|
-
}), config.card.listView && config.addButton && /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
301
|
+
})));
|
|
302
|
+
})), config.card.listView && config.addButton && /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
301
303
|
id: "".concat(config.fieldId, ".addButton"),
|
|
302
304
|
action: {
|
|
303
305
|
collection: config.collectionName,
|
|
@@ -57,9 +57,23 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
57
57
|
}];
|
|
58
58
|
var ON_ACTION = function ON_ACTION() {};
|
|
59
59
|
var checkSetup = function checkSetup(container) {
|
|
60
|
+
var withAddButton = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
60
61
|
var summaryDiv = container.children[0];
|
|
61
62
|
expect(summaryDiv.tagName).toEqual('DIV');
|
|
62
|
-
|
|
63
|
+
var cardList = withAddButton ? summaryDiv.children[1] : summaryDiv.children[0];
|
|
64
|
+
expect(cardList.tagName).toEqual('UL');
|
|
65
|
+
expect(cardList.classList).toContain('collection-summary-card-list');
|
|
66
|
+
var cards = Array.from(cardList.children, function (child) {
|
|
67
|
+
expect(child.tagName).toEqual('LI');
|
|
68
|
+
return child.children[0] || null;
|
|
69
|
+
}).filter(function (c) {
|
|
70
|
+
return !!c;
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
summaryDiv: summaryDiv,
|
|
74
|
+
cardList: cardList,
|
|
75
|
+
cards: cards
|
|
76
|
+
};
|
|
63
77
|
};
|
|
64
78
|
it('should correctly render a CollectionSummary component', function () {
|
|
65
79
|
var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
@@ -68,10 +82,11 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
68
82
|
onAction: ON_ACTION
|
|
69
83
|
})),
|
|
70
84
|
container = _renderWithValidation.container;
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
expect(
|
|
74
|
-
expect(
|
|
85
|
+
var _checkSetup = checkSetup(container),
|
|
86
|
+
cards = _checkSetup.cards;
|
|
87
|
+
expect(cards.length).toEqual(2);
|
|
88
|
+
expect(cards[0].id).toEqual("".concat(CONFIG.fieldId, ".summaryCard").concat(FORM_DATA.testCollection[0].id));
|
|
89
|
+
expect(cards[1].id).toEqual("".concat(CONFIG.fieldId, ".summaryCard").concat(FORM_DATA.testCollection[1].id));
|
|
75
90
|
});
|
|
76
91
|
it('should focus on the most recently duplicated item', function () {
|
|
77
92
|
var customConfig = {
|
|
@@ -145,14 +160,16 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
145
160
|
onAction: ON_ACTION
|
|
146
161
|
})),
|
|
147
162
|
container = _renderWithValidation4.container;
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
var _checkSetup2 = checkSetup(container),
|
|
164
|
+
summaryDiv = _checkSetup2.summaryDiv,
|
|
165
|
+
cards = _checkSetup2.cards;
|
|
166
|
+
expect(cards.length).toEqual(2);
|
|
167
|
+
var card = cards[0];
|
|
151
168
|
var deleteButton = card.children[0].children[1].children[0];
|
|
152
169
|
_react2.fireEvent.click(deleteButton, {});
|
|
153
|
-
expect(
|
|
154
|
-
expect(
|
|
155
|
-
expect(
|
|
170
|
+
expect(summaryDiv.children.length).toEqual(2); // Now with a confirmation.
|
|
171
|
+
expect(summaryDiv.children[0].id).toEqual("".concat(CONFIG.fieldId, ".confirmation"));
|
|
172
|
+
expect(summaryDiv.children[0].classList).toContain(_Confirmation.DEFAULT_CLASS);
|
|
156
173
|
});
|
|
157
174
|
describe('Add Another button', function () {
|
|
158
175
|
it('should render with an Add button if one is configured', function () {
|
|
@@ -174,11 +191,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
174
191
|
onAction: ON_ACTION
|
|
175
192
|
})),
|
|
176
193
|
container = _renderWithValidation5.container;
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
expect(
|
|
180
|
-
expect(
|
|
181
|
-
expect(
|
|
194
|
+
var _checkSetup3 = checkSetup(container, true),
|
|
195
|
+
summaryDiv = _checkSetup3.summaryDiv;
|
|
196
|
+
expect(summaryDiv.children.length).toEqual(2); // The button and card list.
|
|
197
|
+
expect(summaryDiv.children[0].id).toEqual("".concat(CONFIG_WITH_BUTTON.fieldId, ".addButton"));
|
|
198
|
+
expect(summaryDiv.children[0].textContent).toEqual(CONFIG_WITH_BUTTON.addButton.label);
|
|
199
|
+
expect(summaryDiv.children[0].tagName).toEqual('BUTTON');
|
|
182
200
|
});
|
|
183
201
|
it('should use the default button label if none is provided', function () {
|
|
184
202
|
var CONFIG_WITH_BUTTON = {
|
|
@@ -198,11 +216,12 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
198
216
|
onAction: ON_ACTION
|
|
199
217
|
})),
|
|
200
218
|
container = _renderWithValidation6.container;
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
expect(
|
|
204
|
-
expect(
|
|
205
|
-
expect(
|
|
219
|
+
var _checkSetup4 = checkSetup(container, true),
|
|
220
|
+
summaryDiv = _checkSetup4.summaryDiv;
|
|
221
|
+
expect(summaryDiv.children.length).toEqual(2); // The button and card list.
|
|
222
|
+
expect(summaryDiv.children[0].id).toEqual("".concat(CONFIG_WITH_BUTTON.fieldId, ".addButton"));
|
|
223
|
+
expect(summaryDiv.children[0].textContent).toEqual(_CollectionSummary.DEFAULT_ADD_BUTTON_LABEL);
|
|
224
|
+
expect(summaryDiv.children[0].tagName).toEqual('BUTTON');
|
|
206
225
|
});
|
|
207
226
|
it('should apply the expected class name to the summary card when delete button is pressed', function () {
|
|
208
227
|
var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_CollectionSummary.default, {
|
|
@@ -211,9 +230,10 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
211
230
|
onAction: ON_ACTION
|
|
212
231
|
})),
|
|
213
232
|
container = _renderWithValidation7.container;
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
233
|
+
var _checkSetup5 = checkSetup(container),
|
|
234
|
+
cards = _checkSetup5.cards;
|
|
235
|
+
expect(cards.length).toEqual(2);
|
|
236
|
+
var card = cards[0];
|
|
217
237
|
var deleteButton = card.children[0].children[1].children[0];
|
|
218
238
|
_react2.fireEvent.click(deleteButton, {});
|
|
219
239
|
var confirmation = container.querySelector(".".concat(_Confirmation.DEFAULT_CLASS));
|
|
@@ -227,9 +247,10 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
227
247
|
onAction: ON_ACTION
|
|
228
248
|
})),
|
|
229
249
|
container = _renderWithValidation8.container;
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
250
|
+
var _checkSetup6 = checkSetup(container),
|
|
251
|
+
cards = _checkSetup6.cards;
|
|
252
|
+
expect(cards.length).toEqual(2);
|
|
253
|
+
var card = cards[0];
|
|
233
254
|
var deleteButton = card.children[0].children[1].children[0];
|
|
234
255
|
_react2.fireEvent.click(deleteButton, {});
|
|
235
256
|
var confirmButton = container.querySelector(".".concat(_Confirmation.DEFAULT_CLASS, " button.hods-button--warning"));
|
|
@@ -243,9 +264,10 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
243
264
|
onAction: ON_ACTION
|
|
244
265
|
})),
|
|
245
266
|
container = _renderWithValidation9.container;
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
267
|
+
var _checkSetup7 = checkSetup(container),
|
|
268
|
+
cards = _checkSetup7.cards;
|
|
269
|
+
expect(cards.length).toEqual(2);
|
|
270
|
+
var card = cards[0];
|
|
249
271
|
var deleteButton = card.children[0].children[1].children[0];
|
|
250
272
|
_react2.fireEvent.click(deleteButton, {});
|
|
251
273
|
var confirmation = container.querySelector(".".concat(_Confirmation.DEFAULT_CLASS));
|
|
@@ -270,9 +292,10 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
270
292
|
})),
|
|
271
293
|
container = _renderWithValidation10.container,
|
|
272
294
|
getByText = _renderWithValidation10.getByText;
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
295
|
+
var _checkSetup8 = checkSetup(container),
|
|
296
|
+
cards = _checkSetup8.cards;
|
|
297
|
+
expect(cards.length).toEqual(2);
|
|
298
|
+
var card = cards[0];
|
|
276
299
|
var deleteButton = card.querySelector('.govuk-summary-card__actions li:last-child button');
|
|
277
300
|
_react2.fireEvent.click(deleteButton);
|
|
278
301
|
var confirmation = container.querySelector(".".concat(_Confirmation.DEFAULT_CLASS));
|
|
@@ -302,9 +325,10 @@ describe('components.CollectionSummary.CollectionSummary', function () {
|
|
|
302
325
|
})),
|
|
303
326
|
container = _renderWithValidation11.container,
|
|
304
327
|
getByText = _renderWithValidation11.getByText;
|
|
305
|
-
var
|
|
306
|
-
|
|
307
|
-
|
|
328
|
+
var _checkSetup9 = checkSetup(container),
|
|
329
|
+
cards = _checkSetup9.cards;
|
|
330
|
+
expect(cards.length).toEqual(2);
|
|
331
|
+
var card = cards[0];
|
|
308
332
|
var deleteButton = card.querySelector('.govuk-summary-card__actions li:last-child button');
|
|
309
333
|
_react2.fireEvent.click(deleteButton);
|
|
310
334
|
var confirmation = container.querySelector(".".concat(_Confirmation.DEFAULT_CLASS));
|
|
@@ -171,7 +171,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
171
171
|
id: "BannerStrip".concat(entryData.id),
|
|
172
172
|
banners: config.banners,
|
|
173
173
|
formData: entryData
|
|
174
|
-
}), /*#__PURE__*/_react.default.createElement("
|
|
174
|
+
}), /*#__PURE__*/_react.default.createElement("h2", {
|
|
175
175
|
id: "".concat(id, ".titleText"),
|
|
176
176
|
className: classes('header-content-title')
|
|
177
177
|
}, _utils.default.FormPage.getTitle(config.title, entryData)), config.details && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -81,7 +81,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
81
81
|
expect(headerBanners.tagName).toEqual('DIV');
|
|
82
82
|
expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
83
83
|
var headerTitle = headerContentDiv.children[1];
|
|
84
|
-
expect(headerTitle.tagName).toEqual('
|
|
84
|
+
expect(headerTitle.tagName).toEqual('H2');
|
|
85
85
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
86
86
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
87
87
|
var headerDetails = headerContentDiv.children[2];
|
|
@@ -113,7 +113,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
113
113
|
// and the details.
|
|
114
114
|
|
|
115
115
|
var headerTitle = headerContentDiv.children[0];
|
|
116
|
-
expect(headerTitle.tagName).toEqual('
|
|
116
|
+
expect(headerTitle.tagName).toEqual('H2');
|
|
117
117
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
118
118
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
119
119
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -148,7 +148,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
148
148
|
// the title.
|
|
149
149
|
|
|
150
150
|
var headerTitle = headerContentDiv.children[1];
|
|
151
|
-
expect(headerTitle.tagName).toEqual('
|
|
151
|
+
expect(headerTitle.tagName).toEqual('H2');
|
|
152
152
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
153
153
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
154
154
|
});
|
|
@@ -171,7 +171,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
171
171
|
var _checkSetup4 = checkSetup(container),
|
|
172
172
|
headerContentDiv = _checkSetup4.headerContentDiv;
|
|
173
173
|
var headerTitle = headerContentDiv.children[0];
|
|
174
|
-
expect(headerTitle.tagName).toEqual('
|
|
174
|
+
expect(headerTitle.tagName).toEqual('H2');
|
|
175
175
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
176
176
|
expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
|
|
177
177
|
});
|
|
@@ -211,7 +211,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
211
211
|
var _checkSetup5 = checkSetup(container),
|
|
212
212
|
headerContentDiv = _checkSetup5.headerContentDiv;
|
|
213
213
|
var headerTitle = headerContentDiv.children[0];
|
|
214
|
-
expect(headerTitle.tagName).toEqual('
|
|
214
|
+
expect(headerTitle.tagName).toEqual('H2');
|
|
215
215
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
216
216
|
expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
|
|
217
217
|
});
|
|
@@ -62,7 +62,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
62
62
|
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
63
63
|
var containerRows = (0, _getCYARowsForContainer.default)(childPage, component, entryData);
|
|
64
64
|
rowIndex += 1;
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement("
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("dl", {
|
|
66
66
|
key: fieldId,
|
|
67
67
|
className: classes('field'),
|
|
68
68
|
style: {
|
|
@@ -84,7 +84,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
84
84
|
}), component, entryData[component.id]);
|
|
85
85
|
rowIndex += 1;
|
|
86
86
|
var collectionHeadingIndex = 0;
|
|
87
|
-
return /*#__PURE__*/_react.default.createElement("
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement("dl", {
|
|
88
88
|
key: fieldId,
|
|
89
89
|
className: classes('field'),
|
|
90
90
|
style: {
|
|
@@ -113,7 +113,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
113
113
|
}));
|
|
114
114
|
}
|
|
115
115
|
rowIndex += 1;
|
|
116
|
-
return /*#__PURE__*/_react.default.createElement("
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement("dl", {
|
|
117
117
|
key: fieldId,
|
|
118
118
|
className: classes('field'),
|
|
119
119
|
style: {
|
|
@@ -141,6 +141,8 @@ $govuk-font-family: 'Roboto', arial, sans-serif;
|
|
|
141
141
|
grid-column-end: var(--column);
|
|
142
142
|
grid-row-start: var(--row);
|
|
143
143
|
grid-row-end: var(--row);
|
|
144
|
+
margin-block-start: 0;
|
|
145
|
+
margin-block-end: 0;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
.hods-form-summary-card-details__divider {
|
|
@@ -33,7 +33,7 @@ var showComponentCYA = function showComponentCYA(options, data) {
|
|
|
33
33
|
}
|
|
34
34
|
if (options.hideOnCyaWhenEmpty) {
|
|
35
35
|
if (options.type === _models.ComponentTypes.COLLECTION) {
|
|
36
|
-
var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path);
|
|
36
|
+
var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path || options.fieldId);
|
|
37
37
|
if (!(itemCollectionsData !== null && itemCollectionsData !== void 0 && itemCollectionsData.length)) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|