@commercetools-frontend-extensions/export-resources-modal 3.5.1 → 3.7.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.
@@ -36,16 +36,20 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
36
36
  var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
37
37
  var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
38
38
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
39
+ var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
39
40
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
40
41
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
41
42
  var sdk = require('@commercetools-frontend/sdk');
42
43
  var actionsGlobal = require('@commercetools-frontend/actions-global');
43
44
  var constants = require('@commercetools-frontend/constants');
45
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
44
46
  var _styled = require('@emotion/styled/base');
45
47
  var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
46
48
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
49
+ var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
50
+ var throttle = require('lodash/throttle');
51
+ var react = require('@emotion/react');
47
52
  var PropTypes = require('prop-types');
48
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
49
53
  var formik = require('formik');
50
54
 
51
55
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -70,11 +74,14 @@ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
70
74
  var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
71
75
  var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
72
76
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
77
+ var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
73
78
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
74
79
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
75
80
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
76
81
  var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
77
82
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
83
+ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
84
+ var throttle__default = /*#__PURE__*/_interopDefault(throttle);
78
85
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
79
86
 
80
87
  function getBold(msg) {
@@ -228,6 +235,31 @@ var messages = reactIntl.defineMessages({
228
235
  id: 'ExportResourcesModal.unexpectedError',
229
236
  description: 'Generic notification message when starting export process fails',
230
237
  defaultMessage: 'An error occurred while starting the export process. Please try again or contact support if the problem persists.'
238
+ },
239
+ searchForFields: {
240
+ id: 'ExportResourcesModal.searchForFields',
241
+ description: 'Placeholder for "Search for fields" search input',
242
+ defaultMessage: 'Search for fields'
243
+ },
244
+ thereAreNoResults: {
245
+ id: 'ExportResourcesModal.thereAreNoResults',
246
+ description: 'No search results message',
247
+ defaultMessage: 'There are no results that match your search.'
248
+ },
249
+ suggestions: {
250
+ id: 'ExportResourcesModal.suggestions',
251
+ description: 'In Export fields selection - Suggestions message',
252
+ defaultMessage: 'Suggestions:'
253
+ },
254
+ checkTheSpelling: {
255
+ id: 'ExportResourcesModal.checkTheSpelling',
256
+ description: 'In Export fields selection - Check the spelling message',
257
+ defaultMessage: 'Check the spelling.'
258
+ },
259
+ searchByEnteringTheExactFieldName: {
260
+ id: 'ExportResourcesModal.searchByEnteringTheExactFieldName',
261
+ description: 'In Export fields selection - Search by entering the exact field name message',
262
+ defaultMessage: 'Try searching by entering the exact field name.'
231
263
  }
232
264
  });
233
265
 
@@ -405,7 +437,7 @@ function validate(_ref) {
405
437
  }
406
438
 
407
439
  function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
408
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys$4(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys$4(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
440
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context8, _context9; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context8 = ownKeys$4(Object(t), !0)).call(_context8, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context9 = ownKeys$4(Object(t))).call(_context9, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
409
441
  function resourceTypeToDisplayName(_ref) {
410
442
  let resourceType = _ref.resourceType,
411
443
  _ref$isUpperCase = _ref.isUpperCase,
@@ -496,10 +528,32 @@ function extractGeneralFieldNames(generalFields) {
496
528
  function extractCustomFieldNamesWithPrefix(customFields) {
497
529
  const fields = _flatMapInstanceProperty__default["default"](customFields).call(customFields, customType => {
498
530
  var _context6;
499
- return _mapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => "custom.fields.".concat(field.name));
531
+ return _flatMapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => {
532
+ return getCustomFieldNameWithPrefix(field, customType.type.resourceTypeIds);
533
+ });
500
534
  });
501
535
  return [...new _Set__default["default"](fields)];
502
536
  }
537
+ function getCustomFieldNameWithPrefix(field, resourceTypeIds) {
538
+ const prefixes = _mapInstanceProperty__default["default"](resourceTypeIds).call(resourceTypeIds, type => {
539
+ switch (type) {
540
+ case 'asset':
541
+ return 'assets.custom.fields.';
542
+ default:
543
+ return 'custom.fields.';
544
+ }
545
+ });
546
+ return _mapInstanceProperty__default["default"](prefixes).call(prefixes, prefix => {
547
+ var _context7;
548
+ return _concatInstanceProperty__default["default"](_context7 = "".concat(prefix)).call(_context7, field.name);
549
+ });
550
+ }
551
+
552
+ // Sorts an array of custom field names placing those starting with 'assets.custom.fields.' first
553
+ // This function doesn't affect the order of other custom fields
554
+ function sortCustomFields(fields) {
555
+ return _sortInstanceProperty__default["default"](fields).call(fields, (a, b) => _startsWithInstanceProperty__default["default"](b).call(b, 'assets.custom.fields.') - _startsWithInstanceProperty__default["default"](a).call(a, 'assets.custom.fields.'));
556
+ }
503
557
 
504
558
  // TODO: remove this function when filters are passed directly from parent views
505
559
  // This function is temporary and will be removed in the future
@@ -511,16 +565,23 @@ function tmpBuildFilters(selectedResourceIds) {
511
565
  return ["id in (".concat(formattedIds, ")")];
512
566
  }
513
567
 
568
+ const parentKeyExtension = ['parent.key', 'parent.typeId'];
569
+ const customFieldsExtension = ['custom.type.key', 'custom.type.typeId'];
570
+ const assetsCustomFieldsExtension = ['assets.custom.type.key', 'assets.custom.type.typeId'];
571
+ const assetsExtension = ['assets.key', 'assets.name', 'assets.sources.key', 'assets.sources.uri', 'assets.sources.contentType', 'assets.sources.dimensions.w', 'assets.sources.dimensions.h', 'assets.description', 'assets.tags'];
514
572
  const categoryFieldExtension = fields => {
515
573
  return _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
516
574
  if (field === 'parent.key') {
517
- return [...acc, field, 'parent.typeId'];
575
+ return [...acc, ...parentKeyExtension];
518
576
  }
519
577
  if (_startsWithInstanceProperty__default["default"](field).call(field, 'custom.fields.') && !_includesInstanceProperty__default["default"](acc).call(acc, 'custom.type.key')) {
520
- return [...acc, 'custom.type.key', 'custom.type.typeId', field];
578
+ return [...acc, ...customFieldsExtension, field];
521
579
  }
522
580
  if (field === 'assets') {
523
- return [...acc, 'assets.key', 'assets.name', 'assets.sources.key', 'assets.sources.uri', 'assets.sources.contentType', 'assets.sources.dimensions.w', 'assets.sources.dimensions.h', 'assets.description', 'assets.tags'];
581
+ return [...acc, ...assetsExtension];
582
+ }
583
+ if (_startsWithInstanceProperty__default["default"](field).call(field, 'assets.custom.fields.') && !_includesInstanceProperty__default["default"](acc).call(acc, 'assets.custom.type.key')) {
584
+ return [...acc, ...assetsCustomFieldsExtension, field];
524
585
  }
525
586
  return [...acc, field];
526
587
  }, []);
@@ -618,7 +679,7 @@ const useStartExportOperation = props => {
618
679
  const selectedGeneralFields = getSelectedGeneralFields(values.fields);
619
680
  const selectedCustomFields = getSelectedCustomFields(values.customFields);
620
681
  const generalFields = extractGeneralFieldNames(selectedGeneralFields);
621
- const customFields = extractCustomFieldNamesWithPrefix(selectedCustomFields);
682
+ const customFields = sortCustomFields(extractCustomFieldNamesWithPrefix(selectedCustomFields));
622
683
  const filters = tmpBuildFilters(props.selectedResourceIds);
623
684
  const response = await createExportOperation({
624
685
  projectKey,
@@ -796,29 +857,50 @@ const ExportFileSettingsStep = () => {
796
857
  });
797
858
  };
798
859
 
860
+ var _ref = {
861
+ name: "ti75j2",
862
+ styles: "margin:0"
863
+ } ;
864
+ const NoSearchResults = () => {
865
+ return jsxRuntime.jsxs(uiKit.Card, {
866
+ insetScale: "xl",
867
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
868
+ scale: "s",
869
+ children: [jsxRuntime.jsx(uiKit.Text.Body, {
870
+ fontWeight: "medium",
871
+ intlMessage: messages.thereAreNoResults
872
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
873
+ intlMessage: messages.suggestions
874
+ })]
875
+ }), jsxRuntime.jsxs("ul", {
876
+ css: _ref,
877
+ children: [jsxRuntime.jsx("li", {
878
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
879
+ intlMessage: messages.checkTheSpelling
880
+ })
881
+ }), jsxRuntime.jsx("li", {
882
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
883
+ intlMessage: messages.searchByEnteringTheExactFieldName
884
+ })
885
+ })]
886
+ })]
887
+ });
888
+ };
889
+
799
890
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
800
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context12, _context13; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context12 = ownKeys$1(Object(t), !0)).call(_context12, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context13 = ownKeys$1(Object(t))).call(_context13, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
801
- const StyledCardLeft = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
891
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context22, _context23; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context22 = ownKeys$1(Object(t), !0)).call(_context22, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context23 = ownKeys$1(Object(t))).call(_context23, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
892
+ const StyledGroupCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
802
893
  target: "e1ocu3bb1"
803
- } )("height:100%;background-color:#f9f9fb;border-top:", _ref => {
804
- let isTopRow = _ref.isTopRow;
805
- return isTopRow ? uiKit.designTokens.borderForCardWhenRaised : 'none';
806
- }, ";border-radius:", _ref2 => {
807
- let isTopRow = _ref2.isTopRow;
808
- return isTopRow ? '4px 0px 0px 0px' : '0px 0px 0px 4px';
809
- }, ";" + ("" ));
810
- const StyledCardRight = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
894
+ } )("border-right:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";background-color:", uiKit.designTokens.colorNeutral98, ";height:100%;border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
895
+ const StyledFieldsCard = /*#__PURE__*/_styled__default["default"](uiKit.Card, {
811
896
  target: "e1ocu3bb0"
812
- } )("height:100%;border-left:0;border-top:", _ref3 => {
813
- let isTopRow = _ref3.isTopRow;
814
- return isTopRow ? uiKit.designTokens.borderForCardWhenRaised : 'none';
815
- }, ";border-radius:", _ref4 => {
816
- let isTopRow = _ref4.isTopRow;
817
- return isTopRow ? '0px 4px 0px 0px' : '0px 0px 4px 0px';
818
- }, ";" + ("" ));
897
+ } )("border-radius:0;", props => props.showTopBorder && /*#__PURE__*/react.css("border-top:", uiKit.designTokens.borderWidth1, " solid ", uiKit.designTokens.colorNeutral90, ";" + ("" ), "" ), ";" + ("" ));
819
898
  const ExportFieldsSelectionStep = () => {
820
- var _formik$values$custom;
821
899
  const intl = reactIntl.useIntl();
900
+ const _React$useState = React__default["default"].useState(''),
901
+ _React$useState2 = _slicedToArray(_React$useState, 2),
902
+ fieldSearchTerm = _React$useState2[0],
903
+ setFieldSearchTerm = _React$useState2[1];
822
904
  const _useExportResourcesCo = useExportResourcesContext(),
823
905
  formik = _useExportResourcesCo.formik,
824
906
  setCurrentStep = _useExportResourcesCo.setCurrentStep,
@@ -846,6 +928,33 @@ const ExportFieldsSelectionStep = () => {
846
928
  const isAtLeastOneCustomFieldChecked = React__default["default"].useMemo(() => {
847
929
  return _someInstanceProperty__default["default"](allCustomFields).call(allCustomFields, field => field.isChecked);
848
930
  }, [allCustomFields]);
931
+ const filteredGeneralFields = React__default["default"].useMemo(() => {
932
+ var _context4;
933
+ return _filterInstanceProperty__default["default"](_context4 = _valuesInstanceProperty__default["default"](formik).fields).call(_context4, field => {
934
+ var _context5;
935
+ return _includesInstanceProperty__default["default"](_context5 = field.label.toLowerCase()).call(_context5, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase());
936
+ });
937
+ }, [_valuesInstanceProperty__default["default"](formik).fields, fieldSearchTerm]);
938
+ const filteredCustomFields = React__default["default"].useMemo(() => {
939
+ var _context6, _context7;
940
+ return _filterInstanceProperty__default["default"](_context6 = _mapInstanceProperty__default["default"](_context7 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context7, customType => {
941
+ var _context8, _context9;
942
+ return _objectSpread$1(_objectSpread$1({}, customType), {}, {
943
+ fields: _includesInstanceProperty__default["default"](_context8 = customType.type.label.toLowerCase()).call(_context8, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase()) ? customType.fields : _filterInstanceProperty__default["default"](_context9 = customType.fields).call(_context9, field => {
944
+ var _context10;
945
+ return _includesInstanceProperty__default["default"](_context10 = field.label.toLowerCase()).call(_context10, _trimInstanceProperty__default["default"](fieldSearchTerm).call(fieldSearchTerm).toLowerCase());
946
+ })
947
+ });
948
+ })).call(_context6, customType => customType.fields.length > 0);
949
+ }, [_valuesInstanceProperty__default["default"](formik).customFields, fieldSearchTerm]);
950
+ const onSearchChange = React__default["default"].useCallback(event => {
951
+ setFieldSearchTerm(event.target.value);
952
+ }, [setFieldSearchTerm]);
953
+ const hasResults = filteredGeneralFields.length > 0 || filteredCustomFields.length > 0;
954
+ const onSearchChangeThrottled = React__default["default"].useMemo(() => throttle__default["default"](onSearchChange, 300), [onSearchChange]);
955
+ const onSearchReset = () => {
956
+ setFieldSearchTerm('');
957
+ };
849
958
  return jsxRuntime.jsx(applicationComponents.FormDialog, {
850
959
  isOpen: true,
851
960
  title: intl.formatMessage(messages.modalTitle, {
@@ -872,112 +981,128 @@ const ExportFieldsSelectionStep = () => {
872
981
  intlMessage: messages.fieldDefinitions,
873
982
  to: FIELD_DEFINITIONS_URLS[resourceType]
874
983
  })]
875
- }), jsxRuntime.jsxs(uiKit.Grid, {
876
- gridAutoFlow: "row",
877
- gridTemplateColumns: "".concat(uiKit.designTokens.constraint5, " auto"),
878
- children: [jsxRuntime.jsx(uiKit.Grid.Item, {
879
- children: jsxRuntime.jsx(StyledCardLeft, {
880
- isTopRow: true,
881
- insetScale: "l",
882
- children: jsxRuntime.jsx(uiKit.CheckboxInput, {
883
- isIndeterminate: !areAllGeneralFieldsChecked && isAtLeastOneGeneralFieldChecked,
884
- isChecked: areAllGeneralFieldsChecked,
885
- onChange: e => {
886
- var _context4;
887
- formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context4 = _valuesInstanceProperty__default["default"](formik).fields).call(_context4, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
888
- isChecked: field.isRequired ? true : e.target.checked
889
- })));
890
- },
891
- children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allGeneralFields))
892
- })
893
- })
894
- }), jsxRuntime.jsx(uiKit.Grid.Item, {
895
- children: jsxRuntime.jsx(StyledCardRight, {
896
- isTopRow: true,
897
- insetScale: "l",
898
- children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
899
- scale: "s",
900
- children: jsxRuntime.jsx(GeneralFieldsSelection, {
901
- fields: _valuesInstanceProperty__default["default"](formik).fields,
902
- setFieldValue: formik.setFieldValue
984
+ }), jsxRuntime.jsx(uiKit.SearchTextInput, {
985
+ placeholder: intl.formatMessage(messages.searchForFields),
986
+ value: fieldSearchTerm,
987
+ onChange: onSearchChangeThrottled,
988
+ onReset: onSearchReset
989
+ }), !hasResults && jsxRuntime.jsx(NoSearchResults, {}), hasResults && jsxRuntime.jsx(uiKit.Card, {
990
+ insetScale: "none",
991
+ children: jsxRuntime.jsxs(uiKit.Grid, {
992
+ gridAutoFlow: "row",
993
+ gridTemplateColumns: "".concat(uiKit.designTokens.constraint5, " auto"),
994
+ children: [filteredGeneralFields.length > 0 && jsxRuntime.jsxs(jsxRuntime.Fragment, {
995
+ children: [jsxRuntime.jsx(uiKit.Grid.Item, {
996
+ children: jsxRuntime.jsx(StyledGroupCard, {
997
+ type: "flat",
998
+ insetScale: "l",
999
+ children: jsxRuntime.jsx(uiKit.CheckboxInput, {
1000
+ isIndeterminate: !areAllGeneralFieldsChecked && isAtLeastOneGeneralFieldChecked,
1001
+ isChecked: areAllGeneralFieldsChecked,
1002
+ onChange: e => {
1003
+ var _context11;
1004
+ formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context11 = _valuesInstanceProperty__default["default"](formik).fields).call(_context11, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
1005
+ isChecked: field.isRequired ? true : e.target.checked
1006
+ })));
1007
+ },
1008
+ children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allGeneralFields))
1009
+ })
903
1010
  })
904
- })
905
- })
906
- }), ((_formik$values$custom = _valuesInstanceProperty__default["default"](formik).customFields) === null || _formik$values$custom === void 0 ? void 0 : _formik$values$custom.length) > 0 && jsxRuntime.jsxs(jsxRuntime.Fragment, {
907
- children: [jsxRuntime.jsx(uiKit.Grid.Item, {
908
- children: jsxRuntime.jsx(StyledCardLeft, {
909
- insetScale: "l",
910
- children: jsxRuntime.jsx(uiKit.CheckboxInput, {
911
- isIndeterminate: !areAllCustomFieldsChecked && isAtLeastOneCustomFieldChecked,
912
- isChecked: areAllCustomFieldsChecked,
913
- onChange: e => {
914
- var _context5;
915
- formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context5 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context5, customType => {
916
- var _context6;
917
- return _objectSpread$1(_objectSpread$1({}, customType), {}, {
918
- fields: _mapInstanceProperty__default["default"](_context6 = customType.fields).call(_context6, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
919
- isChecked: e.target.checked
920
- }))
921
- });
922
- }));
923
- },
924
- children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allCustomFields))
1011
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1012
+ children: jsxRuntime.jsx(StyledFieldsCard, {
1013
+ type: "flat",
1014
+ insetScale: "l",
1015
+ children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
1016
+ scale: "s",
1017
+ children: jsxRuntime.jsx(GeneralFieldsSelection, {
1018
+ fields: filteredGeneralFields,
1019
+ formik: formik
1020
+ })
1021
+ })
925
1022
  })
926
- })
927
- }), jsxRuntime.jsx(uiKit.Grid.Item, {
928
- children: jsxRuntime.jsx(StyledCardRight, {
929
- insetScale: "l",
930
- children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
931
- scale: "s",
932
- children: [jsxRuntime.jsxs(uiKit.CheckboxInput, {
933
- isReadOnly: true,
934
- onChange: () => {},
935
- isChecked: isAtLeastOneCustomFieldChecked,
936
- children: [jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.customTypeKeyAndTypeId)), ' ', "*"]
937
- }), jsxRuntime.jsx(CustomFieldsSelection, {
938
- customFields: _valuesInstanceProperty__default["default"](formik).customFields,
939
- setFieldValue: formik.setFieldValue
940
- })]
1023
+ })]
1024
+ }), filteredCustomFields.length > 0 && jsxRuntime.jsxs(jsxRuntime.Fragment, {
1025
+ children: [jsxRuntime.jsx(uiKit.Grid.Item, {
1026
+ children: jsxRuntime.jsx(StyledGroupCard, {
1027
+ type: "flat",
1028
+ insetScale: "l",
1029
+ showTopBorder: filteredGeneralFields.length > 0,
1030
+ children: jsxRuntime.jsx(uiKit.CheckboxInput, {
1031
+ isIndeterminate: !areAllCustomFieldsChecked && isAtLeastOneCustomFieldChecked,
1032
+ isChecked: areAllCustomFieldsChecked,
1033
+ onChange: e => {
1034
+ var _context12;
1035
+ formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context12 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context12, customType => {
1036
+ var _context13;
1037
+ return _objectSpread$1(_objectSpread$1({}, customType), {}, {
1038
+ fields: _mapInstanceProperty__default["default"](_context13 = customType.fields).call(_context13, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
1039
+ isChecked: e.target.checked
1040
+ }))
1041
+ });
1042
+ }));
1043
+ },
1044
+ children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.allCustomFields))
1045
+ })
941
1046
  })
942
- })
1047
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1048
+ children: jsxRuntime.jsx(StyledFieldsCard, {
1049
+ type: "flat",
1050
+ insetScale: "l",
1051
+ showTopBorder: filteredGeneralFields.length > 0,
1052
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1053
+ scale: "s",
1054
+ children: [jsxRuntime.jsxs(uiKit.CheckboxInput, {
1055
+ isReadOnly: true,
1056
+ onChange: () => {},
1057
+ isChecked: isAtLeastOneCustomFieldChecked,
1058
+ children: [jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$1({}, messages.customTypeKeyAndTypeId)), ' ', "*"]
1059
+ }), jsxRuntime.jsx(CustomFieldsSelection, {
1060
+ customFields: filteredCustomFields,
1061
+ formik: formik
1062
+ })]
1063
+ })
1064
+ })
1065
+ })]
943
1066
  })]
944
- })]
1067
+ })
945
1068
  })]
946
1069
  })
947
1070
  })
948
1071
  });
949
1072
  };
950
- const GeneralFieldsSelection = _ref5 => {
951
- let fields = _ref5.fields,
952
- setFieldValue = _ref5.setFieldValue;
1073
+ const GeneralFieldsSelection = _ref => {
1074
+ let fields = _ref.fields,
1075
+ formik = _ref.formik;
953
1076
  return _mapInstanceProperty__default["default"](fields).call(fields, field => jsxRuntime.jsxs(uiKit.CheckboxInput, {
954
1077
  isChecked: field.isChecked,
955
1078
  isReadOnly: field.isRequired,
956
1079
  onChange: e => {
957
- setFieldValue('fields', _mapInstanceProperty__default["default"](fields).call(fields, _field => field.name === _field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
1080
+ var _context14;
1081
+ formik.setFieldValue('fields', _mapInstanceProperty__default["default"](_context14 = _valuesInstanceProperty__default["default"](formik).fields).call(_context14, _field => field.name === _field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
958
1082
  isChecked: e.target.checked
959
1083
  }) : _field));
960
1084
  },
961
1085
  children: [field.label, " ", field.isRequired && '*']
962
1086
  }, field.name));
963
1087
  };
964
- const CustomFieldsSelection = _ref6 => {
965
- let customFields = _ref6.customFields,
966
- setFieldValue = _ref6.setFieldValue;
1088
+ const CustomFieldsSelection = _ref2 => {
1089
+ let customFields = _ref2.customFields,
1090
+ formik = _ref2.formik;
967
1091
  return _mapInstanceProperty__default["default"](customFields).call(customFields, customType => {
968
- var _context7, _context8, _context10;
969
- const areAllFieldsChecked = _everyInstanceProperty__default["default"](_context7 = customType.fields).call(_context7, field => field.isChecked);
970
- const isAtLeastOneFieldChecked = _someInstanceProperty__default["default"](_context8 = customType.fields).call(_context8, field => field.isChecked);
1092
+ var _context15, _context16, _context19;
1093
+ const areAllFieldsChecked = _everyInstanceProperty__default["default"](_context15 = customType.fields).call(_context15, field => field.isChecked);
1094
+ const isAtLeastOneFieldChecked = _someInstanceProperty__default["default"](_context16 = customType.fields).call(_context16, field => field.isChecked);
971
1095
  return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
972
1096
  scale: "s",
973
1097
  children: [jsxRuntime.jsx(uiKit.CheckboxInput, {
974
1098
  isIndeterminate: !areAllFieldsChecked && isAtLeastOneFieldChecked,
975
1099
  isChecked: areAllFieldsChecked,
976
1100
  onChange: e => {
977
- setFieldValue('customFields', _mapInstanceProperty__default["default"](customFields).call(customFields, _customType => {
978
- var _context9;
1101
+ var _context17;
1102
+ formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context17 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context17, _customType => {
1103
+ var _context18;
979
1104
  return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
980
- fields: _mapInstanceProperty__default["default"](_context9 = _customType.fields).call(_context9, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
1105
+ fields: _mapInstanceProperty__default["default"](_context18 = _customType.fields).call(_context18, field => _objectSpread$1(_objectSpread$1({}, field), {}, {
981
1106
  isChecked: e.target.checked
982
1107
  }))
983
1108
  }) : _customType;
@@ -990,13 +1115,14 @@ const CustomFieldsSelection = _ref6 => {
990
1115
  scale: "l",
991
1116
  children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Spacings.Stack, {
992
1117
  scale: "s",
993
- children: _mapInstanceProperty__default["default"](_context10 = customType.fields).call(_context10, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
1118
+ children: _mapInstanceProperty__default["default"](_context19 = customType.fields).call(_context19, field => jsxRuntime.jsx(uiKit.CheckboxInput, {
994
1119
  isChecked: field.isChecked,
995
1120
  onChange: e => {
996
- setFieldValue('customFields', _mapInstanceProperty__default["default"](customFields).call(customFields, _customType => {
997
- var _context11;
1121
+ var _context20;
1122
+ formik.setFieldValue('customFields', _mapInstanceProperty__default["default"](_context20 = _valuesInstanceProperty__default["default"](formik).customFields).call(_context20, _customType => {
1123
+ var _context21;
998
1124
  return _customType.type.key === customType.type.key ? _objectSpread$1(_objectSpread$1({}, _customType), {}, {
999
- fields: _mapInstanceProperty__default["default"](_context11 = _customType.fields).call(_context11, _field => _field.name === field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
1125
+ fields: _mapInstanceProperty__default["default"](_context21 = _customType.fields).call(_context21, _field => _field.name === field.name ? _objectSpread$1(_objectSpread$1({}, _field), {}, {
1000
1126
  isChecked: e.target.checked
1001
1127
  }) : _field)
1002
1128
  }) : _customType;
@@ -1036,7 +1162,8 @@ PropTypes__default["default"].shape({
1036
1162
  customFields: PropTypes__default["default"].shape({
1037
1163
  type: PropTypes__default["default"].shape({
1038
1164
  key: PropTypes__default["default"].string.isRequired,
1039
- label: PropTypes__default["default"].string.isRequired
1165
+ label: PropTypes__default["default"].string.isRequired,
1166
+ resourceTypeIds: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string)
1040
1167
  }).isRequired,
1041
1168
  fields: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
1042
1169
  name: PropTypes__default["default"].string.isRequired,