@commercetools-frontend-extensions/export-resources-modal 0.0.0-canary-20240903101116 → 0.0.0-canary-20240904084742
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 +4 -8
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +253 -138
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +247 -132
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +250 -136
- package/dist/declarations/src/@hooks/index.d.ts +4 -0
- package/dist/declarations/src/@hooks/use-convert-custom-type-definitions-for-export.d.ts +8 -0
- package/dist/declarations/src/@hooks/use-export-resources-modal-context.d.ts +2 -0
- package/dist/declarations/src/@hooks/use-initial-values.d.ts +2 -0
- package/dist/declarations/src/@hooks/use-start-export-operation.d.ts +4 -0
- package/dist/declarations/src/@types/custom-type-definition.d.ts +38 -0
- package/dist/declarations/src/@types/export-resources-modal-types.d.ts +1 -2
- package/dist/declarations/src/@types/form.d.ts +0 -3
- package/dist/declarations/src/@types/index.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/package.json +3 -1
|
@@ -31,24 +31,25 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
|
|
|
31
31
|
var experimentalComponents = require('@commercetools-frontend/experimental-components');
|
|
32
32
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
33
33
|
var omitEmpty = require('omit-empty-es');
|
|
34
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
35
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
36
|
+
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
34
37
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
35
38
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
36
39
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
37
40
|
var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
|
|
38
41
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
39
42
|
var moment = require('moment');
|
|
40
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
41
|
-
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
42
|
-
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
43
43
|
var actionsGlobal = require('@commercetools-frontend/actions-global');
|
|
44
44
|
var constants = require('@commercetools-frontend/constants');
|
|
45
45
|
var sdk = require('@commercetools-frontend/sdk');
|
|
46
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
47
|
+
var l10n = require('@commercetools-frontend/l10n');
|
|
46
48
|
var _styled = require('@emotion/styled/base');
|
|
47
49
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
48
50
|
var throttle = require('lodash/throttle');
|
|
49
51
|
var react = require('@emotion/react');
|
|
50
52
|
var get = require('lodash/get');
|
|
51
|
-
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
52
53
|
var formik = require('formik');
|
|
53
54
|
var i18n = require('@commercetools-frontend/i18n');
|
|
54
55
|
var sentry = require('@commercetools-frontend/sentry');
|
|
@@ -69,15 +70,15 @@ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construc
|
|
|
69
70
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
70
71
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
71
72
|
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
73
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
74
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
75
|
+
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
72
76
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
73
77
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
74
78
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
75
79
|
var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
|
|
76
80
|
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
77
81
|
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
78
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
79
|
-
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
80
|
-
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
81
82
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
82
83
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
83
84
|
var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
@@ -116,6 +117,11 @@ var messages = reactIntl.defineMessages({
|
|
|
116
117
|
description: 'Label for the discount codes modal title',
|
|
117
118
|
defaultMessage: 'Export discount codes'
|
|
118
119
|
},
|
|
120
|
+
'modalTitle.customer': {
|
|
121
|
+
id: 'ExportResourcesModal.modalTitle.customer',
|
|
122
|
+
description: 'Label for the customers modal title',
|
|
123
|
+
defaultMessage: 'Export customers'
|
|
124
|
+
},
|
|
119
125
|
outputFormat: {
|
|
120
126
|
id: 'ExportResourcesModal.outputFormat',
|
|
121
127
|
description: 'File format like (csv, xls, ...etc)',
|
|
@@ -362,14 +368,14 @@ var messages = reactIntl.defineMessages({
|
|
|
362
368
|
}
|
|
363
369
|
});
|
|
364
370
|
|
|
365
|
-
function ownKeys$
|
|
366
|
-
function _objectSpread$
|
|
371
|
+
function ownKeys$7(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; }
|
|
372
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
367
373
|
function renderFileNameError(key) {
|
|
368
374
|
switch (key) {
|
|
369
375
|
case 'missing':
|
|
370
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
376
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages.missingFileNameError));
|
|
371
377
|
case 'invalidInput':
|
|
372
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
378
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages.invalidFileNameError));
|
|
373
379
|
default:
|
|
374
380
|
return null;
|
|
375
381
|
}
|
|
@@ -377,7 +383,7 @@ function renderFileNameError(key) {
|
|
|
377
383
|
function renderLocaleError(key) {
|
|
378
384
|
switch (key) {
|
|
379
385
|
case 'missing':
|
|
380
|
-
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$
|
|
386
|
+
return jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$7({}, messages.missingLocaleError));
|
|
381
387
|
default:
|
|
382
388
|
return null;
|
|
383
389
|
}
|
|
@@ -524,14 +530,99 @@ function useExportResourcesModalContext() {
|
|
|
524
530
|
return context;
|
|
525
531
|
}
|
|
526
532
|
|
|
527
|
-
|
|
528
|
-
return fields
|
|
529
|
-
|
|
530
|
-
|
|
533
|
+
const isAnyFieldChecked = fields => {
|
|
534
|
+
return _someInstanceProperty__default["default"](fields).call(fields, field => field.isChecked || field.fields && isAnyFieldChecked(field.fields));
|
|
535
|
+
};
|
|
536
|
+
const hasDependentFields = field => {
|
|
537
|
+
var _context;
|
|
538
|
+
return Boolean(field?.dependentGroupNames && field.dependentGroupNames.length > 0 || field?.dependentFieldNames && field.dependentFieldNames.length > 0 || field?.fields && _someInstanceProperty__default["default"](_context = field.fields).call(_context, nestedField => hasDependentFields(nestedField)));
|
|
539
|
+
};
|
|
540
|
+
const isFieldOrNestedFieldChecked = (field, fieldName) => {
|
|
541
|
+
if (field.name === fieldName && field.isChecked) {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
if (field.fields) {
|
|
545
|
+
var _context2;
|
|
546
|
+
return _someInstanceProperty__default["default"](_context2 = field.fields).call(_context2, nestedField => {
|
|
547
|
+
return nestedField.isChecked || isFieldOrNestedFieldChecked(nestedField, fieldName);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return false;
|
|
551
|
+
};
|
|
552
|
+
const getIndependentFields = group => {
|
|
553
|
+
const independentFields = [];
|
|
554
|
+
const findIndependentFields = fields => {
|
|
555
|
+
_forEachInstanceProperty__default["default"](fields).call(fields, field => {
|
|
556
|
+
if (!field.dependentGroupNames?.length && !field.dependentFieldNames?.length) {
|
|
557
|
+
independentFields.push(field);
|
|
558
|
+
}
|
|
559
|
+
if (field.fields) {
|
|
560
|
+
findIndependentFields(field.fields);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
findIndependentFields(group.fields);
|
|
565
|
+
return independentFields;
|
|
566
|
+
};
|
|
567
|
+
const checkDependentFields = (independentFields, dependentFieldNames) => {
|
|
568
|
+
return _someInstanceProperty__default["default"](dependentFieldNames).call(dependentFieldNames, fieldName => _someInstanceProperty__default["default"](independentFields).call(independentFields, field => {
|
|
569
|
+
if (field.name === fieldName) {
|
|
570
|
+
if (field.fields) {
|
|
571
|
+
var _context3;
|
|
572
|
+
return _someInstanceProperty__default["default"](_context3 = field.fields).call(_context3, nestedField => isFieldOrNestedFieldChecked(nestedField, fieldName));
|
|
573
|
+
}
|
|
574
|
+
if (isFieldOrNestedFieldChecked(field, fieldName)) {
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return false;
|
|
579
|
+
}));
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Checks if any dependent fields are checked within the field groups
|
|
584
|
+
*
|
|
585
|
+
* This function iterates over the provided dependent group names and checks if any fields within those groups
|
|
586
|
+
* are checked. It considers both independent fields and their nested fields within
|
|
587
|
+
* the specified dependent field names
|
|
588
|
+
*
|
|
589
|
+
* @param groups - The array of field groups
|
|
590
|
+
* @param dependentGroupNames - The names of the groups to check for dependencies
|
|
591
|
+
* @param dependentFieldNames - The names of the fields to check within the groups
|
|
592
|
+
* @returns True if any dependent fields are checked otherwise false
|
|
593
|
+
*/
|
|
594
|
+
const isAnyDependentChecked = function (groups) {
|
|
595
|
+
let dependentGroupNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
596
|
+
let dependentFieldNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
597
|
+
return _someInstanceProperty__default["default"](dependentGroupNames).call(dependentGroupNames, groupName => {
|
|
598
|
+
const group = _findInstanceProperty__default["default"](groups).call(groups, g => g.groupName === groupName);
|
|
599
|
+
if (group) {
|
|
600
|
+
const independentFields = getIndependentFields(group);
|
|
601
|
+
const isADependentFieldChecked = isAnyFieldChecked(independentFields);
|
|
602
|
+
const isFieldDependentChecked = checkDependentFields(independentFields, dependentFieldNames);
|
|
603
|
+
if (dependentFieldNames.length > 0) {
|
|
604
|
+
return isADependentFieldChecked && isFieldDependentChecked;
|
|
605
|
+
}
|
|
606
|
+
return isADependentFieldChecked || isFieldDependentChecked;
|
|
531
607
|
}
|
|
532
|
-
return
|
|
608
|
+
return false;
|
|
533
609
|
});
|
|
534
|
-
}
|
|
610
|
+
};
|
|
611
|
+
const areAllFieldsChecked = fields => {
|
|
612
|
+
return _everyInstanceProperty__default["default"](fields).call(fields, field => field.fields ? areAllFieldsChecked(field.fields) : field.isChecked || field.isRequired || hasDependentFields(field));
|
|
613
|
+
};
|
|
614
|
+
const getTotalCheckedFields = group => {
|
|
615
|
+
const countCheckedFields = fields => {
|
|
616
|
+
return _reduceInstanceProperty__default["default"](fields).call(fields, (total, field) => {
|
|
617
|
+
if (field.fields) {
|
|
618
|
+
return total + countCheckedFields(field.fields);
|
|
619
|
+
}
|
|
620
|
+
return total + (field.isChecked ? 1 : 0);
|
|
621
|
+
}, 0);
|
|
622
|
+
};
|
|
623
|
+
return countCheckedFields(group.fields);
|
|
624
|
+
};
|
|
625
|
+
|
|
535
626
|
function validate(_ref) {
|
|
536
627
|
let values = _valuesInstanceProperty__default["default"](_ref),
|
|
537
628
|
step = _ref.step;
|
|
@@ -554,8 +645,8 @@ function validate(_ref) {
|
|
|
554
645
|
if (step === 2) {
|
|
555
646
|
const allFields = _reduceInstanceProperty__default["default"](groups).call(groups, (acc, group) => _concatInstanceProperty__default["default"](acc).call(acc, group.fields), []);
|
|
556
647
|
const checkedFieldsCount = _filterInstanceProperty__default["default"](allFields).call(allFields, field => {
|
|
557
|
-
if (field.fields) return
|
|
558
|
-
return !field.isRequired &&
|
|
648
|
+
if (field.fields) return isAnyFieldChecked(field.fields);
|
|
649
|
+
return !field.isRequired && field.isChecked;
|
|
559
650
|
}).length;
|
|
560
651
|
if (checkedFieldsCount < 1) {
|
|
561
652
|
errors.fields.missing = true;
|
|
@@ -657,8 +748,8 @@ function getInitialExportType(args) {
|
|
|
657
748
|
return EXPORT_TYPES.ALL;
|
|
658
749
|
}
|
|
659
750
|
|
|
660
|
-
function ownKeys$
|
|
661
|
-
function _objectSpread$
|
|
751
|
+
function ownKeys$6(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; }
|
|
752
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
662
753
|
const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
663
754
|
const updateFields = (fields, isParentChecked, parentFieldPath) => {
|
|
664
755
|
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
@@ -668,7 +759,7 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
668
759
|
} else {
|
|
669
760
|
if (cachedSelectedGroups[`${parentFieldPath}.${field.name}`] !== undefined) {
|
|
670
761
|
isChecked = cachedSelectedGroups[`${parentFieldPath}.${field.name}`];
|
|
671
|
-
} else if (!field
|
|
762
|
+
} else if (!hasDependentFields(field) && field.isSelectedByDefault) {
|
|
672
763
|
isChecked = true;
|
|
673
764
|
} else if (isParentChecked) {
|
|
674
765
|
isChecked = true;
|
|
@@ -679,7 +770,7 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
679
770
|
updatedFields = updateFields(field.fields, isChecked, `${parentFieldPath}.${field.name}`);
|
|
680
771
|
isChecked = false;
|
|
681
772
|
}
|
|
682
|
-
return _objectSpread$
|
|
773
|
+
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
683
774
|
isChecked,
|
|
684
775
|
fields: updatedFields
|
|
685
776
|
});
|
|
@@ -687,7 +778,7 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
687
778
|
};
|
|
688
779
|
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
689
780
|
const updatedFields = updateFields(group.fields, false, group.groupName);
|
|
690
|
-
return _objectSpread$
|
|
781
|
+
return _objectSpread$6(_objectSpread$6({}, group), {}, {
|
|
691
782
|
fields: updatedFields
|
|
692
783
|
});
|
|
693
784
|
});
|
|
@@ -699,7 +790,7 @@ const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
|
699
790
|
if (field.fields) {
|
|
700
791
|
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
701
792
|
}
|
|
702
|
-
return _objectSpread$
|
|
793
|
+
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
703
794
|
additionalFieldExtensions: updatedAdditionalFieldExtensions
|
|
704
795
|
});
|
|
705
796
|
});
|
|
@@ -716,9 +807,9 @@ const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
|
716
807
|
}, []);
|
|
717
808
|
}
|
|
718
809
|
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
719
|
-
return _objectSpread$
|
|
810
|
+
return _objectSpread$6(_objectSpread$6({}, group), {}, {
|
|
720
811
|
dependentGroupNames: combineDependentGroupNames(group.fields),
|
|
721
|
-
fields: updateAdditionalFieldExtensions(group.fields,
|
|
812
|
+
fields: updateAdditionalFieldExtensions(group.fields, [])
|
|
722
813
|
});
|
|
723
814
|
});
|
|
724
815
|
};
|
|
@@ -733,7 +824,7 @@ const updateFieldGroupsWithIsExpandedValue = (groups, cachedExpandedGroups) => {
|
|
|
733
824
|
field.fields = updateFields(field.fields, groupName);
|
|
734
825
|
}
|
|
735
826
|
if (isExpanded !== null) {
|
|
736
|
-
return _objectSpread$
|
|
827
|
+
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
737
828
|
isExpanded
|
|
738
829
|
});
|
|
739
830
|
}
|
|
@@ -742,7 +833,7 @@ const updateFieldGroupsWithIsExpandedValue = (groups, cachedExpandedGroups) => {
|
|
|
742
833
|
}
|
|
743
834
|
return _mapInstanceProperty__default["default"](groups).call(groups, group => {
|
|
744
835
|
const updatedFields = updateFields(group.fields, group.groupName);
|
|
745
|
-
return _objectSpread$
|
|
836
|
+
return _objectSpread$6(_objectSpread$6({}, group), {}, {
|
|
746
837
|
isExpanded: cachedExpandedGroups[group.groupName] ?? group.isExpanded ?? false,
|
|
747
838
|
fields: updatedFields
|
|
748
839
|
});
|
|
@@ -755,35 +846,28 @@ const mapFormikErrors = error => {
|
|
|
755
846
|
};
|
|
756
847
|
}
|
|
757
848
|
if (_Array$isArray__default["default"](error)) {
|
|
758
|
-
return _reduceInstanceProperty__default["default"](error).call(error, (errorAggregator, currentError) => _objectSpread$
|
|
849
|
+
return _reduceInstanceProperty__default["default"](error).call(error, (errorAggregator, currentError) => _objectSpread$6(_objectSpread$6({}, errorAggregator), {}, {
|
|
759
850
|
[currentError]: true
|
|
760
851
|
}), {});
|
|
761
852
|
}
|
|
762
853
|
if (!error) return {};
|
|
763
854
|
return error;
|
|
764
855
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (
|
|
774
|
-
|
|
856
|
+
const updateFieldDependenciesStatus = formik => {
|
|
857
|
+
var _context;
|
|
858
|
+
const updateFields = (fields, path) => {
|
|
859
|
+
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
860
|
+
const currentPath = `${path}.fields[${index}]`;
|
|
861
|
+
if (hasDependentFields(field)) {
|
|
862
|
+
formik.setFieldValue(`${currentPath}.isChecked`, isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames), false);
|
|
863
|
+
}
|
|
864
|
+
if (field.fields) {
|
|
865
|
+
updateFields(field.fields, currentPath);
|
|
775
866
|
}
|
|
776
|
-
return result;
|
|
777
867
|
});
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
};
|
|
781
|
-
const checkAllFieldsSelected = fields => {
|
|
782
|
-
return _everyInstanceProperty__default["default"](fields).call(fields, field => {
|
|
783
|
-
if (field.fields) {
|
|
784
|
-
return checkAllFieldsSelected(field.fields);
|
|
785
|
-
}
|
|
786
|
-
return field.isChecked || field.isRequired || field.isReadOnly;
|
|
868
|
+
};
|
|
869
|
+
_forEachInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](formik).groups).call(_context, (group, index) => {
|
|
870
|
+
updateFields(group.fields, `groups[${index}]`);
|
|
787
871
|
});
|
|
788
872
|
};
|
|
789
873
|
|
|
@@ -864,21 +948,21 @@ const useStartExportOperation = props => {
|
|
|
864
948
|
})),
|
|
865
949
|
projectKey = _useApplicationContex.projectKey;
|
|
866
950
|
const extractFieldNamesFromGroups = groups => {
|
|
867
|
-
let
|
|
868
|
-
const
|
|
951
|
+
let checkedFields = [];
|
|
952
|
+
const getCheckedFields = fields => {
|
|
869
953
|
return _filterInstanceProperty__default["default"](fields).call(fields, field => {
|
|
870
954
|
if (field.fields) {
|
|
871
|
-
return
|
|
955
|
+
return getCheckedFields(field.fields);
|
|
872
956
|
}
|
|
873
|
-
if (field.isChecked)
|
|
957
|
+
if (field.isChecked) checkedFields.push(field);
|
|
874
958
|
return field.isChecked ?? false;
|
|
875
959
|
});
|
|
876
960
|
};
|
|
877
961
|
_forEachInstanceProperty__default["default"](groups).call(groups, group => {
|
|
878
|
-
|
|
962
|
+
getCheckedFields(group.fields);
|
|
879
963
|
});
|
|
880
964
|
return sortFieldsByFieldOrder({
|
|
881
|
-
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(
|
|
965
|
+
fieldNames: extractFieldNamesAndAdditionalFieldExtensions(checkedFields),
|
|
882
966
|
fieldOrder: props.fieldOrder
|
|
883
967
|
});
|
|
884
968
|
};
|
|
@@ -947,6 +1031,82 @@ const useStartExportOperation = props => {
|
|
|
947
1031
|
};
|
|
948
1032
|
};
|
|
949
1033
|
|
|
1034
|
+
const _excluded$1 = ["fieldDefinitions"];
|
|
1035
|
+
function ownKeys$5(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; }
|
|
1036
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$5(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$5(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1037
|
+
const customFieldKey = 'custom.fields';
|
|
1038
|
+
const getCustomFieldFullName = _ref => {
|
|
1039
|
+
var _context;
|
|
1040
|
+
let customFieldPrefix = _ref.customFieldPrefix,
|
|
1041
|
+
key = _ref.key;
|
|
1042
|
+
return _filterInstanceProperty__default["default"](_context = [customFieldPrefix, customFieldKey, key]).call(_context, Boolean).join('.');
|
|
1043
|
+
};
|
|
1044
|
+
const transformAndLocalizeTypeDefinitions = function () {
|
|
1045
|
+
let typeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1046
|
+
return _mapInstanceProperty__default["default"](typeDefinitions).call(typeDefinitions, _ref2 => {
|
|
1047
|
+
let fieldDefinitions = _ref2.fieldDefinitions,
|
|
1048
|
+
typeDefinition = _objectWithoutProperties(_ref2, _excluded$1);
|
|
1049
|
+
return {
|
|
1050
|
+
type: l10n.applyTransformedLocalizedFields(typeDefinition, [{
|
|
1051
|
+
from: 'nameAllLocales',
|
|
1052
|
+
to: 'name'
|
|
1053
|
+
}]),
|
|
1054
|
+
fields: _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, fieldDefinition => _objectSpread$5({}, l10n.applyTransformedLocalizedFields(fieldDefinition, [{
|
|
1055
|
+
from: 'labelAllLocales',
|
|
1056
|
+
to: 'label'
|
|
1057
|
+
}])))
|
|
1058
|
+
};
|
|
1059
|
+
});
|
|
1060
|
+
};
|
|
1061
|
+
const useConvertCustomTypeDefinitionsForExport = () => {
|
|
1062
|
+
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1063
|
+
language: applicationContext.dataLocale,
|
|
1064
|
+
languages: applicationContext.project?.languages
|
|
1065
|
+
})),
|
|
1066
|
+
language = _useApplicationContex.language,
|
|
1067
|
+
languages = _useApplicationContex.languages;
|
|
1068
|
+
const convertCustomTypeDefinitionsForExport = _ref3 => {
|
|
1069
|
+
let customTypeDefinitions = _ref3.customTypeDefinitions,
|
|
1070
|
+
customFieldPrefix = _ref3.customFieldPrefix,
|
|
1071
|
+
expandAll = _ref3.expandAll;
|
|
1072
|
+
if (!customTypeDefinitions) return [];
|
|
1073
|
+
const transformedCustomTypeDefinitions = transformAndLocalizeTypeDefinitions(customTypeDefinitions);
|
|
1074
|
+
return _mapInstanceProperty__default["default"](transformedCustomTypeDefinitions).call(transformedCustomTypeDefinitions, customTypeDefinition => {
|
|
1075
|
+
var _context2;
|
|
1076
|
+
return {
|
|
1077
|
+
isExpandable: true,
|
|
1078
|
+
isExpanded: expandAll,
|
|
1079
|
+
name: customTypeDefinition.type.key,
|
|
1080
|
+
label: l10n.formatLocalizedString({
|
|
1081
|
+
nameAllLocales: customTypeDefinition.type.name
|
|
1082
|
+
}, {
|
|
1083
|
+
key: 'nameAllLocales',
|
|
1084
|
+
locale: language,
|
|
1085
|
+
fallbackOrder: languages,
|
|
1086
|
+
fallback: customTypeDefinition.type.key
|
|
1087
|
+
}),
|
|
1088
|
+
fields: _mapInstanceProperty__default["default"](_context2 = customTypeDefinition.fields).call(_context2, fieldDefinition => ({
|
|
1089
|
+
name: getCustomFieldFullName({
|
|
1090
|
+
customFieldPrefix: customFieldPrefix,
|
|
1091
|
+
key: fieldDefinition.name
|
|
1092
|
+
}),
|
|
1093
|
+
label: l10n.formatLocalizedString({
|
|
1094
|
+
labelAllLocales: fieldDefinition.label
|
|
1095
|
+
}, {
|
|
1096
|
+
key: 'labelAllLocales',
|
|
1097
|
+
locale: language,
|
|
1098
|
+
fallbackOrder: languages,
|
|
1099
|
+
fallback: fieldDefinition.name
|
|
1100
|
+
})
|
|
1101
|
+
}))
|
|
1102
|
+
};
|
|
1103
|
+
});
|
|
1104
|
+
};
|
|
1105
|
+
return {
|
|
1106
|
+
convertCustomTypeDefinitionsForExport
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
|
|
950
1110
|
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; }
|
|
951
1111
|
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
952
1112
|
function ExportScopeSection() {
|
|
@@ -1136,50 +1296,8 @@ const useExportFieldSelectionContext = () => {
|
|
|
1136
1296
|
return React.useContext(ExportFieldSelectionContext);
|
|
1137
1297
|
};
|
|
1138
1298
|
|
|
1139
|
-
const calculateTotalSelectedFields = (group, formik) => {
|
|
1140
|
-
let result = 0;
|
|
1141
|
-
// Check `isChecked` fields
|
|
1142
|
-
function countSelectedFields(fields) {
|
|
1143
|
-
_forEachInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1144
|
-
if (field.fields) {
|
|
1145
|
-
countSelectedFields(field.fields);
|
|
1146
|
-
} else if (field.isChecked) {
|
|
1147
|
-
result += 1;
|
|
1148
|
-
}
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
countSelectedFields(group.fields);
|
|
1152
|
-
// check `isReadOnly` fields
|
|
1153
|
-
function countReadOnlyDependentFields(fields) {
|
|
1154
|
-
_forEachInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1155
|
-
if (field.fields) {
|
|
1156
|
-
countReadOnlyDependentFields(field.fields);
|
|
1157
|
-
} else if (field.dependentGroupNames?.length && isAnyDependentGroupChecked(field.dependentGroupNames, _valuesInstanceProperty__default["default"](formik).groups)) {
|
|
1158
|
-
result += 1;
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
function countReadOnlyFields(fields) {
|
|
1163
|
-
_forEachInstanceProperty__default["default"](fields).call(fields, field => {
|
|
1164
|
-
if (field.fields) {
|
|
1165
|
-
countReadOnlyFields(field.fields);
|
|
1166
|
-
} else if (field.isReadOnly && !field.dependentGroupNames?.length) {
|
|
1167
|
-
result += 1;
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
if (result > 0) {
|
|
1172
|
-
countReadOnlyFields(group.fields);
|
|
1173
|
-
}
|
|
1174
|
-
if (group.dependentGroupNames) {
|
|
1175
|
-
countReadOnlyDependentFields(group.fields);
|
|
1176
|
-
}
|
|
1177
|
-
return result;
|
|
1178
|
-
};
|
|
1179
1299
|
const ExportFieldSelectionStamp = _ref => {
|
|
1180
1300
|
let group = _ref.group;
|
|
1181
|
-
const _useExportResourcesMo = useExportResourcesModalContext(),
|
|
1182
|
-
formik = _useExportResourcesMo.formik;
|
|
1183
1301
|
const _useIntl = reactIntl.useIntl(),
|
|
1184
1302
|
formatMessage = _useIntl.formatMessage;
|
|
1185
1303
|
return jsxRuntime.jsx(uiKit.Card, {
|
|
@@ -1191,7 +1309,7 @@ const ExportFieldSelectionStamp = _ref => {
|
|
|
1191
1309
|
tone: "secondary",
|
|
1192
1310
|
isCondensed: true,
|
|
1193
1311
|
label: formatMessage(messages.selected, {
|
|
1194
|
-
total:
|
|
1312
|
+
total: getTotalCheckedFields(group)
|
|
1195
1313
|
})
|
|
1196
1314
|
})
|
|
1197
1315
|
})
|
|
@@ -1239,19 +1357,13 @@ const FieldSection = _ref3 => {
|
|
|
1239
1357
|
return jsxRuntime.jsx(uiKit.Spacings.Stack, {
|
|
1240
1358
|
scale: "s",
|
|
1241
1359
|
children: fields?.map((field, index) => {
|
|
1242
|
-
const
|
|
1243
|
-
const
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
if (field.dependentGroupNames) {
|
|
1250
|
-
return isAnyDependentGroupChecked(field.dependentGroupNames, _valuesInstanceProperty__default["default"](formik).groups);
|
|
1251
|
-
}
|
|
1252
|
-
return isAnySiblingChecked;
|
|
1253
|
-
}
|
|
1254
|
-
return isAnyOfTheChildFieldsChecked || field.isChecked;
|
|
1360
|
+
const hasDependents = Boolean(field.dependentGroupNames?.length || field.dependentFieldNames?.length);
|
|
1361
|
+
const isAnyOfTheChildFieldsChecked = isAnyFieldChecked(field.fields || []);
|
|
1362
|
+
const allFieldsChecked = areAllFieldsChecked(field.fields || []);
|
|
1363
|
+
const getIsChecked = () => {
|
|
1364
|
+
const isParent = Boolean(field.fields && field.fields?.length > 0);
|
|
1365
|
+
if (isParent) return areAllFieldsChecked(field.fields);
|
|
1366
|
+
return field.isChecked;
|
|
1255
1367
|
};
|
|
1256
1368
|
if (field.isHidden) return null;
|
|
1257
1369
|
return jsxRuntime.jsx(CollapsibleFieldWrapper, {
|
|
@@ -1281,11 +1393,12 @@ const FieldSection = _ref3 => {
|
|
|
1281
1393
|
scale: "s",
|
|
1282
1394
|
alignItems: "center",
|
|
1283
1395
|
children: jsxRuntime.jsxs(uiKit.CheckboxInput, {
|
|
1284
|
-
isIndeterminate: field.isExpandable && !
|
|
1285
|
-
isChecked:
|
|
1286
|
-
isReadOnly:
|
|
1396
|
+
isIndeterminate: field.isExpandable && !allFieldsChecked && isAnyOfTheChildFieldsChecked,
|
|
1397
|
+
isChecked: getIsChecked(),
|
|
1398
|
+
isReadOnly: hasDependents || field.isRequired,
|
|
1287
1399
|
onChange: e => {
|
|
1288
1400
|
const path = `${parentKeys.join('.')}.fields[${index}]`;
|
|
1401
|
+
const checked = e.target.checked;
|
|
1289
1402
|
// Update all child fields
|
|
1290
1403
|
const updateAllChildFieldsChecked = (path, checked) => {
|
|
1291
1404
|
const item = get__default["default"](_valuesInstanceProperty__default["default"](formik), path);
|
|
@@ -1294,7 +1407,7 @@ const FieldSection = _ref3 => {
|
|
|
1294
1407
|
_forEachInstanceProperty__default["default"](_context = item.fields).call(_context, (field, i) => {
|
|
1295
1408
|
const fieldPath = `${path}.fields[${i}]`;
|
|
1296
1409
|
if (!field.fields?.length) {
|
|
1297
|
-
formik.setFieldValue(`${fieldPath}.isChecked`, checked,
|
|
1410
|
+
formik.setFieldValue(`${fieldPath}.isChecked`, checked || field.isRequired,
|
|
1298
1411
|
// pass `false` to avoid revalidating the form with intermediate values
|
|
1299
1412
|
false);
|
|
1300
1413
|
}
|
|
@@ -1303,13 +1416,13 @@ const FieldSection = _ref3 => {
|
|
|
1303
1416
|
}
|
|
1304
1417
|
};
|
|
1305
1418
|
if (!field.fields?.length) {
|
|
1306
|
-
formik.setFieldValue(`${path}.isChecked`,
|
|
1419
|
+
formik.setFieldValue(`${path}.isChecked`, checked || field.isRequired,
|
|
1307
1420
|
// pass `false` to avoid revalidating the form with intermediate values
|
|
1308
1421
|
false);
|
|
1309
1422
|
}
|
|
1310
|
-
updateAllChildFieldsChecked(path,
|
|
1423
|
+
updateAllChildFieldsChecked(path, checked);
|
|
1311
1424
|
},
|
|
1312
|
-
children: [field.label, (
|
|
1425
|
+
children: [field.label, (hasDependents || field.isRequired) && ' *']
|
|
1313
1426
|
})
|
|
1314
1427
|
})]
|
|
1315
1428
|
}), field.fields && field.fields?.length > 0 && jsxRuntime.jsx(StyledExpandableContent, {
|
|
@@ -1354,8 +1467,8 @@ const FieldGroupSection = _ref2 => {
|
|
|
1354
1467
|
index = _ref2.index,
|
|
1355
1468
|
formik = _ref2.formik,
|
|
1356
1469
|
isForceExpanded = _ref2.isForceExpanded;
|
|
1357
|
-
const
|
|
1358
|
-
const
|
|
1470
|
+
const allFieldsChecked = React.useMemo(() => areAllFieldsChecked(group.fields), [group.fields]);
|
|
1471
|
+
const isAnyFieldInGroupChecked = React.useMemo(() => isAnyFieldChecked(group.fields), [group.fields]);
|
|
1359
1472
|
const _useExportFieldSelect = useExportFieldSelectionContext(),
|
|
1360
1473
|
updateExpandedGroups = _useExportFieldSelect.updateExpandedGroups;
|
|
1361
1474
|
const parentKey = `groups[${index}]`;
|
|
@@ -1368,7 +1481,7 @@ const FieldGroupSection = _ref2 => {
|
|
|
1368
1481
|
fields: updateAllFields(field.fields, checked)
|
|
1369
1482
|
});
|
|
1370
1483
|
}
|
|
1371
|
-
if (field.
|
|
1484
|
+
if (field.isRequired) return field;
|
|
1372
1485
|
return _objectSpread$2(_objectSpread$2({}, field), {}, {
|
|
1373
1486
|
isChecked: checked
|
|
1374
1487
|
});
|
|
@@ -1405,8 +1518,8 @@ const FieldGroupSection = _ref2 => {
|
|
|
1405
1518
|
icon: isOpen ? jsxRuntime.jsx(uiKit.AngleDownIcon, {}) : jsxRuntime.jsx(uiKit.AngleRightIcon, {}),
|
|
1406
1519
|
label: ""
|
|
1407
1520
|
}), jsxRuntime.jsx(uiKit.CheckboxInput, {
|
|
1408
|
-
isIndeterminate: !
|
|
1409
|
-
isChecked:
|
|
1521
|
+
isIndeterminate: !allFieldsChecked && isAnyFieldInGroupChecked,
|
|
1522
|
+
isChecked: allFieldsChecked,
|
|
1410
1523
|
onChange: handleChangeAllFields,
|
|
1411
1524
|
children: group.groupLabel
|
|
1412
1525
|
})]
|
|
@@ -1428,7 +1541,7 @@ const FieldGroupSection = _ref2 => {
|
|
|
1428
1541
|
fields: group.fields,
|
|
1429
1542
|
formik: formik,
|
|
1430
1543
|
parentKeys: [parentKey],
|
|
1431
|
-
isAnySiblingChecked:
|
|
1544
|
+
isAnySiblingChecked: isAnyFieldInGroupChecked,
|
|
1432
1545
|
groupName: group.groupName,
|
|
1433
1546
|
isForceExpanded: isForceExpanded
|
|
1434
1547
|
})
|
|
@@ -1521,23 +1634,24 @@ const ExportFieldsSelectionStep = () => {
|
|
|
1521
1634
|
React__default["default"].useEffect(() => {
|
|
1522
1635
|
var _context2;
|
|
1523
1636
|
formik.validateForm();
|
|
1524
|
-
|
|
1525
|
-
|
|
1637
|
+
updateFieldDependenciesStatus(formik);
|
|
1638
|
+
const checkedFields = {};
|
|
1639
|
+
function getCheckedFields(field, groupName) {
|
|
1526
1640
|
const fieldName = field.name ? `${groupName}.${field.name}` : groupName;
|
|
1527
1641
|
if (field.fields) {
|
|
1528
1642
|
var _context;
|
|
1529
|
-
return _forEachInstanceProperty__default["default"](_context = field.fields).call(_context, f =>
|
|
1643
|
+
return _forEachInstanceProperty__default["default"](_context = field.fields).call(_context, f => getCheckedFields(f, fieldName));
|
|
1530
1644
|
}
|
|
1531
|
-
|
|
1645
|
+
checkedFields[fieldName] = field.isChecked;
|
|
1532
1646
|
}
|
|
1533
1647
|
_forEachInstanceProperty__default["default"](_context2 = _valuesInstanceProperty__default["default"](formik).groups).call(_context2, group => {
|
|
1534
1648
|
var _context3;
|
|
1535
1649
|
_forEachInstanceProperty__default["default"](_context3 = group.fields).call(_context3, field => {
|
|
1536
|
-
|
|
1650
|
+
getCheckedFields(field, group.groupName);
|
|
1537
1651
|
});
|
|
1538
1652
|
});
|
|
1539
1653
|
setCachedSelectedGroups({
|
|
1540
|
-
[resourceType]:
|
|
1654
|
+
[resourceType]: checkedFields
|
|
1541
1655
|
});
|
|
1542
1656
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1543
1657
|
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
@@ -1792,3 +1906,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1792
1906
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1793
1907
|
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
1794
1908
|
exports["default"] = ExportResourcesModal;
|
|
1909
|
+
exports.useConvertCustomTypeDefinitionsForExport = useConvertCustomTypeDefinitionsForExport;
|