@ukhomeoffice/cop-react-form-renderer 5.39.1 → 5.41.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.
- package/dist/components/CollectionSummary/CollectionSummary.js +32 -7
- package/dist/components/CollectionSummary/SummaryCard.js +25 -15
- package/dist/components/CollectionSummary/SummaryCard.scss +4 -0
- package/dist/components/CollectionSummary/SummaryCard.test.js +152 -101
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +4 -3
- package/dist/utils/Data/getAutocompleteSource.js +11 -1
- package/dist/utils/Data/getAutocompleteSource.test.js +38 -0
- package/package.json +1 -1
|
@@ -38,10 +38,14 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
38
38
|
onAction = _ref.onAction,
|
|
39
39
|
onChange = _ref.onChange,
|
|
40
40
|
pages = _ref.pages;
|
|
41
|
-
var _useState = (0, _react.useState)(
|
|
41
|
+
var _useState = (0, _react.useState)([]),
|
|
42
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
duplicatedEntries = _useState2[0],
|
|
44
|
+
setDuplicatedEntries = _useState2[1];
|
|
45
|
+
var _useState3 = (0, _react.useState)(null),
|
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
+
entryToDelete = _useState4[0],
|
|
48
|
+
setEntryToDelete = _useState4[1];
|
|
45
49
|
var data = (0, _react.useMemo)(function () {
|
|
46
50
|
return _utils.default.CollectionPage.getData(config.collectionName, formData) || [];
|
|
47
51
|
}, [formData]);
|
|
@@ -52,7 +56,21 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
52
56
|
return ((_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : _page$collection.name) === config.collectionName;
|
|
53
57
|
});
|
|
54
58
|
}, [pages]);
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
var storedEntries = localStorage.getItem('duplicatedEntries');
|
|
61
|
+
if (storedEntries) {
|
|
62
|
+
setDuplicatedEntries(JSON.parse(storedEntries));
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
65
|
+
var removeDuplicatedEntry = function removeDuplicatedEntry(entryId) {
|
|
66
|
+
var filteredEntries = duplicatedEntries.filter(function (id) {
|
|
67
|
+
return id !== entryId;
|
|
68
|
+
});
|
|
69
|
+
localStorage.setItem('duplicatedEntries', JSON.stringify(filteredEntries));
|
|
70
|
+
setDuplicatedEntries(filteredEntries);
|
|
71
|
+
};
|
|
55
72
|
var onSummaryCardChange = function onSummaryCardChange(page, entryId) {
|
|
73
|
+
removeDuplicatedEntry(entryId);
|
|
56
74
|
if (typeof onAction !== 'function') {
|
|
57
75
|
return;
|
|
58
76
|
}
|
|
@@ -67,7 +85,12 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
67
85
|
};
|
|
68
86
|
var onDuplicate = function onDuplicate(entry) {
|
|
69
87
|
var _config$card;
|
|
70
|
-
_utils.default.CollectionPage.duplicateEntry(config.collectionName, formData, entry.id, ((_config$card = config.card) === null || _config$card === void 0 || (_config$card = _config$card.duplicateAction) === null || _config$card === void 0 ? void 0 : _config$card.fieldsToIgnore) || []);
|
|
88
|
+
var newEntryId = _utils.default.CollectionPage.duplicateEntry(config.collectionName, formData, entry.id, ((_config$card = config.card) === null || _config$card === void 0 || (_config$card = _config$card.duplicateAction) === null || _config$card === void 0 ? void 0 : _config$card.fieldsToIgnore) || []);
|
|
89
|
+
if (newEntryId) {
|
|
90
|
+
var newData = [].concat(duplicatedEntries, [newEntryId]);
|
|
91
|
+
localStorage.setItem('duplicatedEntries', JSON.stringify(newData));
|
|
92
|
+
setDuplicatedEntries(newData);
|
|
93
|
+
}
|
|
71
94
|
var parentCollection = config.collectionName.split('.').shift();
|
|
72
95
|
// Report the whole top-level collection as being changed. We have to do this
|
|
73
96
|
// because of how patch is applied to formData on a page submission.
|
|
@@ -143,12 +166,14 @@ var CollectionSummary = function CollectionSummary(_ref) {
|
|
|
143
166
|
return setEntryToDelete(entry);
|
|
144
167
|
},
|
|
145
168
|
pages: pages,
|
|
146
|
-
onQuickEdit: function onQuickEdit(target) {
|
|
147
|
-
|
|
169
|
+
onQuickEdit: function onQuickEdit(target, entryId) {
|
|
170
|
+
removeDuplicatedEntry(entryId);
|
|
171
|
+
onChange(target);
|
|
148
172
|
},
|
|
149
173
|
parentCollectionName: config.collectionName.split('.').shift(),
|
|
150
174
|
formData: formData,
|
|
151
|
-
classModifiers: entry === entryToDelete ? ['deleting-summary-card'] : ['']
|
|
175
|
+
classModifiers: entry === entryToDelete ? ['deleting-summary-card'] : [''],
|
|
176
|
+
isDuplicated: duplicatedEntries.includes(entry.id)
|
|
152
177
|
});
|
|
153
178
|
}));
|
|
154
179
|
};
|
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.DEFAULT_TITLE = exports.DEFAULT_EDIT_LABEL = exports.DEFAULT_DUPLICATE_BUTTON_LABEL = exports.DEFAULT_DELETE_BUTTON_LABEL = exports.DEFAULT_CLASS = exports.DEFAULT_CHANGE_BUTTON_LABEL = void 0;
|
|
7
|
+
exports.default = exports.DEFAULT_TITLE = exports.DEFAULT_REMOVE_BUTTON_LABEL = exports.DEFAULT_FULL_EDIT_BUTTON_LABEL = exports.DEFAULT_EDIT_LABEL = exports.DEFAULT_DUPLICATE_BUTTON_LABEL = exports.DEFAULT_DELETE_BUTTON_LABEL = exports.DEFAULT_CLASS = exports.DEFAULT_CHANGE_BUTTON_LABEL = void 0;
|
|
8
8
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -46,8 +46,12 @@ var DEFAULT_EDIT_LABEL = 'Quick Edit';
|
|
|
46
46
|
exports.DEFAULT_EDIT_LABEL = DEFAULT_EDIT_LABEL;
|
|
47
47
|
var DEFAULT_DUPLICATE_BUTTON_LABEL = 'Duplicate';
|
|
48
48
|
exports.DEFAULT_DUPLICATE_BUTTON_LABEL = DEFAULT_DUPLICATE_BUTTON_LABEL;
|
|
49
|
+
var DEFAULT_FULL_EDIT_BUTTON_LABEL = 'Full edit';
|
|
50
|
+
exports.DEFAULT_FULL_EDIT_BUTTON_LABEL = DEFAULT_FULL_EDIT_BUTTON_LABEL;
|
|
51
|
+
var DEFAULT_REMOVE_BUTTON_LABEL = 'Remove';
|
|
52
|
+
exports.DEFAULT_REMOVE_BUTTON_LABEL = DEFAULT_REMOVE_BUTTON_LABEL;
|
|
49
53
|
var SummaryCard = function SummaryCard(_ref) {
|
|
50
|
-
var _config$changeAction2, _config$duplicateActi, _config$deleteAction, _masterPage$childPage;
|
|
54
|
+
var _config$changeAction2, _config$changeAction3, _config$duplicateActi, _config$deleteAction, _config$deleteAction2, _masterPage$childPage;
|
|
51
55
|
var id = _ref.id,
|
|
52
56
|
entryData = _ref.entryData,
|
|
53
57
|
config = _ref.config,
|
|
@@ -60,12 +64,13 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
60
64
|
parentCollectionName = _ref.parentCollectionName,
|
|
61
65
|
formData = _ref.formData,
|
|
62
66
|
masterPage = _ref.masterPage,
|
|
63
|
-
hideDetails = _ref.hideDetails
|
|
64
|
-
|
|
67
|
+
hideDetails = _ref.hideDetails,
|
|
68
|
+
isDuplicated = _ref.isDuplicated;
|
|
65
69
|
var _useState = (0, _react.useState)(false),
|
|
66
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
67
71
|
quickEdit = _useState2[0],
|
|
68
72
|
setQuickEdit = _useState2[1];
|
|
73
|
+
var classes = _copReactComponents.Utils.classBuilder(DEFAULT_CLASS, classModifiers, isDuplicated ? 'duplicated' : '');
|
|
69
74
|
var quickEditPage = (0, _react.useMemo)(function () {
|
|
70
75
|
return (0, _getQuickEditPage.default)(config.quickEdit, pages, entryData);
|
|
71
76
|
}, [pages, config, entryData]);
|
|
@@ -116,7 +121,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
116
121
|
name: parentCollectionName,
|
|
117
122
|
value: allData
|
|
118
123
|
}
|
|
119
|
-
});
|
|
124
|
+
}, entryData.id);
|
|
120
125
|
setQuickEdit(function (prevState) {
|
|
121
126
|
return !prevState;
|
|
122
127
|
});
|
|
@@ -150,7 +155,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
150
155
|
className: classes('header-content-detail')
|
|
151
156
|
}, _copReactComponents.Utils.interpolateString(config.details, entryData))), /*#__PURE__*/_react.default.createElement("div", {
|
|
152
157
|
className: classes('header-actions')
|
|
153
|
-
}, config.quickEdit && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
158
|
+
}, config.quickEdit && isDuplicated && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
154
159
|
id: "".concat(id, ".quickEditButton"),
|
|
155
160
|
onClick: function onClick() {
|
|
156
161
|
return setQuickEdit(function (prevState) {
|
|
@@ -165,11 +170,11 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
165
170
|
var _config$changeAction;
|
|
166
171
|
return onChange((_config$changeAction = config.changeAction) === null || _config$changeAction === void 0 ? void 0 : _config$changeAction.page, entryData.id);
|
|
167
172
|
},
|
|
168
|
-
classModifiers:
|
|
169
|
-
}, ((_config$changeAction2 = config.changeAction) === null || _config$changeAction2 === void 0 ? void 0 : _config$changeAction2.label) || DEFAULT_CHANGE_BUTTON_LABEL), config.duplicateAction && typeof onDuplicate === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
173
|
+
classModifiers: isDuplicated ? 'primary' : 'secondary'
|
|
174
|
+
}, isDuplicated ? ((_config$changeAction2 = config.changeAction) === null || _config$changeAction2 === void 0 ? void 0 : _config$changeAction2.isDuplicateLabel) || DEFAULT_FULL_EDIT_BUTTON_LABEL : ((_config$changeAction3 = config.changeAction) === null || _config$changeAction3 === void 0 ? void 0 : _config$changeAction3.label) || DEFAULT_CHANGE_BUTTON_LABEL), config.duplicateAction && !isDuplicated && typeof onDuplicate === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
170
175
|
id: "".concat(id, ".duplicateButton"),
|
|
171
176
|
onClick: function onClick() {
|
|
172
|
-
|
|
177
|
+
onDuplicate(entryData);
|
|
173
178
|
},
|
|
174
179
|
classModifiers: "secondary"
|
|
175
180
|
}, ((_config$duplicateActi = config.duplicateAction) === null || _config$duplicateActi === void 0 ? void 0 : _config$duplicateActi.label) || DEFAULT_DUPLICATE_BUTTON_LABEL), config.deleteAction && typeof onDelete === 'function' && /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
@@ -178,7 +183,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
178
183
|
return onDelete(entryData);
|
|
179
184
|
},
|
|
180
185
|
classModifiers: "secondary"
|
|
181
|
-
}, ((_config$deleteAction = config.deleteAction) === null || _config$deleteAction === void 0 ? void 0 : _config$deleteAction.label) || DEFAULT_DELETE_BUTTON_LABEL))), quickEdit && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
|
|
186
|
+
}, isDuplicated ? ((_config$deleteAction = config.deleteAction) === null || _config$deleteAction === void 0 ? void 0 : _config$deleteAction.isDuplicateLabel) || DEFAULT_REMOVE_BUTTON_LABEL : ((_config$deleteAction2 = config.deleteAction) === null || _config$deleteAction2 === void 0 ? void 0 : _config$deleteAction2.label) || DEFAULT_DELETE_BUTTON_LABEL))), quickEdit && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
|
|
182
187
|
page: quickEditPage,
|
|
183
188
|
onAction: function onAction(action, patch) {
|
|
184
189
|
return _onAction(action, patch);
|
|
@@ -187,7 +192,7 @@ var SummaryCard = function SummaryCard(_ref) {
|
|
|
187
192
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
188
193
|
className: classes('body')
|
|
189
194
|
}, !hideDetails && /*#__PURE__*/_react.default.createElement(_copReactComponents.Details, {
|
|
190
|
-
summary:
|
|
195
|
+
summary: isDuplicated ? 'View duplicated details' : 'Full details',
|
|
191
196
|
className: "details"
|
|
192
197
|
}, masterPage === null || masterPage === void 0 || (_masterPage$childPage = masterPage.childPages) === null || _masterPage$childPage === void 0 ? void 0 : _masterPage$childPage.map(function (childPage) {
|
|
193
198
|
var _childPage$summaryLay;
|
|
@@ -233,13 +238,16 @@ SummaryCard.propTypes = {
|
|
|
233
238
|
details: _propTypes.default.string,
|
|
234
239
|
changeAction: _propTypes.default.shape({
|
|
235
240
|
label: _propTypes.default.string,
|
|
241
|
+
isDuplicateLabel: _propTypes.default.string,
|
|
236
242
|
page: _propTypes.default.string.isRequired
|
|
237
243
|
}),
|
|
238
244
|
deleteAction: _propTypes.default.shape({
|
|
239
|
-
label: _propTypes.default.string
|
|
245
|
+
label: _propTypes.default.string,
|
|
246
|
+
isDuplicateLabel: _propTypes.default.string
|
|
240
247
|
}),
|
|
241
248
|
duplicateAction: _propTypes.default.shape({
|
|
242
|
-
label: _propTypes.default.string
|
|
249
|
+
label: _propTypes.default.string,
|
|
250
|
+
isDuplicateLabel: _propTypes.default.string
|
|
243
251
|
}),
|
|
244
252
|
quickEdit: _propTypes.default.shape({
|
|
245
253
|
components: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -260,7 +268,8 @@ SummaryCard.propTypes = {
|
|
|
260
268
|
pages: _propTypes.default.arrayOf(_propTypes.default.shape({})).isRequired,
|
|
261
269
|
parentCollectionName: _propTypes.default.string.isRequired,
|
|
262
270
|
formData: _propTypes.default.shape({}).isRequired,
|
|
263
|
-
hideDetails: _propTypes.default.bool
|
|
271
|
+
hideDetails: _propTypes.default.bool,
|
|
272
|
+
isDuplicated: _propTypes.default.bool
|
|
264
273
|
};
|
|
265
274
|
SummaryCard.defaultProps = {
|
|
266
275
|
classModifiers: null,
|
|
@@ -268,7 +277,8 @@ SummaryCard.defaultProps = {
|
|
|
268
277
|
onDelete: null,
|
|
269
278
|
onDuplicate: null,
|
|
270
279
|
onQuickEdit: null,
|
|
271
|
-
hideDetails: false
|
|
280
|
+
hideDetails: false,
|
|
281
|
+
isDuplicated: false
|
|
272
282
|
};
|
|
273
283
|
var _default = SummaryCard;
|
|
274
284
|
exports.default = _default;
|
|
@@ -203,6 +203,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
203
203
|
expect(headerDetails.textContent).toEqual("".concat(ENTRY.detailsText, " that are interpolated"));
|
|
204
204
|
});
|
|
205
205
|
describe('Change action button', function () {
|
|
206
|
+
var isDuplicatedValue = true;
|
|
206
207
|
var onChangeArgs = [];
|
|
207
208
|
var onChangeCalls = 0;
|
|
208
209
|
var ON_CHANGE = function ON_CHANGE(page, id) {
|
|
@@ -211,6 +212,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
211
212
|
id: id
|
|
212
213
|
});
|
|
213
214
|
onChangeCalls += 1;
|
|
215
|
+
isDuplicatedValue = false;
|
|
214
216
|
};
|
|
215
217
|
beforeEach(function () {
|
|
216
218
|
onChangeArgs = [];
|
|
@@ -249,9 +251,10 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
249
251
|
id: ENTRY.id
|
|
250
252
|
});
|
|
251
253
|
});
|
|
252
|
-
it('should
|
|
254
|
+
it('should render correctly when isDuplicated is true', function () {
|
|
253
255
|
var CONFIG = {
|
|
254
256
|
changeAction: {
|
|
257
|
+
label: 'Change label',
|
|
255
258
|
page: 'testPage'
|
|
256
259
|
}
|
|
257
260
|
};
|
|
@@ -265,7 +268,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
265
268
|
formData: {},
|
|
266
269
|
masterPage: {
|
|
267
270
|
childPages: []
|
|
268
|
-
}
|
|
271
|
+
},
|
|
272
|
+
isDuplicated: isDuplicatedValue
|
|
269
273
|
})),
|
|
270
274
|
container = _renderWithValidation7.container;
|
|
271
275
|
var _checkSetup7 = checkSetup(container),
|
|
@@ -273,13 +277,27 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
273
277
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
274
278
|
var changeButton = headerActionDiv.children[0];
|
|
275
279
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
276
|
-
expect(changeButton.textContent).toEqual(
|
|
280
|
+
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
281
|
+
_react.fireEvent.click(changeButton, {});
|
|
282
|
+
expect(onChangeCalls).toEqual(1);
|
|
283
|
+
expect(onChangeArgs[0]).toMatchObject({
|
|
284
|
+
page: CONFIG.changeAction.page,
|
|
285
|
+
id: ENTRY.id
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Check that the isDuplicated prop is now false
|
|
289
|
+
expect(isDuplicatedValue).toBe(false);
|
|
277
290
|
});
|
|
278
|
-
it('should
|
|
291
|
+
it('should use the default label when one is not provided', function () {
|
|
292
|
+
var CONFIG = {
|
|
293
|
+
changeAction: {
|
|
294
|
+
page: 'testPage'
|
|
295
|
+
}
|
|
296
|
+
};
|
|
279
297
|
var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
280
298
|
id: ID,
|
|
281
299
|
entryData: ENTRY,
|
|
282
|
-
config:
|
|
300
|
+
config: CONFIG,
|
|
283
301
|
onChange: ON_CHANGE,
|
|
284
302
|
parentCollectionName: "parent",
|
|
285
303
|
pages: [],
|
|
@@ -291,6 +309,27 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
291
309
|
container = _renderWithValidation8.container;
|
|
292
310
|
var _checkSetup8 = checkSetup(container),
|
|
293
311
|
headerActionDiv = _checkSetup8.headerActionDiv;
|
|
312
|
+
expect(headerActionDiv.children.length).toEqual(1);
|
|
313
|
+
var changeButton = headerActionDiv.children[0];
|
|
314
|
+
expect(changeButton.tagName).toEqual('BUTTON');
|
|
315
|
+
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
316
|
+
});
|
|
317
|
+
it('should not render when no config is provided for it', function () {
|
|
318
|
+
var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
319
|
+
id: ID,
|
|
320
|
+
entryData: ENTRY,
|
|
321
|
+
config: {},
|
|
322
|
+
onChange: ON_CHANGE,
|
|
323
|
+
parentCollectionName: "parent",
|
|
324
|
+
pages: [],
|
|
325
|
+
formData: {},
|
|
326
|
+
masterPage: {
|
|
327
|
+
childPages: []
|
|
328
|
+
}
|
|
329
|
+
})),
|
|
330
|
+
container = _renderWithValidation9.container;
|
|
331
|
+
var _checkSetup9 = checkSetup(container),
|
|
332
|
+
headerActionDiv = _checkSetup9.headerActionDiv;
|
|
294
333
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
295
334
|
});
|
|
296
335
|
it('should not render when onChange is not supplied', function () {
|
|
@@ -300,7 +339,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
300
339
|
page: 'testPage'
|
|
301
340
|
}
|
|
302
341
|
};
|
|
303
|
-
var
|
|
342
|
+
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
304
343
|
id: ID,
|
|
305
344
|
entryData: ENTRY,
|
|
306
345
|
config: CONFIG,
|
|
@@ -311,9 +350,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
311
350
|
childPages: []
|
|
312
351
|
}
|
|
313
352
|
})),
|
|
314
|
-
container =
|
|
315
|
-
var
|
|
316
|
-
headerActionDiv =
|
|
353
|
+
container = _renderWithValidation10.container;
|
|
354
|
+
var _checkSetup10 = checkSetup(container),
|
|
355
|
+
headerActionDiv = _checkSetup10.headerActionDiv;
|
|
317
356
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
318
357
|
});
|
|
319
358
|
});
|
|
@@ -334,7 +373,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
334
373
|
label: 'Delete label'
|
|
335
374
|
}
|
|
336
375
|
};
|
|
337
|
-
var
|
|
376
|
+
var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
338
377
|
id: ID,
|
|
339
378
|
entryData: ENTRY,
|
|
340
379
|
config: CONFIG,
|
|
@@ -346,9 +385,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
346
385
|
childPages: []
|
|
347
386
|
}
|
|
348
387
|
})),
|
|
349
|
-
container =
|
|
350
|
-
var
|
|
351
|
-
headerActionDiv =
|
|
388
|
+
container = _renderWithValidation11.container;
|
|
389
|
+
var _checkSetup11 = checkSetup(container),
|
|
390
|
+
headerActionDiv = _checkSetup11.headerActionDiv;
|
|
352
391
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
353
392
|
var deleteButton = headerActionDiv.children[0];
|
|
354
393
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
@@ -361,7 +400,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
361
400
|
var CONFIG = {
|
|
362
401
|
deleteAction: {}
|
|
363
402
|
};
|
|
364
|
-
var
|
|
403
|
+
var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
365
404
|
id: ID,
|
|
366
405
|
entryData: ENTRY,
|
|
367
406
|
config: CONFIG,
|
|
@@ -373,16 +412,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
373
412
|
childPages: []
|
|
374
413
|
}
|
|
375
414
|
})),
|
|
376
|
-
container =
|
|
377
|
-
var
|
|
378
|
-
headerActionDiv =
|
|
415
|
+
container = _renderWithValidation12.container;
|
|
416
|
+
var _checkSetup12 = checkSetup(container),
|
|
417
|
+
headerActionDiv = _checkSetup12.headerActionDiv;
|
|
379
418
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
380
419
|
var deleteButton = headerActionDiv.children[0];
|
|
381
420
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
382
421
|
expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
|
|
383
422
|
});
|
|
384
423
|
it('should not render when no config is provided for it', function () {
|
|
385
|
-
var
|
|
424
|
+
var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
386
425
|
id: ID,
|
|
387
426
|
entryData: ENTRY,
|
|
388
427
|
config: {},
|
|
@@ -394,9 +433,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
394
433
|
childPages: []
|
|
395
434
|
}
|
|
396
435
|
})),
|
|
397
|
-
container =
|
|
398
|
-
var
|
|
399
|
-
headerActionDiv =
|
|
436
|
+
container = _renderWithValidation13.container;
|
|
437
|
+
var _checkSetup13 = checkSetup(container),
|
|
438
|
+
headerActionDiv = _checkSetup13.headerActionDiv;
|
|
400
439
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
401
440
|
});
|
|
402
441
|
it('should not render when onDelete is not supplied', function () {
|
|
@@ -405,7 +444,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
405
444
|
label: 'Delete label'
|
|
406
445
|
}
|
|
407
446
|
};
|
|
408
|
-
var
|
|
447
|
+
var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
409
448
|
id: ID,
|
|
410
449
|
entryData: ENTRY,
|
|
411
450
|
config: CONFIG,
|
|
@@ -416,9 +455,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
416
455
|
childPages: []
|
|
417
456
|
}
|
|
418
457
|
})),
|
|
419
|
-
container =
|
|
420
|
-
var
|
|
421
|
-
headerActionDiv =
|
|
458
|
+
container = _renderWithValidation14.container;
|
|
459
|
+
var _checkSetup14 = checkSetup(container),
|
|
460
|
+
headerActionDiv = _checkSetup14.headerActionDiv;
|
|
422
461
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
423
462
|
});
|
|
424
463
|
it('should correctly render the Details section with entry data', function () {
|
|
@@ -427,7 +466,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
427
466
|
label: 'Delete label'
|
|
428
467
|
}
|
|
429
468
|
};
|
|
430
|
-
var
|
|
469
|
+
var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
431
470
|
id: ID,
|
|
432
471
|
entryData: ENTRY,
|
|
433
472
|
config: CONFIG,
|
|
@@ -438,7 +477,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
438
477
|
childPages: []
|
|
439
478
|
}
|
|
440
479
|
})),
|
|
441
|
-
container =
|
|
480
|
+
container = _renderWithValidation15.container;
|
|
442
481
|
var detailsSection = container.querySelector('.details');
|
|
443
482
|
expect(detailsSection).not.toBeNull();
|
|
444
483
|
expect(detailsSection.textContent).toContain(ENTRY.summaryText);
|
|
@@ -461,7 +500,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
461
500
|
label: 'Duplicate label'
|
|
462
501
|
}
|
|
463
502
|
};
|
|
464
|
-
var
|
|
503
|
+
var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
465
504
|
id: ID,
|
|
466
505
|
entryData: ENTRY,
|
|
467
506
|
config: CONFIG,
|
|
@@ -473,9 +512,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
473
512
|
childPages: []
|
|
474
513
|
}
|
|
475
514
|
})),
|
|
476
|
-
container =
|
|
477
|
-
var
|
|
478
|
-
headerActionDiv =
|
|
515
|
+
container = _renderWithValidation16.container;
|
|
516
|
+
var _checkSetup15 = checkSetup(container),
|
|
517
|
+
headerActionDiv = _checkSetup15.headerActionDiv;
|
|
479
518
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
480
519
|
var duplicateButton = headerActionDiv.children[0];
|
|
481
520
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
@@ -488,7 +527,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
488
527
|
var CONFIG = {
|
|
489
528
|
duplicateAction: {}
|
|
490
529
|
};
|
|
491
|
-
var
|
|
530
|
+
var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
492
531
|
id: ID,
|
|
493
532
|
entryData: ENTRY,
|
|
494
533
|
config: CONFIG,
|
|
@@ -500,16 +539,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
500
539
|
childPages: []
|
|
501
540
|
}
|
|
502
541
|
})),
|
|
503
|
-
container =
|
|
504
|
-
var
|
|
505
|
-
headerActionDiv =
|
|
542
|
+
container = _renderWithValidation17.container;
|
|
543
|
+
var _checkSetup16 = checkSetup(container),
|
|
544
|
+
headerActionDiv = _checkSetup16.headerActionDiv;
|
|
506
545
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
507
546
|
var duplicateButton = headerActionDiv.children[0];
|
|
508
547
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
509
548
|
expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
|
|
510
549
|
});
|
|
511
550
|
it('should not render when no config is provided for it', function () {
|
|
512
|
-
var
|
|
551
|
+
var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
513
552
|
id: ID,
|
|
514
553
|
entryData: ENTRY,
|
|
515
554
|
config: {},
|
|
@@ -521,9 +560,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
521
560
|
childPages: []
|
|
522
561
|
}
|
|
523
562
|
})),
|
|
524
|
-
container =
|
|
525
|
-
var
|
|
526
|
-
headerActionDiv =
|
|
563
|
+
container = _renderWithValidation18.container;
|
|
564
|
+
var _checkSetup17 = checkSetup(container),
|
|
565
|
+
headerActionDiv = _checkSetup17.headerActionDiv;
|
|
527
566
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
528
567
|
});
|
|
529
568
|
it('should not render when onDuplicate is not supplied', function () {
|
|
@@ -532,7 +571,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
532
571
|
label: 'Duplicate label'
|
|
533
572
|
}
|
|
534
573
|
};
|
|
535
|
-
var
|
|
574
|
+
var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
536
575
|
id: ID,
|
|
537
576
|
entryData: ENTRY,
|
|
538
577
|
config: CONFIG,
|
|
@@ -543,9 +582,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
543
582
|
childPages: []
|
|
544
583
|
}
|
|
545
584
|
})),
|
|
546
|
-
container =
|
|
547
|
-
var
|
|
548
|
-
headerActionDiv =
|
|
585
|
+
container = _renderWithValidation19.container;
|
|
586
|
+
var _checkSetup18 = checkSetup(container),
|
|
587
|
+
headerActionDiv = _checkSetup18.headerActionDiv;
|
|
549
588
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
550
589
|
});
|
|
551
590
|
});
|
|
@@ -580,7 +619,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
580
619
|
}
|
|
581
620
|
}];
|
|
582
621
|
it('should render correctly', function () {
|
|
583
|
-
var
|
|
622
|
+
var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
584
623
|
id: ID,
|
|
585
624
|
entryData: ENTRY,
|
|
586
625
|
config: CONFIG,
|
|
@@ -589,11 +628,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
589
628
|
formData: {},
|
|
590
629
|
masterPage: {
|
|
591
630
|
childPages: []
|
|
592
|
-
}
|
|
631
|
+
},
|
|
632
|
+
isDuplicated: true
|
|
593
633
|
})),
|
|
594
|
-
container =
|
|
595
|
-
var
|
|
596
|
-
headerActionDiv =
|
|
634
|
+
container = _renderWithValidation20.container;
|
|
635
|
+
var _checkSetup19 = checkSetup(container),
|
|
636
|
+
headerActionDiv = _checkSetup19.headerActionDiv;
|
|
597
637
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
598
638
|
|
|
599
639
|
// Shows edit button but no quick edit
|
|
@@ -621,7 +661,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
621
661
|
});
|
|
622
662
|
|
|
623
663
|
it('should not render when no config is provided for it', function () {
|
|
624
|
-
var
|
|
664
|
+
var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
625
665
|
id: ID,
|
|
626
666
|
entryData: ENTRY,
|
|
627
667
|
config: {},
|
|
@@ -630,11 +670,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
630
670
|
formData: {},
|
|
631
671
|
masterPage: {
|
|
632
672
|
childPages: []
|
|
633
|
-
}
|
|
673
|
+
},
|
|
674
|
+
isDuplicated: true
|
|
634
675
|
})),
|
|
635
|
-
container =
|
|
636
|
-
var
|
|
637
|
-
headerActionDiv =
|
|
676
|
+
container = _renderWithValidation21.container;
|
|
677
|
+
var _checkSetup20 = checkSetup(container),
|
|
678
|
+
headerActionDiv = _checkSetup20.headerActionDiv;
|
|
638
679
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
639
680
|
});
|
|
640
681
|
});
|
|
@@ -674,7 +715,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
674
715
|
}
|
|
675
716
|
}];
|
|
676
717
|
it('should render correctly', function () {
|
|
677
|
-
var
|
|
718
|
+
var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
678
719
|
id: ID,
|
|
679
720
|
entryData: ENTRY,
|
|
680
721
|
config: CONFIG,
|
|
@@ -683,11 +724,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
683
724
|
formData: {},
|
|
684
725
|
masterPage: {
|
|
685
726
|
childPages: []
|
|
686
|
-
}
|
|
727
|
+
},
|
|
728
|
+
isDuplicated: true
|
|
687
729
|
})),
|
|
688
|
-
container =
|
|
689
|
-
var
|
|
690
|
-
headerActionDiv =
|
|
730
|
+
container = _renderWithValidation22.container;
|
|
731
|
+
var _checkSetup21 = checkSetup(container),
|
|
732
|
+
headerActionDiv = _checkSetup21.headerActionDiv;
|
|
691
733
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
692
734
|
|
|
693
735
|
// Shows edit button but no quick edit
|
|
@@ -721,7 +763,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
721
763
|
return ON_SUBMIT_CALLS.push(patch);
|
|
722
764
|
}
|
|
723
765
|
};
|
|
724
|
-
var
|
|
766
|
+
var _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
725
767
|
id: ID,
|
|
726
768
|
entryData: ENTRY,
|
|
727
769
|
config: CONFIG,
|
|
@@ -730,13 +772,14 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
730
772
|
formData: {},
|
|
731
773
|
masterPage: {
|
|
732
774
|
childPages: []
|
|
733
|
-
}
|
|
775
|
+
},
|
|
776
|
+
isDuplicated: true
|
|
734
777
|
}), {
|
|
735
778
|
hooks: hooks
|
|
736
779
|
}),
|
|
737
|
-
container =
|
|
738
|
-
var
|
|
739
|
-
headerActionDiv =
|
|
780
|
+
container = _renderWithValidation23.container;
|
|
781
|
+
var _checkSetup22 = checkSetup(container),
|
|
782
|
+
headerActionDiv = _checkSetup22.headerActionDiv;
|
|
740
783
|
|
|
741
784
|
// Shows edit button but no quick edit
|
|
742
785
|
var editButton = headerActionDiv.children[0];
|
|
@@ -750,7 +793,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
750
793
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
751
794
|
});
|
|
752
795
|
it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
753
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
796
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation24, container, _checkSetup23, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
754
797
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
755
798
|
while (1) switch (_context3.prev = _context3.next) {
|
|
756
799
|
case 0:
|
|
@@ -765,7 +808,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
765
808
|
var target = _ref2.target;
|
|
766
809
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
767
810
|
};
|
|
768
|
-
|
|
811
|
+
_renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
769
812
|
id: ID,
|
|
770
813
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
771
814
|
index: 0
|
|
@@ -781,11 +824,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
781
824
|
},
|
|
782
825
|
masterPage: {
|
|
783
826
|
childPages: []
|
|
784
|
-
}
|
|
827
|
+
},
|
|
828
|
+
isDuplicated: true
|
|
785
829
|
}), {
|
|
786
830
|
hooks: hooks
|
|
787
|
-
}), container =
|
|
788
|
-
|
|
831
|
+
}), container = _renderWithValidation24.container;
|
|
832
|
+
_checkSetup23 = checkSetup(container), headerActionDiv = _checkSetup23.headerActionDiv;
|
|
789
833
|
editButton = headerActionDiv.children[0];
|
|
790
834
|
_react.fireEvent.click(editButton, {});
|
|
791
835
|
quickEdit = container.childNodes[0].childNodes[1];
|
|
@@ -832,7 +876,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
832
876
|
}, _callee3);
|
|
833
877
|
})));
|
|
834
878
|
it('should run hook validation when a value changes and local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
835
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
879
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation25, container, _checkSetup24, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
836
880
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
837
881
|
while (1) switch (_context5.prev = _context5.next) {
|
|
838
882
|
case 0:
|
|
@@ -851,7 +895,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
851
895
|
var target = _ref6.target;
|
|
852
896
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
853
897
|
};
|
|
854
|
-
|
|
898
|
+
_renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
855
899
|
id: ID,
|
|
856
900
|
entryData: ENTRY,
|
|
857
901
|
config: CONFIG,
|
|
@@ -865,11 +909,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
865
909
|
},
|
|
866
910
|
masterPage: {
|
|
867
911
|
childPages: []
|
|
868
|
-
}
|
|
912
|
+
},
|
|
913
|
+
isDuplicated: true
|
|
869
914
|
}), {
|
|
870
915
|
hooks: hooks
|
|
871
|
-
}), container =
|
|
872
|
-
|
|
916
|
+
}), container = _renderWithValidation25.container;
|
|
917
|
+
_checkSetup24 = checkSetup(container), headerActionDiv = _checkSetup24.headerActionDiv;
|
|
873
918
|
editButton = headerActionDiv.children[0];
|
|
874
919
|
_react.fireEvent.click(editButton, {});
|
|
875
920
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change
|
|
@@ -906,10 +951,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
906
951
|
}, _callee5);
|
|
907
952
|
})));
|
|
908
953
|
it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
909
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
954
|
+
var isDuplicatedValue, ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation26, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
910
955
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
911
956
|
while (1) switch (_context7.prev = _context7.next) {
|
|
912
957
|
case 0:
|
|
958
|
+
isDuplicatedValue = true;
|
|
913
959
|
ON_SUBMIT_CALLS = [];
|
|
914
960
|
hooks = {
|
|
915
961
|
onSubmit: function onSubmit(type, patch) {
|
|
@@ -920,8 +966,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
920
966
|
ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref9) {
|
|
921
967
|
var target = _ref9.target;
|
|
922
968
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
969
|
+
isDuplicatedValue = false;
|
|
923
970
|
};
|
|
924
|
-
|
|
971
|
+
_renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
925
972
|
id: ID,
|
|
926
973
|
entryData: {
|
|
927
974
|
index: 0,
|
|
@@ -938,11 +985,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
938
985
|
},
|
|
939
986
|
masterPage: {
|
|
940
987
|
childPages: []
|
|
941
|
-
}
|
|
988
|
+
},
|
|
989
|
+
isDuplicated: isDuplicatedValue
|
|
942
990
|
}), {
|
|
943
991
|
hooks: hooks
|
|
944
|
-
}), container =
|
|
945
|
-
|
|
992
|
+
}), container = _renderWithValidation26.container;
|
|
993
|
+
_checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
|
|
946
994
|
editButton = headerActionDiv.children[0];
|
|
947
995
|
_react.fireEvent.click(editButton, {});
|
|
948
996
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
|
|
@@ -955,7 +1003,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
955
1003
|
});
|
|
956
1004
|
quickEditButtons = quickEdit.childNodes[2];
|
|
957
1005
|
saveButton = quickEditButtons.childNodes[0];
|
|
958
|
-
_context7.next =
|
|
1006
|
+
_context7.next = 17;
|
|
959
1007
|
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
960
1008
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
961
1009
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -967,13 +1015,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
967
1015
|
}
|
|
968
1016
|
}, _callee6);
|
|
969
1017
|
})));
|
|
970
|
-
case
|
|
1018
|
+
case 17:
|
|
971
1019
|
expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
|
|
972
1020
|
expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
|
|
973
1021
|
alreadyProvidedField: 'hello',
|
|
974
1022
|
testText: 'new value'
|
|
975
1023
|
});
|
|
976
|
-
|
|
1024
|
+
|
|
1025
|
+
// Check that the isDuplicated prop is now false
|
|
1026
|
+
expect(isDuplicatedValue).toBe(false);
|
|
1027
|
+
case 20:
|
|
977
1028
|
case "end":
|
|
978
1029
|
return _context7.stop();
|
|
979
1030
|
}
|
|
@@ -987,7 +1038,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
987
1038
|
title: 'Title',
|
|
988
1039
|
details: DETAILS
|
|
989
1040
|
};
|
|
990
|
-
var
|
|
1041
|
+
var _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
991
1042
|
id: ID,
|
|
992
1043
|
entryData: ENTRY,
|
|
993
1044
|
config: CONFIG,
|
|
@@ -998,9 +1049,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
998
1049
|
childPages: []
|
|
999
1050
|
}
|
|
1000
1051
|
})),
|
|
1001
|
-
container =
|
|
1002
|
-
var
|
|
1003
|
-
headerContentDiv =
|
|
1052
|
+
container = _renderWithValidation27.container;
|
|
1053
|
+
var _checkSetup26 = checkSetup(container),
|
|
1054
|
+
headerContentDiv = _checkSetup26.headerContentDiv;
|
|
1004
1055
|
var headerDetails = headerContentDiv.children[1];
|
|
1005
1056
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
1006
1057
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
@@ -1011,7 +1062,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1011
1062
|
title: 'Title',
|
|
1012
1063
|
details: ''
|
|
1013
1064
|
};
|
|
1014
|
-
var
|
|
1065
|
+
var _renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1015
1066
|
id: ID,
|
|
1016
1067
|
entryData: ENTRY,
|
|
1017
1068
|
config: CONFIG,
|
|
@@ -1022,9 +1073,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1022
1073
|
childPages: []
|
|
1023
1074
|
}
|
|
1024
1075
|
})),
|
|
1025
|
-
container =
|
|
1026
|
-
var
|
|
1027
|
-
headerContentDiv =
|
|
1076
|
+
container = _renderWithValidation28.container;
|
|
1077
|
+
var _checkSetup27 = checkSetup(container),
|
|
1078
|
+
headerContentDiv = _checkSetup27.headerContentDiv;
|
|
1028
1079
|
// If no details are provided, we expect only the header title to be rendered.
|
|
1029
1080
|
expect(headerContentDiv.children.length).toEqual(1);
|
|
1030
1081
|
var headerTitle = headerContentDiv.children[0];
|
|
@@ -1039,7 +1090,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1039
1090
|
title: 'Title',
|
|
1040
1091
|
details: DETAILS
|
|
1041
1092
|
};
|
|
1042
|
-
var
|
|
1093
|
+
var _renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1043
1094
|
id: ID,
|
|
1044
1095
|
entryData: INTERPOLATED_ENTRY,
|
|
1045
1096
|
config: CONFIG,
|
|
@@ -1050,9 +1101,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1050
1101
|
childPages: []
|
|
1051
1102
|
}
|
|
1052
1103
|
})),
|
|
1053
|
-
container =
|
|
1054
|
-
var
|
|
1055
|
-
headerContentDiv =
|
|
1104
|
+
container = _renderWithValidation29.container;
|
|
1105
|
+
var _checkSetup28 = checkSetup(container),
|
|
1106
|
+
headerContentDiv = _checkSetup28.headerContentDiv;
|
|
1056
1107
|
var headerDetails = headerContentDiv.children[1];
|
|
1057
1108
|
var expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
|
|
1058
1109
|
expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
|
|
@@ -1061,7 +1112,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1061
1112
|
var CONFIG = {
|
|
1062
1113
|
title: 'Title'
|
|
1063
1114
|
};
|
|
1064
|
-
var
|
|
1115
|
+
var _renderWithValidation30 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1065
1116
|
id: ID,
|
|
1066
1117
|
entryData: ENTRY,
|
|
1067
1118
|
config: CONFIG,
|
|
@@ -1072,9 +1123,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1072
1123
|
childPages: []
|
|
1073
1124
|
}
|
|
1074
1125
|
})),
|
|
1075
|
-
container =
|
|
1076
|
-
var
|
|
1077
|
-
headerContentDiv =
|
|
1126
|
+
container = _renderWithValidation30.container;
|
|
1127
|
+
var _checkSetup29 = checkSetup(container),
|
|
1128
|
+
headerContentDiv = _checkSetup29.headerContentDiv;
|
|
1078
1129
|
var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
1079
1130
|
expect(headerDetails).toBeNull();
|
|
1080
1131
|
});
|
|
@@ -1084,7 +1135,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1084
1135
|
title: 'Title',
|
|
1085
1136
|
details: DETAILS
|
|
1086
1137
|
};
|
|
1087
|
-
var
|
|
1138
|
+
var _renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1088
1139
|
id: ID,
|
|
1089
1140
|
entryData: ENTRY,
|
|
1090
1141
|
config: CONFIG,
|
|
@@ -1096,7 +1147,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1096
1147
|
childPages: []
|
|
1097
1148
|
}
|
|
1098
1149
|
})),
|
|
1099
|
-
container =
|
|
1150
|
+
container = _renderWithValidation31.container;
|
|
1100
1151
|
var detailsComponent = container.querySelector('.details');
|
|
1101
1152
|
expect(detailsComponent).toBeNull();
|
|
1102
1153
|
});
|
|
@@ -1126,7 +1177,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1126
1177
|
var CONFIG = {
|
|
1127
1178
|
title: 'Title'
|
|
1128
1179
|
};
|
|
1129
|
-
var
|
|
1180
|
+
var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1130
1181
|
id: ID,
|
|
1131
1182
|
entryData: ENTRY,
|
|
1132
1183
|
config: CONFIG,
|
|
@@ -1137,7 +1188,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1137
1188
|
childPages: []
|
|
1138
1189
|
}
|
|
1139
1190
|
})),
|
|
1140
|
-
container =
|
|
1191
|
+
container = _renderWithValidation32.container;
|
|
1141
1192
|
|
|
1142
1193
|
// Function to find an element by its text content
|
|
1143
1194
|
function getByTextContent(parent, text) {
|
|
@@ -19,10 +19,11 @@ var duplicateCollectionPageEntry = function duplicateCollectionPageEntry(collect
|
|
|
19
19
|
return entry.id === entryId;
|
|
20
20
|
});
|
|
21
21
|
if (!entryToDuplicate) {
|
|
22
|
-
return
|
|
22
|
+
return null;
|
|
23
23
|
}
|
|
24
|
+
var newEntryId = Date.now().toString();
|
|
24
25
|
var newEntry = _objectSpread(_objectSpread({}, entryToDuplicate), {}, {
|
|
25
|
-
id:
|
|
26
|
+
id: newEntryId
|
|
26
27
|
});
|
|
27
28
|
fieldsToIgnore.forEach(function (field) {
|
|
28
29
|
return delete newEntry[field];
|
|
@@ -30,7 +31,7 @@ var duplicateCollectionPageEntry = function duplicateCollectionPageEntry(collect
|
|
|
30
31
|
collectionData.push(newEntry);
|
|
31
32
|
// eslint-disable-next-line no-param-reassign
|
|
32
33
|
formData["".concat(collectionName.split('.').pop(), "ActiveId")] = newEntry.id;
|
|
33
|
-
return
|
|
34
|
+
return newEntryId;
|
|
34
35
|
};
|
|
35
36
|
var _default = duplicateCollectionPageEntry;
|
|
36
37
|
exports.default = _default;
|
|
@@ -20,13 +20,23 @@ var getAutocompleteSource = function getAutocompleteSource(config) {
|
|
|
20
20
|
return function (query, populateResults) {
|
|
21
21
|
var lcQuery = query ? query.toLowerCase() : '';
|
|
22
22
|
populateResults(options.filter(function (opt) {
|
|
23
|
+
var _config$item;
|
|
23
24
|
var label = labelMaker ? labelMaker(opt) : opt.label || '';
|
|
24
25
|
if (label.toLowerCase().includes(lcQuery)) {
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
var matchingSynonym = opt.synonyms ? opt.synonyms.some(function (synonym) {
|
|
28
29
|
return synonym.toLowerCase().includes(lcQuery);
|
|
29
30
|
}) : false;
|
|
31
|
+
if (matchingSynonym) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return config !== null && config !== void 0 && (_config$item = config.item) !== null && _config$item !== void 0 && _config$item.extraFieldsToSearch ? config.item.extraFieldsToSearch.some(function (field) {
|
|
35
|
+
if (typeof opt[field] !== 'string') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return opt[field].toLowerCase().includes(lcQuery);
|
|
39
|
+
}) : false;
|
|
30
40
|
}));
|
|
31
41
|
};
|
|
32
42
|
};
|
|
@@ -405,6 +405,44 @@ describe('utils', function () {
|
|
|
405
405
|
}]);
|
|
406
406
|
});
|
|
407
407
|
});
|
|
408
|
+
it('should match options using defined extra searchable fields', function () {
|
|
409
|
+
var CONFIG = {
|
|
410
|
+
item: {
|
|
411
|
+
value: 'currencyCode',
|
|
412
|
+
label: 'currencyCode',
|
|
413
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
414
|
+
format: '${currencyName} (${currencyCode})',
|
|
415
|
+
extraFieldsToSearch: ['slangTerm']
|
|
416
|
+
},
|
|
417
|
+
data: {
|
|
418
|
+
options: [{
|
|
419
|
+
currencyName: 'Great British Pounds',
|
|
420
|
+
currencyCode: 'GBP',
|
|
421
|
+
value: 'GBP',
|
|
422
|
+
label: 'GBP',
|
|
423
|
+
slangTerm: 'Quid'
|
|
424
|
+
}, {
|
|
425
|
+
currencyName: 'United States Dollars',
|
|
426
|
+
currencyCode: 'USD',
|
|
427
|
+
value: 'USD',
|
|
428
|
+
label: 'USD',
|
|
429
|
+
slangTerm: 'Dollary-doos'
|
|
430
|
+
}]
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
434
|
+
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
435
|
+
SOURCE('doo', function (results) {
|
|
436
|
+
expect(results.length).toEqual(1);
|
|
437
|
+
expect(results).toEqual([{
|
|
438
|
+
currencyName: 'United States Dollars',
|
|
439
|
+
currencyCode: 'USD',
|
|
440
|
+
value: 'USD',
|
|
441
|
+
label: 'USD',
|
|
442
|
+
slangTerm: 'Dollary-doos'
|
|
443
|
+
}]);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
408
446
|
});
|
|
409
447
|
});
|
|
410
448
|
});
|