@commercetools-frontend-extensions/export-resources-modal 1.0.8 → 1.1.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/README.md
CHANGED
|
@@ -31,11 +31,17 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
31
31
|
resourceType="category"
|
|
32
32
|
allResourcesCount={143}
|
|
33
33
|
exportSelectionType="allResources"
|
|
34
|
-
|
|
34
|
+
fields={[
|
|
35
35
|
{ key: 'externalId' },
|
|
36
36
|
{ key: 'createdAt' },
|
|
37
37
|
{ key: 'lastModifiedAt' },
|
|
38
38
|
{ key: 'name', isLocalized: true },
|
|
39
|
+
{ key: 'parent', fields: [
|
|
40
|
+
{
|
|
41
|
+
key: 'name',
|
|
42
|
+
isLocalized: true
|
|
43
|
+
}
|
|
44
|
+
]},
|
|
39
45
|
]}
|
|
40
46
|
renderProperties={()=>(
|
|
41
47
|
<>
|
|
@@ -54,11 +60,17 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
54
60
|
resourceType="category"
|
|
55
61
|
allResourcesCount={143}
|
|
56
62
|
exportSelectionType="onlyMatching"
|
|
57
|
-
|
|
63
|
+
fields={[
|
|
58
64
|
{ key: 'externalId' },
|
|
59
65
|
{ key: 'createdAt' },
|
|
60
66
|
{ key: 'lastModifiedAt' },
|
|
61
67
|
{ key: 'name', isLocalized: true },
|
|
68
|
+
{ key: 'parent', fields: [
|
|
69
|
+
{
|
|
70
|
+
key: 'name',
|
|
71
|
+
isLocalized: true
|
|
72
|
+
}
|
|
73
|
+
]},
|
|
62
74
|
]}
|
|
63
75
|
appliedFilters={
|
|
64
76
|
[
|
|
@@ -86,11 +98,17 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
86
98
|
allResourcesCount={143}
|
|
87
99
|
exportSelectionType="onlySelected"
|
|
88
100
|
selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
|
|
89
|
-
|
|
101
|
+
fields={[
|
|
90
102
|
{ key: 'externalId' },
|
|
91
103
|
{ key: 'createdAt' },
|
|
92
104
|
{ key: 'lastModifiedAt' },
|
|
93
105
|
{ key: 'name', isLocalized: true },
|
|
106
|
+
{ key: 'parent', fields: [
|
|
107
|
+
{
|
|
108
|
+
key: 'name',
|
|
109
|
+
isLocalized: true
|
|
110
|
+
}
|
|
111
|
+
]},
|
|
94
112
|
]}
|
|
95
113
|
renderProperties={()=>(
|
|
96
114
|
<>
|
|
@@ -115,9 +133,10 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
115
133
|
| `exportSelectionType` | `string` <br/>Possible values:<br/>`allResources, onlyMatching, onlySelected` | | `allResources` | The type of export, so either export all resources or export only resources that match the filters & search or export only selected resources |
|
|
116
134
|
| `matchingResourcesCount` | `Number` | ✅ Required only if `exportSelectionType` is `onlyMatching` | | The count of resources that matches the filters & search |
|
|
117
135
|
| `selectedResourceIds` | `array` | ✅ Required only if `exportSelectionType` is `onlySelected` | | Array of Ids of the selected resources |
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
136
|
+
| `fields` | `array` | ✅ Required | | Array of the fields to export |
|
|
137
|
+
| `fields[].key` | `string` | ✅ Required | | The unique key of the field that is used to identify data type |
|
|
138
|
+
| `fields[].label` | `string` | | | The label of the field to be shown in the export modal, if it's not set the key will be shown instead |
|
|
139
|
+
| `fields[].isLocalized` | `boolean` | | false | The field is a localized field |
|
|
121
140
|
| `appliedSearchTerms` | `array` | | [] | Array of the search terms that are used when `exportSelectionType` is `onlyMatching` |
|
|
122
141
|
| `appliedFilters` | `array` | | [] | Array of the filters that are used when `exportSelectionType` is `onlyMatching` |
|
|
123
142
|
| `renderProperties` | `function` | | | A prop to render properties that are resource-specific |
|
|
@@ -25,6 +25,7 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
25
25
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
26
26
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
27
27
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
28
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
28
29
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
29
30
|
var PropTypes = require('prop-types');
|
|
30
31
|
var formik = require('formik');
|
|
@@ -58,6 +59,7 @@ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstancePro
|
|
|
58
59
|
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
59
60
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
60
61
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
62
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
61
63
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
62
64
|
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
63
65
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
@@ -210,6 +212,9 @@ function resourceTypeToOperationName(resourceType) {
|
|
|
210
212
|
function replaceSpecialCharsWithUnderscore(string) {
|
|
211
213
|
return string.replace(/[^a-zA-Z0-9]/g, '_');
|
|
212
214
|
}
|
|
215
|
+
function isFilledArray(maybeArray) {
|
|
216
|
+
return _Array$isArray__default["default"](maybeArray) && maybeArray.length;
|
|
217
|
+
}
|
|
213
218
|
|
|
214
219
|
function buildGraphQuery(exportSettings) {
|
|
215
220
|
var _context;
|
|
@@ -221,8 +226,8 @@ function buildGraphQuery(exportSettings) {
|
|
|
221
226
|
return gqlQueryBuilder.query({
|
|
222
227
|
operation: operation,
|
|
223
228
|
fields: [{
|
|
224
|
-
results:
|
|
225
|
-
|
|
229
|
+
results: buildFields({
|
|
230
|
+
fields: exportSettings.fields,
|
|
226
231
|
languages: exportSettings.languages
|
|
227
232
|
})
|
|
228
233
|
}],
|
|
@@ -233,8 +238,8 @@ function buildGraphQuery(exportSettings) {
|
|
|
233
238
|
return gqlQueryBuilder.query({
|
|
234
239
|
operation: operation,
|
|
235
240
|
fields: [{
|
|
236
|
-
results:
|
|
237
|
-
|
|
241
|
+
results: buildFields({
|
|
242
|
+
fields: exportSettings.fields,
|
|
238
243
|
languages: exportSettings.languages
|
|
239
244
|
})
|
|
240
245
|
}],
|
|
@@ -254,18 +259,27 @@ function buildGraphQuery(exportSettings) {
|
|
|
254
259
|
}
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
function
|
|
262
|
+
function buildFields(_ref) {
|
|
258
263
|
var _context2;
|
|
259
264
|
|
|
260
|
-
var
|
|
265
|
+
var fields = _ref.fields,
|
|
261
266
|
languages = _ref.languages;
|
|
262
|
-
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](
|
|
263
|
-
if (
|
|
267
|
+
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](fields).call(fields, function (field) {
|
|
268
|
+
if (field.isLocalized) return _mapInstanceProperty__default["default"](languages).call(languages, function (language) {
|
|
264
269
|
var _context3, _context4, _context5;
|
|
265
270
|
|
|
266
|
-
var alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(
|
|
267
|
-
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5,
|
|
268
|
-
});else
|
|
271
|
+
var alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(field.key, "_")).call(_context3, language));
|
|
272
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4, language, "\")");
|
|
273
|
+
});else {
|
|
274
|
+
if (isFilledArray(field.fields)) {
|
|
275
|
+
return _defineProperty({}, field.key, buildFields({
|
|
276
|
+
fields: field.fields,
|
|
277
|
+
languages: languages
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return field.key;
|
|
282
|
+
}
|
|
269
283
|
})).call(_context2);
|
|
270
284
|
}
|
|
271
285
|
|
|
@@ -427,9 +441,16 @@ var ExportResourcesModalShape = PropTypes__default["default"].shape({
|
|
|
427
441
|
allResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
428
442
|
matchingResourcesCount: PropTypes__default["default"].number,
|
|
429
443
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
430
|
-
|
|
444
|
+
// TODO: Circular reference
|
|
445
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
431
446
|
key: PropTypes__default["default"].string.isRequired,
|
|
432
|
-
|
|
447
|
+
label: PropTypes__default["default"].string,
|
|
448
|
+
isLocalized: PropTypes__default["default"].bool,
|
|
449
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
450
|
+
key: PropTypes__default["default"].string.isRequired,
|
|
451
|
+
label: PropTypes__default["default"].string,
|
|
452
|
+
isLocalized: PropTypes__default["default"].bool
|
|
453
|
+
}))
|
|
433
454
|
})).isRequired,
|
|
434
455
|
exportSelectionType: PropTypes__default["default"].string,
|
|
435
456
|
appliedSearchTerms: PropTypes__default["default"].array,
|
|
@@ -480,7 +501,7 @@ var ExportResourcesContextProvider = function ExportResourcesContextProvider(pro
|
|
|
480
501
|
isUpperCase: true
|
|
481
502
|
}), "_Export_")).call(_context, todayFormatted),
|
|
482
503
|
languages: [language],
|
|
483
|
-
|
|
504
|
+
fields: props.fields,
|
|
484
505
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
485
506
|
appliedFilters: props.appliedFilters,
|
|
486
507
|
exportSelectionType: props.exportSelectionType,
|
|
@@ -794,9 +815,46 @@ AppliedSearchTerms.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
794
815
|
|
|
795
816
|
function ownKeys$6(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
796
817
|
|
|
797
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
798
|
-
|
|
799
|
-
|
|
818
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$6(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$6(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
819
|
+
|
|
820
|
+
function normalizeFields(fields) {
|
|
821
|
+
var result = _mapInstanceProperty__default["default"](fields).call(fields, function (field) {
|
|
822
|
+
if (isFilledArray(field.fields)) {
|
|
823
|
+
var _context;
|
|
824
|
+
|
|
825
|
+
return _mapInstanceProperty__default["default"](_context = normalizeFields(field.fields)).call(_context, function (nestedField) {
|
|
826
|
+
var _context2;
|
|
827
|
+
|
|
828
|
+
return _objectSpread$6(_objectSpread$6({}, nestedField), {}, {
|
|
829
|
+
key: _concatInstanceProperty__default["default"](_context2 = "".concat(field.key, ".")).call(_context2, nestedField.key)
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
return field;
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
return _flatInstanceProperty__default["default"](result).call(result);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
function FieldsRenderer(_ref) {
|
|
841
|
+
var fields = _ref.fields;
|
|
842
|
+
var allFields = normalizeFields(fields);
|
|
843
|
+
return jsxRuntime.jsx(TagList, {
|
|
844
|
+
children: _mapInstanceProperty__default["default"](allFields).call(allFields, function (field) {
|
|
845
|
+
return jsxRuntime.jsx("div", {
|
|
846
|
+
"data-testid": "test-field-".concat(field.key),
|
|
847
|
+
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
848
|
+
children: field.label || field.key
|
|
849
|
+
})
|
|
850
|
+
}, field.key);
|
|
851
|
+
})
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
FieldsRenderer.propTypes = process.env.NODE_ENV !== "production" ? ExportFields.propTypes : {};
|
|
856
|
+
function ExportFields(_ref2) {
|
|
857
|
+
var fields = _ref2.fields;
|
|
800
858
|
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
801
859
|
scale: "s",
|
|
802
860
|
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
@@ -809,27 +867,27 @@ function Columns(_ref) {
|
|
|
809
867
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
810
868
|
intlMessage: _objectSpread$6(_objectSpread$6({}, messages.columnsMessage), {}, {
|
|
811
869
|
values: {
|
|
812
|
-
columnsCount:
|
|
870
|
+
columnsCount: fields.length,
|
|
813
871
|
b: getBold
|
|
814
872
|
}
|
|
815
873
|
})
|
|
816
874
|
})]
|
|
817
|
-
}), jsxRuntime.jsx(
|
|
818
|
-
|
|
819
|
-
return jsxRuntime.jsx("div", {
|
|
820
|
-
"data-testid": "test-column-".concat(column.exportLabel),
|
|
821
|
-
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
822
|
-
children: column.key
|
|
823
|
-
})
|
|
824
|
-
}, column.exportLabel);
|
|
825
|
-
})
|
|
875
|
+
}), jsxRuntime.jsx(FieldsRenderer, {
|
|
876
|
+
fields: fields
|
|
826
877
|
})]
|
|
827
878
|
});
|
|
828
879
|
}
|
|
829
|
-
|
|
830
|
-
|
|
880
|
+
ExportFields.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
881
|
+
// TODO: Circular reference
|
|
882
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
831
883
|
key: PropTypes__default["default"].string.isRequired,
|
|
832
|
-
|
|
884
|
+
label: PropTypes__default["default"].string,
|
|
885
|
+
isLocalized: PropTypes__default["default"].bool,
|
|
886
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
887
|
+
key: PropTypes__default["default"].string.isRequired,
|
|
888
|
+
label: PropTypes__default["default"].string,
|
|
889
|
+
isLocalized: PropTypes__default["default"].bool
|
|
890
|
+
}))
|
|
833
891
|
})).isRequired
|
|
834
892
|
} : {};
|
|
835
893
|
|
|
@@ -870,8 +928,8 @@ var ExportSelection = function ExportSelection() {
|
|
|
870
928
|
filters: _valuesInstanceProperty__default["default"](formik).appliedFilters,
|
|
871
929
|
onFilterRemove: onAppliedFilterRemove
|
|
872
930
|
})]
|
|
873
|
-
}), _valuesInstanceProperty__default["default"](formik).
|
|
874
|
-
|
|
931
|
+
}), _valuesInstanceProperty__default["default"](formik).fields.length > 0 && jsxRuntime.jsx(ExportFields, {
|
|
932
|
+
fields: _valuesInstanceProperty__default["default"](formik).fields
|
|
875
933
|
})]
|
|
876
934
|
})
|
|
877
935
|
})]
|
|
@@ -1124,7 +1182,7 @@ function ExportConfirmationModal(props) {
|
|
|
1124
1182
|
graphQuery = buildGraphQuery({
|
|
1125
1183
|
resourceType: resourceType,
|
|
1126
1184
|
selectedResourceIds: selectedResourceIds,
|
|
1127
|
-
|
|
1185
|
+
fields: _valuesInstanceProperty__default["default"](formik).fields,
|
|
1128
1186
|
exportSelectionType: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
1129
1187
|
languages: _valuesInstanceProperty__default["default"](formik).languages
|
|
1130
1188
|
});
|
|
@@ -25,6 +25,7 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
25
25
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
26
26
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
27
27
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
28
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
28
29
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
29
30
|
var PropTypes = require('prop-types');
|
|
30
31
|
var formik = require('formik');
|
|
@@ -58,6 +59,7 @@ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstancePro
|
|
|
58
59
|
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
59
60
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
60
61
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
62
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
61
63
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
62
64
|
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
63
65
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
@@ -210,6 +212,9 @@ function resourceTypeToOperationName(resourceType) {
|
|
|
210
212
|
function replaceSpecialCharsWithUnderscore(string) {
|
|
211
213
|
return string.replace(/[^a-zA-Z0-9]/g, '_');
|
|
212
214
|
}
|
|
215
|
+
function isFilledArray(maybeArray) {
|
|
216
|
+
return _Array$isArray__default["default"](maybeArray) && maybeArray.length;
|
|
217
|
+
}
|
|
213
218
|
|
|
214
219
|
function buildGraphQuery(exportSettings) {
|
|
215
220
|
var _context;
|
|
@@ -221,8 +226,8 @@ function buildGraphQuery(exportSettings) {
|
|
|
221
226
|
return gqlQueryBuilder.query({
|
|
222
227
|
operation: operation,
|
|
223
228
|
fields: [{
|
|
224
|
-
results:
|
|
225
|
-
|
|
229
|
+
results: buildFields({
|
|
230
|
+
fields: exportSettings.fields,
|
|
226
231
|
languages: exportSettings.languages
|
|
227
232
|
})
|
|
228
233
|
}],
|
|
@@ -233,8 +238,8 @@ function buildGraphQuery(exportSettings) {
|
|
|
233
238
|
return gqlQueryBuilder.query({
|
|
234
239
|
operation: operation,
|
|
235
240
|
fields: [{
|
|
236
|
-
results:
|
|
237
|
-
|
|
241
|
+
results: buildFields({
|
|
242
|
+
fields: exportSettings.fields,
|
|
238
243
|
languages: exportSettings.languages
|
|
239
244
|
})
|
|
240
245
|
}],
|
|
@@ -254,18 +259,27 @@ function buildGraphQuery(exportSettings) {
|
|
|
254
259
|
}
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
function
|
|
262
|
+
function buildFields(_ref) {
|
|
258
263
|
var _context2;
|
|
259
264
|
|
|
260
|
-
var
|
|
265
|
+
var fields = _ref.fields,
|
|
261
266
|
languages = _ref.languages;
|
|
262
|
-
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](
|
|
263
|
-
if (
|
|
267
|
+
return _flatInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](fields).call(fields, function (field) {
|
|
268
|
+
if (field.isLocalized) return _mapInstanceProperty__default["default"](languages).call(languages, function (language) {
|
|
264
269
|
var _context3, _context4, _context5;
|
|
265
270
|
|
|
266
|
-
var alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(
|
|
267
|
-
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5,
|
|
268
|
-
});else
|
|
271
|
+
var alias = replaceSpecialCharsWithUnderscore(_concatInstanceProperty__default["default"](_context3 = "".concat(field.key, "_")).call(_context3, language));
|
|
272
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(alias, ": ")).call(_context5, field.key, "(locale: \"")).call(_context4, language, "\")");
|
|
273
|
+
});else {
|
|
274
|
+
if (isFilledArray(field.fields)) {
|
|
275
|
+
return _defineProperty({}, field.key, buildFields({
|
|
276
|
+
fields: field.fields,
|
|
277
|
+
languages: languages
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return field.key;
|
|
282
|
+
}
|
|
269
283
|
})).call(_context2);
|
|
270
284
|
}
|
|
271
285
|
|
|
@@ -427,9 +441,16 @@ PropTypes__default["default"].shape({
|
|
|
427
441
|
allResourcesCount: PropTypes__default["default"].number.isRequired,
|
|
428
442
|
matchingResourcesCount: PropTypes__default["default"].number,
|
|
429
443
|
selectedResourceIds: PropTypes__default["default"].array,
|
|
430
|
-
|
|
444
|
+
// TODO: Circular reference
|
|
445
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
431
446
|
key: PropTypes__default["default"].string.isRequired,
|
|
432
|
-
|
|
447
|
+
label: PropTypes__default["default"].string,
|
|
448
|
+
isLocalized: PropTypes__default["default"].bool,
|
|
449
|
+
fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
450
|
+
key: PropTypes__default["default"].string.isRequired,
|
|
451
|
+
label: PropTypes__default["default"].string,
|
|
452
|
+
isLocalized: PropTypes__default["default"].bool
|
|
453
|
+
}))
|
|
433
454
|
})).isRequired,
|
|
434
455
|
exportSelectionType: PropTypes__default["default"].string,
|
|
435
456
|
appliedSearchTerms: PropTypes__default["default"].array,
|
|
@@ -476,7 +497,7 @@ var ExportResourcesContextProvider = function ExportResourcesContextProvider(pro
|
|
|
476
497
|
isUpperCase: true
|
|
477
498
|
}), "_Export_")).call(_context, todayFormatted),
|
|
478
499
|
languages: [language],
|
|
479
|
-
|
|
500
|
+
fields: props.fields,
|
|
480
501
|
appliedSearchTerms: props.appliedSearchTerms,
|
|
481
502
|
appliedFilters: props.appliedFilters,
|
|
482
503
|
exportSelectionType: props.exportSelectionType,
|
|
@@ -771,9 +792,46 @@ AppliedSearchTerms.propTypes = {};
|
|
|
771
792
|
|
|
772
793
|
function ownKeys$6(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
773
794
|
|
|
774
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
775
|
-
|
|
776
|
-
|
|
795
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$6(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$6(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
796
|
+
|
|
797
|
+
function normalizeFields(fields) {
|
|
798
|
+
var result = _mapInstanceProperty__default["default"](fields).call(fields, function (field) {
|
|
799
|
+
if (isFilledArray(field.fields)) {
|
|
800
|
+
var _context;
|
|
801
|
+
|
|
802
|
+
return _mapInstanceProperty__default["default"](_context = normalizeFields(field.fields)).call(_context, function (nestedField) {
|
|
803
|
+
var _context2;
|
|
804
|
+
|
|
805
|
+
return _objectSpread$6(_objectSpread$6({}, nestedField), {}, {
|
|
806
|
+
key: _concatInstanceProperty__default["default"](_context2 = "".concat(field.key, ".")).call(_context2, nestedField.key)
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
return field;
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
return _flatInstanceProperty__default["default"](result).call(result);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function FieldsRenderer(_ref) {
|
|
818
|
+
var fields = _ref.fields;
|
|
819
|
+
var allFields = normalizeFields(fields);
|
|
820
|
+
return jsxRuntime.jsx(TagList, {
|
|
821
|
+
children: _mapInstanceProperty__default["default"](allFields).call(allFields, function (field) {
|
|
822
|
+
return jsxRuntime.jsx("div", {
|
|
823
|
+
"data-testid": "test-field-".concat(field.key),
|
|
824
|
+
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
825
|
+
children: field.label || field.key
|
|
826
|
+
})
|
|
827
|
+
}, field.key);
|
|
828
|
+
})
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
FieldsRenderer.propTypes = {};
|
|
833
|
+
function ExportFields(_ref2) {
|
|
834
|
+
var fields = _ref2.fields;
|
|
777
835
|
return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
|
|
778
836
|
scale: "s",
|
|
779
837
|
children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
|
|
@@ -786,24 +844,17 @@ function Columns(_ref) {
|
|
|
786
844
|
}), jsxRuntime.jsx(uiKit.Text.Body, {
|
|
787
845
|
intlMessage: _objectSpread$6(_objectSpread$6({}, messages.columnsMessage), {}, {
|
|
788
846
|
values: {
|
|
789
|
-
columnsCount:
|
|
847
|
+
columnsCount: fields.length,
|
|
790
848
|
b: getBold
|
|
791
849
|
}
|
|
792
850
|
})
|
|
793
851
|
})]
|
|
794
|
-
}), jsxRuntime.jsx(
|
|
795
|
-
|
|
796
|
-
return jsxRuntime.jsx("div", {
|
|
797
|
-
"data-testid": "test-column-".concat(column.exportLabel),
|
|
798
|
-
children: jsxRuntime.jsx(uiKit.Tag, {
|
|
799
|
-
children: column.key
|
|
800
|
-
})
|
|
801
|
-
}, column.exportLabel);
|
|
802
|
-
})
|
|
852
|
+
}), jsxRuntime.jsx(FieldsRenderer, {
|
|
853
|
+
fields: fields
|
|
803
854
|
})]
|
|
804
855
|
});
|
|
805
856
|
}
|
|
806
|
-
|
|
857
|
+
ExportFields.propTypes = {};
|
|
807
858
|
|
|
808
859
|
var ExportSelection = function ExportSelection() {
|
|
809
860
|
var _useExportResourcesCo = useExportResourcesContext(),
|
|
@@ -842,8 +893,8 @@ var ExportSelection = function ExportSelection() {
|
|
|
842
893
|
filters: _valuesInstanceProperty__default["default"](formik).appliedFilters,
|
|
843
894
|
onFilterRemove: onAppliedFilterRemove
|
|
844
895
|
})]
|
|
845
|
-
}), _valuesInstanceProperty__default["default"](formik).
|
|
846
|
-
|
|
896
|
+
}), _valuesInstanceProperty__default["default"](formik).fields.length > 0 && jsxRuntime.jsx(ExportFields, {
|
|
897
|
+
fields: _valuesInstanceProperty__default["default"](formik).fields
|
|
847
898
|
})]
|
|
848
899
|
})
|
|
849
900
|
})]
|
|
@@ -1092,7 +1143,7 @@ function ExportConfirmationModal(props) {
|
|
|
1092
1143
|
graphQuery = buildGraphQuery({
|
|
1093
1144
|
resourceType: resourceType,
|
|
1094
1145
|
selectedResourceIds: selectedResourceIds,
|
|
1095
|
-
|
|
1146
|
+
fields: _valuesInstanceProperty__default["default"](formik).fields,
|
|
1096
1147
|
exportSelectionType: _valuesInstanceProperty__default["default"](formik).exportSelectionType,
|
|
1097
1148
|
languages: _valuesInstanceProperty__default["default"](formik).languages
|
|
1098
1149
|
});
|
package/package.json
CHANGED