@truedat/df 7.5.9 → 7.5.11
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/package.json +43 -67
- package/src/components/DynamicFieldValue.js +0 -1
- package/src/components/DynamicForm.js +5 -4
- package/src/components/DynamicFormViewer.js +0 -1
- package/src/components/DynamicFormWithTranslations.js +3 -3
- package/src/components/EditableDynamicFieldValue.js +1 -2
- package/src/components/FieldGroupDetail.js +0 -1
- package/src/components/FieldGroupSegment.js +17 -29
- package/src/components/FieldGroupWithTranslations.js +19 -38
- package/src/components/FieldViewerValue.js +4 -7
- package/src/components/OriginLabel.js +0 -1
- package/src/components/SelectDynamicFormWithTranslations.js +4 -6
- package/src/components/SelectableDynamicForm.js +5 -11
- package/src/components/__tests__/DynamicFieldValue.spec.js +0 -1
- package/src/components/__tests__/DynamicForm.spec.js +25 -23
- package/src/components/__tests__/EditableDynamicFieldValue.spec.js +0 -1
- package/src/components/__tests__/FieldGroupDetail.spec.js +0 -1
- package/src/components/__tests__/FieldViewerValue.spec.js +1 -6
- package/src/components/__tests__/SelectableDynamicForm.spec.js +102 -46
- package/src/components/__tests__/__snapshots__/DynamicFieldValue.spec.js.snap +2 -2
- package/src/components/__tests__/__snapshots__/DynamicForm.spec.js.snap +94 -81
- package/src/components/__tests__/__snapshots__/FieldGroupDetail.spec.js.snap +2 -2
- package/src/components/__tests__/__snapshots__/FieldViewerValue.spec.js.snap +1 -7
- package/src/components/__tests__/__snapshots__/SelectableDynamicForm.spec.js.snap +39 -39
- package/src/components/hierarchies/Hierarchies.js +2 -4
- package/src/components/hierarchies/HierarchiesView.js +1 -2
- package/src/components/hierarchies/HierarchyCrumbs.js +1 -2
- package/src/components/hierarchies/HierarchyRoutes.js +44 -39
- package/src/components/hierarchies/HierarchyView.js +4 -7
- package/src/components/hierarchies/__tests__/Hierarchies.spec.js +2 -3
- package/src/components/hierarchies/__tests__/HierarchiesView.spec.js +3 -7
- package/src/components/hierarchies/__tests__/HierarchyCrumbs.spec.js +0 -1
- package/src/components/hierarchies/__tests__/HierarchyRoutes.spec.js +79 -0
- package/src/components/hierarchies/__tests__/HierarchyView.spec.js +2 -10
- package/src/components/hierarchies/__tests__/__snapshots__/Hierarchies.spec.js.snap +1 -0
- package/src/components/hierarchies/__tests__/__snapshots__/HierarchiesView.spec.js.snap +7 -5
- package/src/components/hierarchies/__tests__/__snapshots__/HierarchyCrumbs.spec.js.snap +4 -2
- package/src/components/hierarchies/__tests__/__snapshots__/HierarchyRoutes.spec.js.snap +60 -0
- package/src/components/hierarchies/__tests__/__snapshots__/HierarchyView.spec.js.snap +8 -6
- package/src/components/widgets/CheckboxField.js +0 -1
- package/src/components/widgets/ColorPickerField.js +2 -3
- package/src/components/widgets/DateField.js +0 -1
- package/src/components/widgets/DateTimeField.js +0 -1
- package/src/components/widgets/DomainDropdown.js +1 -1
- package/src/components/widgets/DomainPreview.js +1 -2
- package/src/components/widgets/DropdownDataLoader.js +3 -3
- package/src/components/widgets/DropdownField.js +5 -4
- package/src/components/widgets/DynamicField.js +0 -5
- package/src/components/widgets/EnrichedTextField.js +0 -1
- package/src/components/widgets/HierarchyDropdown.js +1 -1
- package/src/components/widgets/HierarchyPreview.js +0 -1
- package/src/components/widgets/IdentifierField.js +0 -1
- package/src/components/widgets/ImageField.js +1 -1
- package/src/components/widgets/ImagePreview.js +0 -1
- package/src/components/widgets/NumberField.js +6 -7
- package/src/components/widgets/PairListField.js +5 -6
- package/src/components/widgets/PasswordField.js +1 -2
- package/src/components/widgets/RadioField.js +0 -1
- package/src/components/widgets/StandardDropdown.js +0 -1
- package/src/components/widgets/StringField.js +0 -1
- package/src/components/widgets/SystemPreview.js +2 -3
- package/src/components/widgets/TableField.js +5 -5
- package/src/components/widgets/TextField.js +1 -2
- package/src/components/widgets/__tests__/CheckboxField.spec.js +33 -23
- package/src/components/widgets/__tests__/ColorPickerField.spec.js +5 -12
- package/src/components/widgets/__tests__/DateField.spec.js +5 -5
- package/src/components/widgets/__tests__/DateTimeField.spec.js +5 -5
- package/src/components/widgets/__tests__/DomainPreview.spec.js +12 -14
- package/src/components/widgets/__tests__/DropdownDataLoader.spec.js +5 -5
- package/src/components/widgets/__tests__/DropdownField.spec.js +18 -29
- package/src/components/widgets/__tests__/DynamicField.spec.js +0 -1
- package/src/components/widgets/__tests__/HierarchyDropdown.spec.js +4 -5
- package/src/components/widgets/__tests__/HierarchyPreview.spec.js +0 -1
- package/src/components/widgets/__tests__/ImageField.spec.js +5 -10
- package/src/components/widgets/__tests__/NumberField.spec.js +23 -5
- package/src/components/widgets/__tests__/PairListField.spec.js +69 -59
- package/src/components/widgets/__tests__/PasswordField.spec.js +3 -4
- package/src/components/widgets/__tests__/RadioField.spec.js +5 -5
- package/src/components/widgets/__tests__/StandardDropdown.spec.js +45 -46
- package/src/components/widgets/__tests__/StringField.spec.js +10 -13
- package/src/components/widgets/__tests__/SystemPreview.spec.js +13 -15
- package/src/components/widgets/__tests__/TableField.spec.js +32 -32
- package/src/components/widgets/__tests__/TextField.spec.js +5 -5
- package/src/components/widgets/__tests__/__snapshots__/CheckboxField.spec.js.snap +58 -29
- package/src/components/widgets/__tests__/__snapshots__/ColorPickerField.spec.js.snap +221 -36
- package/src/components/widgets/__tests__/__snapshots__/DateField.spec.js.snap +21 -16
- package/src/components/widgets/__tests__/__snapshots__/DateTimeField.spec.js.snap +21 -20
- package/src/components/widgets/__tests__/__snapshots__/DomainPreview.spec.js.snap +26 -21
- package/src/components/widgets/__tests__/__snapshots__/DropdownDataLoader.spec.js.snap +1 -1
- package/src/components/widgets/__tests__/__snapshots__/DropdownField.spec.js.snap +93 -43
- package/src/components/widgets/__tests__/__snapshots__/DynamicField.spec.js.snap +2 -14
- package/src/components/widgets/__tests__/__snapshots__/ImageField.spec.js.snap +16 -28
- package/src/components/widgets/__tests__/__snapshots__/NumberField.spec.js.snap +11 -9
- package/src/components/widgets/__tests__/__snapshots__/PairListField.spec.js.snap +53 -39
- package/src/components/widgets/__tests__/__snapshots__/PasswordField.spec.js.snap +15 -8
- package/src/components/widgets/__tests__/__snapshots__/RadioField.spec.js.snap +41 -22
- package/src/components/widgets/__tests__/__snapshots__/StandardDropdown.spec.js.snap +78 -31
- package/src/components/widgets/__tests__/__snapshots__/StringField.spec.js.snap +78 -38
- package/src/components/widgets/__tests__/__snapshots__/SystemPreview.spec.js.snap +24 -21
- package/src/components/widgets/__tests__/__snapshots__/TableField.spec.js.snap +138 -174
- package/src/components/widgets/__tests__/__snapshots__/TextField.spec.js.snap +12 -7
- package/src/reducers/__tests__/dfMessage.spec.js +14 -18
- package/src/reducers/dfMessage.js +8 -7
- package/src/selectors/index.js +0 -1
- package/src/templates/components/NewTemplate.js +0 -1
- package/src/templates/components/Template.js +10 -3
- package/src/templates/components/TemplateCard.js +3 -4
- package/src/templates/components/TemplateCrumbs.js +2 -3
- package/src/templates/components/TemplateFilters.js +0 -1
- package/src/templates/components/TemplateLoader.js +25 -101
- package/src/templates/components/TemplateRoutes.js +29 -45
- package/src/templates/components/Templates.js +1 -5
- package/src/templates/components/TemplatesContext.js +3 -7
- package/src/templates/components/TemplatesTable.js +1 -2
- package/src/templates/components/__tests__/NewTemplate.spec.js +5 -10
- package/src/templates/components/__tests__/Template.spec.js +0 -1
- package/src/templates/components/__tests__/TemplateLoader.spec.js +71 -109
- package/src/templates/components/__tests__/TemplateRoutes.spec.js +63 -0
- package/src/templates/components/__tests__/TemplatesTable.spec.js +15 -9
- package/src/templates/components/__tests__/__snapshots__/NewTemplate.spec.js.snap +335 -22
- package/src/templates/components/__tests__/__snapshots__/Template.spec.js.snap +49 -48
- package/src/templates/components/__tests__/__snapshots__/TemplateLoader.spec.js.snap +7 -1
- package/src/templates/components/__tests__/__snapshots__/TemplateRoutes.spec.js.snap +38 -0
- package/src/templates/components/__tests__/__snapshots__/TemplatesTable.spec.js.snap +94 -1
- package/src/templates/components/index.js +1 -2
- package/src/templates/components/templateForm/ActiveGroupForm.js +1 -4
- package/src/templates/components/templateForm/ConditionalFieldForm.js +0 -1
- package/src/templates/components/templateForm/DefaultValue.js +0 -1
- package/src/templates/components/templateForm/DependentDomain.js +0 -1
- package/src/templates/components/templateForm/DependentFormField.js +0 -1
- package/src/templates/components/templateForm/FieldForm.js +5 -5
- package/src/templates/components/templateForm/GroupsList.js +0 -1
- package/src/templates/components/templateForm/HierarchiesList.js +1 -2
- package/src/templates/components/templateForm/MandatoryConditional.js +0 -1
- package/src/templates/components/templateForm/SwitchListForm.js +2 -2
- package/src/templates/components/templateForm/SwitchSegment.js +0 -1
- package/src/templates/components/templateForm/TemplateForm.js +1 -1
- package/src/templates/components/templateForm/TemplateFormActions.js +3 -4
- package/src/templates/components/templateForm/ValuesField.js +1 -3
- package/src/templates/components/templateForm/ValuesListForm.js +3 -3
- package/src/templates/components/templateForm/ValuesSelector.js +0 -1
- package/src/templates/components/templateForm/__tests__/ActiveGroupForm.spec.js +8 -13
- package/src/templates/components/templateForm/__tests__/DefaultValue.spec.js +198 -113
- package/src/templates/components/templateForm/__tests__/DependentDomain.spec.js +0 -1
- package/src/templates/components/templateForm/__tests__/DependentFormField.spec.js +0 -1
- package/src/templates/components/templateForm/__tests__/FieldForm.spec.js +106 -72
- package/src/templates/components/templateForm/__tests__/GroupsList.spec.js +7 -12
- package/src/templates/components/templateForm/__tests__/MandatoryConditional.spec.js +0 -1
- package/src/templates/components/templateForm/__tests__/SwitchListForm.spec.js +71 -50
- package/src/templates/components/templateForm/__tests__/SwitchSegment.spec.js +37 -62
- package/src/templates/components/templateForm/__tests__/TemplateForm.spec.js +0 -1
- package/src/templates/components/templateForm/__tests__/TemplateFormActions.spec.js +19 -15
- package/src/templates/components/templateForm/__tests__/ValuesField.spec.js +84 -62
- package/src/templates/components/templateForm/__tests__/ValuesListForm.spec.js +108 -144
- package/src/templates/components/templateForm/__tests__/ValuesSelector.spec.js +36 -36
- package/src/templates/components/templateForm/__tests__/__snapshots__/ActiveGroupForm.spec.js.snap +654 -86
- package/src/templates/components/templateForm/__tests__/__snapshots__/DefaultValue.spec.js.snap +45 -23
- package/src/templates/components/templateForm/__tests__/__snapshots__/FieldForm.spec.js.snap +1700 -1025
- package/src/templates/components/templateForm/__tests__/__snapshots__/GroupsList.spec.js.snap +44 -39
- package/src/templates/components/templateForm/__tests__/__snapshots__/SwitchListForm.spec.js.snap +225 -60
- package/src/templates/components/templateForm/__tests__/__snapshots__/SwitchSegment.spec.js.snap +1 -1
- package/src/templates/components/templateForm/__tests__/__snapshots__/TemplateForm.spec.js.snap +89 -92
- package/src/templates/components/templateForm/__tests__/__snapshots__/TemplateFormActions.spec.js.snap +66 -100
- package/src/templates/components/templateForm/__tests__/__snapshots__/ValuesField.spec.js.snap +542 -231
- package/src/templates/components/templateForm/__tests__/__snapshots__/ValuesListForm.spec.js.snap +264 -268
- package/src/templates/components/templateForm/__tests__/__snapshots__/ValuesSelector.spec.js.snap +146 -11
- package/src/templates/reducers/__tests__/allTemplates.spec.js +1 -1
- package/src/templates/reducers/__tests__/template.spec.js +3 -2
- package/src/templates/reducers/__tests__/templateLoading.spec.js +2 -2
- package/src/templates/reducers/__tests__/templates.spec.js +1 -1
- package/src/templates/reducers/__tests__/templatesLoading.spec.js +1 -1
- package/src/templates/reducers/allTemplates.js +1 -2
- package/src/templates/reducers/template.js +2 -1
- package/src/templates/reducers/templateRedirect.js +1 -1
- package/src/templates/reducers/templates.js +1 -1
- package/src/templates/reducers/templatesLoading.js +1 -1
- package/src/templates/routines.js +0 -2
- package/src/templates/sagas/__tests__/deleteTemplate.spec.js +2 -2
- package/src/templates/sagas/__tests__/fetchTemplates.spec.js +3 -6
- package/src/templates/sagas/__tests__/updateTemplate.spec.js +4 -4
- package/src/templates/sagas/deleteTemplate.js +1 -1
- package/src/templates/sagas/fetchTemplate.js +1 -1
- package/src/templates/sagas/fetchTemplates.js +1 -1
- package/src/templates/sagas/updateTemplate.js +1 -1
- package/src/templates/utils/filterSwitches.js +2 -2
- package/src/templates/utils/filterValues.js +2 -2
- package/src/api/hierarchies.js +0 -4
- package/src/components/FieldGroupCopy.js +0 -108
- package/src/components/FieldGroupSubSegment/FieldGroupSubSegment.js +0 -181
- package/src/components/FieldGroupSubSegment/__tests__/FieldGroupSubSegment.spec.js +0 -221
- package/src/components/FieldGroupSubSegment/__tests__/__snapshots__/FieldGroupSubSegment.spec.js.snap +0 -230
- package/src/components/FieldGroupSubSegment/constants.js +0 -68
- package/src/components/FieldGroupSubSegment/copyValidations.js +0 -75
- package/src/components/FieldGroupSubSegment/handleCopyModule.js +0 -186
- package/src/components/__tests__/FieldGroupCopy.spec.js +0 -14
- package/src/components/__tests__/__snapshots__/FieldGroupCopy.spec.js.snap +0 -307
- package/src/components/widgets/CopyField/CopyField.js +0 -270
- package/src/components/widgets/CopyField/CopyFieldCell.js +0 -138
- package/src/components/widgets/CopyField/CopyFieldColumn.js +0 -53
- package/src/components/widgets/CopyField/CopyFieldSelectableCell.js +0 -71
- package/src/components/widgets/CopyField/CustomStyles.js +0 -91
- package/src/components/widgets/CopyField/__tests__/CopyField.spec.js +0 -82
- package/src/components/widgets/CopyField/__tests__/CopyFieldCell.spec.js +0 -67
- package/src/components/widgets/CopyField/__tests__/CopyFieldColumn.spec.js +0 -33
- package/src/components/widgets/CopyField/__tests__/CopyFieldSelectableCell.spec.js +0 -49
- package/src/components/widgets/CopyField/__tests__/__snapshots__/CopyField.spec.js.snap +0 -279
- package/src/components/widgets/CopyField/__tests__/__snapshots__/CopyFieldCell.spec.js.snap +0 -67
- package/src/components/widgets/CopyField/__tests__/__snapshots__/CopyFieldColumn.spec.js.snap +0 -42
- package/src/components/widgets/CopyField/__tests__/__snapshots__/CopyFieldSelectableCell.spec.js.snap +0 -60
- package/src/hooks/useHierarchies.js +0 -112
- package/src/selectors/subscopedTemplates.js +0 -16
- package/src/templates/components/TemplatesLoader.js +0 -24
- package/src/templates/components/__tests__/TemplatesLoader.spec.js +0 -29
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { getCopyEntriesOnFormat } from "./handleCopyModule";
|
|
2
|
-
import {
|
|
3
|
-
REQUIRED_COPY_ENTRIES,
|
|
4
|
-
WITHOUT_SIZE,
|
|
5
|
-
VALID_FIELD_TYPES
|
|
6
|
-
} from "./constants";
|
|
7
|
-
|
|
8
|
-
const validateCopyEntries = (fieldContent, formatOptions) => {
|
|
9
|
-
const { delimiter, quoted, escape_char, fileFormat } = fieldContent;
|
|
10
|
-
if (!Object.keys(fieldContent).length) {
|
|
11
|
-
return getCopyEntriesOnFormat(fileFormat, fieldContent);
|
|
12
|
-
}
|
|
13
|
-
if (fileFormat === undefined) {
|
|
14
|
-
throw new Error("template.form.subsegment.error.nofileformat");
|
|
15
|
-
}
|
|
16
|
-
const fileFormatConfiguration = formatOptions.find(
|
|
17
|
-
option => option.text === fileFormat
|
|
18
|
-
);
|
|
19
|
-
if (!fileFormatConfiguration) {
|
|
20
|
-
throw new Error("template.form.subsegment.error.wrongformat");
|
|
21
|
-
}
|
|
22
|
-
if (
|
|
23
|
-
REQUIRED_COPY_ENTRIES[fileFormatConfiguration.value].some(
|
|
24
|
-
key => !Object.keys(fieldContent).includes(key)
|
|
25
|
-
)
|
|
26
|
-
) {
|
|
27
|
-
throw new Error("template.form.subsegment.error.requiredparam");
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
(delimiter && delimiter.length > 1) ||
|
|
31
|
-
(quoted && quoted.length > 1) ||
|
|
32
|
-
(escape_char && escape_char.length > 1)
|
|
33
|
-
) {
|
|
34
|
-
throw new Error("template.form.subsegment.error.onechar");
|
|
35
|
-
}
|
|
36
|
-
return { ...fieldContent };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const validateCopyFields = (fieldContent, formatOptions) => {
|
|
40
|
-
const { fields, fileFormat } = fieldContent;
|
|
41
|
-
const wrongCopyFieldNameChars = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
|
|
42
|
-
|
|
43
|
-
const fileFormatConfiguration = formatOptions.find(
|
|
44
|
-
option => option.text === fileFormat
|
|
45
|
-
);
|
|
46
|
-
if (!fileFormatConfiguration || !fields) return;
|
|
47
|
-
if (
|
|
48
|
-
fields.some(
|
|
49
|
-
field =>
|
|
50
|
-
(Object.keys(field).includes("size") &&
|
|
51
|
-
WITHOUT_SIZE.includes(fileFormatConfiguration.value)) ||
|
|
52
|
-
(!Object.keys(field).includes("size") &&
|
|
53
|
-
!WITHOUT_SIZE.includes(fileFormatConfiguration.value)) ||
|
|
54
|
-
!Object.keys(field).includes("name") ||
|
|
55
|
-
!Object.keys(field).includes("type")
|
|
56
|
-
)
|
|
57
|
-
) {
|
|
58
|
-
throw new Error("template.form.subsegment.error.wrongparams");
|
|
59
|
-
}
|
|
60
|
-
if (
|
|
61
|
-
fields.some(
|
|
62
|
-
({ name }) =>
|
|
63
|
-
wrongCopyFieldNameChars.test(name) ||
|
|
64
|
-
name > 250 ||
|
|
65
|
-
!isNaN(name.substring(0, 1))
|
|
66
|
-
)
|
|
67
|
-
) {
|
|
68
|
-
throw new Error("template.form.subsegment.error.wrongname");
|
|
69
|
-
}
|
|
70
|
-
if (fields.some(({ type }) => type && !VALID_FIELD_TYPES.includes(type))) {
|
|
71
|
-
throw new Error("template.form.subsegment.error.wrongfield");
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { validateCopyEntries, validateCopyFields };
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
3
|
-
ENTRIES_FORMAT,
|
|
4
|
-
REQUIRED_COPY_ENTRIES,
|
|
5
|
-
VALID_COMPRESSION,
|
|
6
|
-
} from "./constants";
|
|
7
|
-
|
|
8
|
-
const getCopyForm = (field, fileFormat, formatOptions) => {
|
|
9
|
-
const copyEntries = getCopyEntriesOnFormat(
|
|
10
|
-
fileFormat,
|
|
11
|
-
JSON.parse(field || "{}")
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const fileFormatConfiguration = fileFormat
|
|
15
|
-
? formatOptions.find((option) => option.text === fileFormat).value
|
|
16
|
-
: "";
|
|
17
|
-
|
|
18
|
-
return Object.entries(copyEntries)
|
|
19
|
-
.filter(([key, value]) => {
|
|
20
|
-
if (fileFormatConfiguration) {
|
|
21
|
-
return ENTRIES_FORMAT[fileFormatConfiguration].includes(key);
|
|
22
|
-
}
|
|
23
|
-
return { [key]: value };
|
|
24
|
-
})
|
|
25
|
-
.map(([key, value]) => {
|
|
26
|
-
const widget =
|
|
27
|
-
key === "compression" || key === "fileFormat"
|
|
28
|
-
? "dropdown"
|
|
29
|
-
: typeof value === "string"
|
|
30
|
-
? "string"
|
|
31
|
-
: typeof value === "boolean"
|
|
32
|
-
? "radio"
|
|
33
|
-
: "copy";
|
|
34
|
-
|
|
35
|
-
const cardinality =
|
|
36
|
-
fileFormatConfiguration &&
|
|
37
|
-
REQUIRED_COPY_ENTRIES[fileFormatConfiguration].includes(key)
|
|
38
|
-
? "1"
|
|
39
|
-
: "0";
|
|
40
|
-
const dynamicFormObj = {
|
|
41
|
-
cardinality,
|
|
42
|
-
label: key,
|
|
43
|
-
value,
|
|
44
|
-
type: "string",
|
|
45
|
-
name: key,
|
|
46
|
-
widget,
|
|
47
|
-
description: "",
|
|
48
|
-
};
|
|
49
|
-
const dropdownValues =
|
|
50
|
-
key === "compression"
|
|
51
|
-
? { fixed: VALID_COMPRESSION }
|
|
52
|
-
: key === "header"
|
|
53
|
-
? { fixed: ["true", "false"] }
|
|
54
|
-
: key === "fileFormat"
|
|
55
|
-
? { fixed: formatOptions.map((option) => option.text) }
|
|
56
|
-
: "";
|
|
57
|
-
|
|
58
|
-
const parsedValues = dropdownValues
|
|
59
|
-
? dropdownValues.fixed.map((item) => {
|
|
60
|
-
return { value: item, text: item };
|
|
61
|
-
})
|
|
62
|
-
: [];
|
|
63
|
-
const values =
|
|
64
|
-
typeof value === "boolean" ? [{ true: true }, { false: false }] : [];
|
|
65
|
-
const currentValue = setFormFieldValue(key, value, fileFormat);
|
|
66
|
-
return { ...dynamicFormObj, values, value: currentValue, parsedValues };
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const setFormFieldValue = (key, value, fileFormat) => {
|
|
71
|
-
if (typeof value === "boolean") {
|
|
72
|
-
return value ? "true" : "false";
|
|
73
|
-
}
|
|
74
|
-
switch (key) {
|
|
75
|
-
case "compression":
|
|
76
|
-
return !VALID_COMPRESSION.includes(value) ? "none" : value;
|
|
77
|
-
case "fields":
|
|
78
|
-
return value.map((field) => _handleCopyFields(field, fileFormat));
|
|
79
|
-
default:
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const getCopyJson = (field, fileFormat, hasChangedFormat = false) => {
|
|
85
|
-
try {
|
|
86
|
-
const copyEntries = hasChangedFormat
|
|
87
|
-
? getCopyEntriesOnFormat(fileFormat, JSON.parse(field || "{}"))
|
|
88
|
-
: JSON.parse(field || "{}");
|
|
89
|
-
return _.flow(
|
|
90
|
-
_.toPairs,
|
|
91
|
-
_.map(([key, value]) => [
|
|
92
|
-
key,
|
|
93
|
-
key === "fields"
|
|
94
|
-
? value.map((field) => _handleCopyFields(field, fileFormat))
|
|
95
|
-
: value,
|
|
96
|
-
]),
|
|
97
|
-
_.fromPairs
|
|
98
|
-
)(copyEntries);
|
|
99
|
-
} catch (e) {
|
|
100
|
-
return field;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const getCopyEntriesOnFormat = (format, copyEntries) => {
|
|
105
|
-
const emptyCopy = {
|
|
106
|
-
fileFormat: copyEntries.fileFormat || "",
|
|
107
|
-
header: true,
|
|
108
|
-
compression: "none",
|
|
109
|
-
fields: [],
|
|
110
|
-
...copyEntries,
|
|
111
|
-
};
|
|
112
|
-
if (format === "CSV") {
|
|
113
|
-
const {
|
|
114
|
-
header,
|
|
115
|
-
fileFormat,
|
|
116
|
-
compression,
|
|
117
|
-
fields,
|
|
118
|
-
delimiter,
|
|
119
|
-
escape_char,
|
|
120
|
-
quoted,
|
|
121
|
-
} = emptyCopy;
|
|
122
|
-
return {
|
|
123
|
-
fileFormat,
|
|
124
|
-
header,
|
|
125
|
-
compression,
|
|
126
|
-
escape_char: escape_char === undefined ? "\\" : escape_char,
|
|
127
|
-
quoted: quoted === undefined ? '"' : quoted,
|
|
128
|
-
delimiter: delimiter === undefined ? "," : delimiter,
|
|
129
|
-
fields,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
if (format === "JSON") {
|
|
133
|
-
delete emptyCopy.header;
|
|
134
|
-
}
|
|
135
|
-
delete emptyCopy.delimiter;
|
|
136
|
-
delete emptyCopy.escape_char;
|
|
137
|
-
delete emptyCopy.quoted;
|
|
138
|
-
|
|
139
|
-
return emptyCopy;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const _handleCopyFields = (field, fileFormat) => {
|
|
143
|
-
const { name, type, size, scale, precision, format: fieldFormat } = field;
|
|
144
|
-
const copyField = {
|
|
145
|
-
name,
|
|
146
|
-
type: type || "string",
|
|
147
|
-
size: size || 40,
|
|
148
|
-
...field,
|
|
149
|
-
};
|
|
150
|
-
switch (type) {
|
|
151
|
-
case "integer":
|
|
152
|
-
Object.assign(copyField, { size: size || 4 });
|
|
153
|
-
break;
|
|
154
|
-
case "decimal":
|
|
155
|
-
Object.assign(copyField, {
|
|
156
|
-
scale: scale || 2,
|
|
157
|
-
precision: precision || 10,
|
|
158
|
-
size: size || 11,
|
|
159
|
-
});
|
|
160
|
-
break;
|
|
161
|
-
case "date":
|
|
162
|
-
Object.assign(copyField, {
|
|
163
|
-
size: size || 10,
|
|
164
|
-
format: fieldFormat || "%d-%m-%Y",
|
|
165
|
-
});
|
|
166
|
-
break;
|
|
167
|
-
case "time":
|
|
168
|
-
Object.assign(copyField, {
|
|
169
|
-
size: size || 10,
|
|
170
|
-
format: fieldFormat || "%H:%M:%S",
|
|
171
|
-
});
|
|
172
|
-
break;
|
|
173
|
-
case "datetime":
|
|
174
|
-
Object.assign(copyField, {
|
|
175
|
-
size: size || 10,
|
|
176
|
-
format: fieldFormat || "%d-%m-%Y %H:%M:%S",
|
|
177
|
-
});
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
if (fileFormat === "JSON" || fileFormat === "CSV") {
|
|
181
|
-
delete copyField.size;
|
|
182
|
-
}
|
|
183
|
-
return copyField;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export { getCopyForm, getCopyJson, getCopyEntriesOnFormat };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import { FieldGroupCopy } from "../FieldGroupCopy";
|
|
4
|
-
|
|
5
|
-
describe("<FieldGroupCopy />", () => {
|
|
6
|
-
const value =
|
|
7
|
-
'{"fileFormat":"DAT","header":true,"compression":"brotli","fields":[{"name":"New3","type":"decimal","size":11,"scale":2,"precision":10},{"name":"New5","type":"datetime","size":10,"format":"%d-%m-%Y %H:%M:%S"},{"name":"New1","type":"string","size":40},{"name":"New0","type":"datetime","size":10,"format":"%d-%m-%Y %H:%M:%S"},{"name":"New4","type":"string","size":40}]}';
|
|
8
|
-
const props = { value };
|
|
9
|
-
|
|
10
|
-
it("matches the latest snapshot", () => {
|
|
11
|
-
const { container } = render(<FieldGroupCopy {...props} />);
|
|
12
|
-
expect(container).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<FieldGroupCopy /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="ui large segment"
|
|
7
|
-
style="margin-top: 15px;"
|
|
8
|
-
>
|
|
9
|
-
<div
|
|
10
|
-
class="ui large horizontal list"
|
|
11
|
-
role="list"
|
|
12
|
-
style="padding: 0px;"
|
|
13
|
-
>
|
|
14
|
-
<div
|
|
15
|
-
class="item"
|
|
16
|
-
role="listitem"
|
|
17
|
-
>
|
|
18
|
-
<span
|
|
19
|
-
style="margin-right: 5px; font-weight: bold;"
|
|
20
|
-
>
|
|
21
|
-
FileFormat
|
|
22
|
-
:
|
|
23
|
-
</span>
|
|
24
|
-
DAT
|
|
25
|
-
</div>
|
|
26
|
-
<div
|
|
27
|
-
class="item"
|
|
28
|
-
role="listitem"
|
|
29
|
-
>
|
|
30
|
-
<span
|
|
31
|
-
style="margin-right: 5px; font-weight: bold;"
|
|
32
|
-
>
|
|
33
|
-
Header
|
|
34
|
-
:
|
|
35
|
-
</span>
|
|
36
|
-
true
|
|
37
|
-
</div>
|
|
38
|
-
<div
|
|
39
|
-
class="item"
|
|
40
|
-
role="listitem"
|
|
41
|
-
>
|
|
42
|
-
<span
|
|
43
|
-
style="margin-right: 5px; font-weight: bold;"
|
|
44
|
-
>
|
|
45
|
-
Compression
|
|
46
|
-
:
|
|
47
|
-
</span>
|
|
48
|
-
brotli
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
<div
|
|
52
|
-
style="font-weight: bold; margin: 10px 0px;"
|
|
53
|
-
>
|
|
54
|
-
Fields:
|
|
55
|
-
</div>
|
|
56
|
-
<div
|
|
57
|
-
style="overflow-x: auto;"
|
|
58
|
-
>
|
|
59
|
-
<table
|
|
60
|
-
class="ui celled definition table"
|
|
61
|
-
style="overflow-x: scroll; min-width: 200px; max-width: 600px;"
|
|
62
|
-
>
|
|
63
|
-
<thead
|
|
64
|
-
class=""
|
|
65
|
-
>
|
|
66
|
-
<tr
|
|
67
|
-
class=""
|
|
68
|
-
>
|
|
69
|
-
<th
|
|
70
|
-
class=""
|
|
71
|
-
/>
|
|
72
|
-
<th
|
|
73
|
-
class=""
|
|
74
|
-
style="width: 140px;"
|
|
75
|
-
>
|
|
76
|
-
<div
|
|
77
|
-
style="width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
|
78
|
-
>
|
|
79
|
-
New3
|
|
80
|
-
</div>
|
|
81
|
-
</th>
|
|
82
|
-
<th
|
|
83
|
-
class=""
|
|
84
|
-
style="width: 140px;"
|
|
85
|
-
>
|
|
86
|
-
<div
|
|
87
|
-
style="width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
|
88
|
-
>
|
|
89
|
-
New5
|
|
90
|
-
</div>
|
|
91
|
-
</th>
|
|
92
|
-
<th
|
|
93
|
-
class=""
|
|
94
|
-
style="width: 140px;"
|
|
95
|
-
>
|
|
96
|
-
<div
|
|
97
|
-
style="width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
|
98
|
-
>
|
|
99
|
-
New1
|
|
100
|
-
</div>
|
|
101
|
-
</th>
|
|
102
|
-
<th
|
|
103
|
-
class=""
|
|
104
|
-
style="width: 140px;"
|
|
105
|
-
>
|
|
106
|
-
<div
|
|
107
|
-
style="width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
|
108
|
-
>
|
|
109
|
-
New0
|
|
110
|
-
</div>
|
|
111
|
-
</th>
|
|
112
|
-
<th
|
|
113
|
-
class=""
|
|
114
|
-
style="width: 140px;"
|
|
115
|
-
>
|
|
116
|
-
<div
|
|
117
|
-
style="width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
|
118
|
-
>
|
|
119
|
-
New4
|
|
120
|
-
</div>
|
|
121
|
-
</th>
|
|
122
|
-
</tr>
|
|
123
|
-
</thead>
|
|
124
|
-
<tbody
|
|
125
|
-
class=""
|
|
126
|
-
>
|
|
127
|
-
<tr
|
|
128
|
-
class=""
|
|
129
|
-
>
|
|
130
|
-
<td
|
|
131
|
-
class=""
|
|
132
|
-
style="width: 150px;"
|
|
133
|
-
>
|
|
134
|
-
Type
|
|
135
|
-
</td>
|
|
136
|
-
<td
|
|
137
|
-
class=""
|
|
138
|
-
>
|
|
139
|
-
decimal
|
|
140
|
-
</td>
|
|
141
|
-
<td
|
|
142
|
-
class=""
|
|
143
|
-
>
|
|
144
|
-
datetime
|
|
145
|
-
</td>
|
|
146
|
-
<td
|
|
147
|
-
class=""
|
|
148
|
-
>
|
|
149
|
-
string
|
|
150
|
-
</td>
|
|
151
|
-
<td
|
|
152
|
-
class=""
|
|
153
|
-
>
|
|
154
|
-
datetime
|
|
155
|
-
</td>
|
|
156
|
-
<td
|
|
157
|
-
class=""
|
|
158
|
-
>
|
|
159
|
-
string
|
|
160
|
-
</td>
|
|
161
|
-
</tr>
|
|
162
|
-
<tr
|
|
163
|
-
class=""
|
|
164
|
-
>
|
|
165
|
-
<td
|
|
166
|
-
class=""
|
|
167
|
-
style="width: 150px;"
|
|
168
|
-
>
|
|
169
|
-
Size
|
|
170
|
-
</td>
|
|
171
|
-
<td
|
|
172
|
-
class=""
|
|
173
|
-
>
|
|
174
|
-
11
|
|
175
|
-
</td>
|
|
176
|
-
<td
|
|
177
|
-
class=""
|
|
178
|
-
>
|
|
179
|
-
10
|
|
180
|
-
</td>
|
|
181
|
-
<td
|
|
182
|
-
class=""
|
|
183
|
-
>
|
|
184
|
-
40
|
|
185
|
-
</td>
|
|
186
|
-
<td
|
|
187
|
-
class=""
|
|
188
|
-
>
|
|
189
|
-
10
|
|
190
|
-
</td>
|
|
191
|
-
<td
|
|
192
|
-
class=""
|
|
193
|
-
>
|
|
194
|
-
40
|
|
195
|
-
</td>
|
|
196
|
-
</tr>
|
|
197
|
-
<tr
|
|
198
|
-
class=""
|
|
199
|
-
>
|
|
200
|
-
<td
|
|
201
|
-
class=""
|
|
202
|
-
style="width: 150px;"
|
|
203
|
-
>
|
|
204
|
-
Format
|
|
205
|
-
</td>
|
|
206
|
-
<td
|
|
207
|
-
class=""
|
|
208
|
-
>
|
|
209
|
-
-
|
|
210
|
-
</td>
|
|
211
|
-
<td
|
|
212
|
-
class=""
|
|
213
|
-
>
|
|
214
|
-
%d-%m-%Y %H:%M:%S
|
|
215
|
-
</td>
|
|
216
|
-
<td
|
|
217
|
-
class=""
|
|
218
|
-
>
|
|
219
|
-
-
|
|
220
|
-
</td>
|
|
221
|
-
<td
|
|
222
|
-
class=""
|
|
223
|
-
>
|
|
224
|
-
%d-%m-%Y %H:%M:%S
|
|
225
|
-
</td>
|
|
226
|
-
<td
|
|
227
|
-
class=""
|
|
228
|
-
>
|
|
229
|
-
-
|
|
230
|
-
</td>
|
|
231
|
-
</tr>
|
|
232
|
-
<tr
|
|
233
|
-
class=""
|
|
234
|
-
>
|
|
235
|
-
<td
|
|
236
|
-
class=""
|
|
237
|
-
style="width: 150px;"
|
|
238
|
-
>
|
|
239
|
-
Scale
|
|
240
|
-
</td>
|
|
241
|
-
<td
|
|
242
|
-
class=""
|
|
243
|
-
>
|
|
244
|
-
2
|
|
245
|
-
</td>
|
|
246
|
-
<td
|
|
247
|
-
class=""
|
|
248
|
-
>
|
|
249
|
-
-
|
|
250
|
-
</td>
|
|
251
|
-
<td
|
|
252
|
-
class=""
|
|
253
|
-
>
|
|
254
|
-
-
|
|
255
|
-
</td>
|
|
256
|
-
<td
|
|
257
|
-
class=""
|
|
258
|
-
>
|
|
259
|
-
-
|
|
260
|
-
</td>
|
|
261
|
-
<td
|
|
262
|
-
class=""
|
|
263
|
-
>
|
|
264
|
-
-
|
|
265
|
-
</td>
|
|
266
|
-
</tr>
|
|
267
|
-
<tr
|
|
268
|
-
class=""
|
|
269
|
-
>
|
|
270
|
-
<td
|
|
271
|
-
class=""
|
|
272
|
-
style="width: 150px;"
|
|
273
|
-
>
|
|
274
|
-
Precision
|
|
275
|
-
</td>
|
|
276
|
-
<td
|
|
277
|
-
class=""
|
|
278
|
-
>
|
|
279
|
-
10
|
|
280
|
-
</td>
|
|
281
|
-
<td
|
|
282
|
-
class=""
|
|
283
|
-
>
|
|
284
|
-
-
|
|
285
|
-
</td>
|
|
286
|
-
<td
|
|
287
|
-
class=""
|
|
288
|
-
>
|
|
289
|
-
-
|
|
290
|
-
</td>
|
|
291
|
-
<td
|
|
292
|
-
class=""
|
|
293
|
-
>
|
|
294
|
-
-
|
|
295
|
-
</td>
|
|
296
|
-
<td
|
|
297
|
-
class=""
|
|
298
|
-
>
|
|
299
|
-
-
|
|
300
|
-
</td>
|
|
301
|
-
</tr>
|
|
302
|
-
</tbody>
|
|
303
|
-
</table>
|
|
304
|
-
</div>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
`;
|