@dartech/arsenal-ui 1.2.4 → 1.2.5
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/.babelrc +13 -0
- package/.eslintrc.json +22 -0
- package/{index.d.ts → index.ts} +5 -5
- package/jest.config.ts +11 -0
- package/package.json +3 -12
- package/project.json +94 -0
- package/rollup.config.js +146 -0
- package/src/assets/chevron_left_gray.svg +3 -0
- package/src/consts/index.ts +13 -0
- package/src/interfaces/common.ts +18 -0
- package/src/interfaces/definition.ts +143 -0
- package/src/interfaces/{index.d.ts → index.ts} +3 -3
- package/src/interfaces/ui.ts +80 -0
- package/src/lib/Alert/Alert.tsx +108 -0
- package/src/lib/Alert/index.ts +1 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +16 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.tsx +40 -0
- package/src/lib/Breadcrumbs/{index.d.ts → index.ts} +1 -1
- package/src/lib/ContentLayout/ContentLayout.tsx +31 -0
- package/src/lib/ContentLayout/index.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +78 -0
- package/src/lib/Definition/CreateDefinition/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +71 -0
- package/src/lib/Definition/DefinitionFiller/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +54 -0
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +67 -0
- package/src/lib/Definition/DefinitionValueView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/{index.d.ts → index.ts} +3 -3
- package/src/lib/Forms/BackButton.tsx +46 -0
- package/src/lib/Forms/ControlAceEditor.tsx +125 -0
- package/src/lib/Forms/ControlAutocomplete.tsx +145 -0
- package/src/lib/Forms/ControlCheckbox.tsx +113 -0
- package/src/lib/Forms/ControlDate.tsx +75 -0
- package/src/lib/Forms/ControlDateTime.tsx +77 -0
- package/src/lib/Forms/ControlDebouncedInput.tsx +80 -0
- package/src/lib/Forms/ControlInput.tsx +111 -0
- package/src/lib/Forms/ControlNumberInput.tsx +121 -0
- package/src/lib/Forms/ControlQueryAutocomplete.tsx +197 -0
- package/src/lib/Forms/ControlRadio.tsx +136 -0
- package/src/lib/Forms/ControlSelect.tsx +164 -0
- package/src/lib/Forms/ControlSwitch.tsx +71 -0
- package/src/lib/Forms/ControlTime.tsx +93 -0
- package/src/lib/Forms/CopyButton.tsx +46 -0
- package/src/lib/Forms/{index.d.ts → index.ts} +15 -15
- package/src/lib/Forms/useAutocomplete.tsx +47 -0
- package/src/lib/InfoItem/InfoItem.tsx +40 -0
- package/src/lib/InfoItem/{index.d.ts → index.ts} +1 -1
- package/src/lib/InfoItem/styles.ts +17 -0
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +73 -0
- package/src/lib/JsonPathPicker/PropertyStep.tsx +70 -0
- package/src/lib/JsonPathPicker/{index.d.ts → index.ts} +1 -1
- package/src/lib/JsonView/JsonView.tsx +41 -0
- package/src/lib/JsonView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Loader/Loader.tsx +41 -0
- package/src/lib/Loader/{index.d.ts → index.ts} +1 -1
- package/src/lib/Modals/JsonModalView.tsx +53 -0
- package/src/lib/Modals/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/PropertyFiller/JsonEditor.tsx +58 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +129 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +85 -0
- package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +199 -0
- package/src/lib/Property/PropertyFiller/{index.d.ts → index.ts} +2 -2
- package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +72 -0
- package/src/lib/Property/PropertyFiller/useStyles.ts +12 -0
- package/src/lib/Property/PropertyValidator/NodeValidator.tsx +92 -0
- package/src/lib/Property/PropertyValidator/NodesList.tsx +26 -0
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +59 -0
- package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +42 -0
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +4 -0
- package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +36 -0
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +62 -0
- package/src/lib/Property/PropertyValidator/index.ts +1 -0
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +49 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +58 -0
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +58 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +65 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +49 -0
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +50 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +67 -0
- package/src/lib/Property/PropertyValueField/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +115 -0
- package/src/lib/Property/PropertyWidget/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +148 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +158 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +103 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/UpsertProperty/{index.d.ts → index.ts} +2 -2
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +37 -0
- package/src/lib/Property/ViewPropertiesList/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +40 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +148 -0
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +43 -0
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
- package/src/lib/Property/ViewProperty/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/{index.d.ts → index.ts} +5 -5
- package/src/lib/Sidebar/Sidebar.styled.tsx +157 -0
- package/src/lib/Sidebar/Sidebar.tsx +27 -0
- package/src/lib/Sidebar/SidebarContext.tsx +37 -0
- package/src/lib/Sidebar/SidebarDrawer.tsx +50 -0
- package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +16 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +54 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +54 -0
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +62 -0
- package/src/lib/Sidebar/SidebarLink/{index.d.ts → index.ts} +2 -2
- package/src/lib/Sidebar/index.ts +2 -0
- package/src/lib/Status/Status.tsx +16 -0
- package/src/lib/Status/{index.d.ts → index.ts} +1 -1
- package/src/lib/Status/styles.ts +21 -0
- package/src/lib/StepperView/StepperView.tsx +73 -0
- package/src/lib/StepperView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Table/DataGrid/JsonTypeCell.tsx +51 -0
- package/src/lib/Table/DataGrid/Table.tsx +117 -0
- package/src/lib/Table/DataGrid/TableAction.tsx +43 -0
- package/src/lib/Table/DataGrid/TableColumnMenu.tsx +12 -0
- package/src/lib/Table/DataGrid/TablePagination.tsx +42 -0
- package/src/lib/Table/DataGrid/index.ts +2 -0
- package/src/lib/Table/DataGrid/styles.ts +59 -0
- package/src/lib/Table/DataGrid/usePagination.ts +15 -0
- package/src/lib/Table/DataGrid/useTableQueryPagination.ts +47 -0
- package/src/lib/Table/DataGrid/useTableQuerySorting.ts +47 -0
- package/src/lib/Table/SimpleTable/SimpleTable.tsx +138 -0
- package/src/lib/Table/SimpleTable/TableActionCell.tsx +67 -0
- package/src/lib/Table/SimpleTable/index.ts +2 -0
- package/src/lib/Table/SimpleTable/useTablePagination.ts +54 -0
- package/src/lib/Table/SimpleTable/useTableSorting.ts +50 -0
- package/src/lib/Table/index.ts +2 -0
- package/src/lib/Tabs/RouteTabs.tsx +54 -0
- package/src/lib/Tabs/TabPanel.tsx +42 -0
- package/src/lib/Tabs/{index.d.ts → index.ts} +2 -2
- package/src/lib/{index.d.ts → index.ts} +16 -16
- package/src/theme/baseTheme.ts +128 -0
- package/src/theme/fonts.d.ts +2 -0
- package/src/theme/index.ts +126 -0
- package/src/theme/inputThemeOptions.ts +126 -0
- package/src/theme/stepperThemeOptions.ts +20 -0
- package/src/theme/tableThemeOptions.ts +50 -0
- package/src/theme/typographyThemeOptions.ts +32 -0
- package/src/utils/common.ts +73 -0
- package/src/utils/dem.ts +431 -0
- package/src/utils/hooks.ts +41 -0
- package/src/utils/{index.d.ts → index.ts} +5 -5
- package/src/utils/ui-utils.tsx +102 -0
- package/src/utils/validators.ts +14 -0
- package/tsconfig.json +25 -0
- package/tsconfig.lib.json +23 -0
- package/tsconfig.spec.json +20 -0
- package/index.js +0 -1
- package/src/consts/index.d.ts +0 -12
- package/src/interfaces/common.d.ts +0 -17
- package/src/interfaces/definition.d.ts +0 -107
- package/src/interfaces/ui.d.ts +0 -70
- package/src/lib/Alert/Alert.d.ts +0 -53
- package/src/lib/Alert/index.d.ts +0 -1
- package/src/lib/Breadcrumbs/Breadcrumbs.d.ts +0 -9
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +0 -2
- package/src/lib/ContentLayout/ContentLayout.d.ts +0 -9
- package/src/lib/ContentLayout/index.d.ts +0 -1
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +0 -11
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +0 -10
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +0 -8
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +0 -9
- package/src/lib/Forms/BackButton.d.ts +0 -7
- package/src/lib/Forms/ControlAceEditor.d.ts +0 -24
- package/src/lib/Forms/ControlAutocomplete.d.ts +0 -69
- package/src/lib/Forms/ControlCheckbox.d.ts +0 -51
- package/src/lib/Forms/ControlDate.d.ts +0 -18
- package/src/lib/Forms/ControlDateTime.d.ts +0 -18
- package/src/lib/Forms/ControlDebouncedInput.d.ts +0 -4
- package/src/lib/Forms/ControlInput.d.ts +0 -59
- package/src/lib/Forms/ControlNumberInput.d.ts +0 -51
- package/src/lib/Forms/ControlQueryAutocomplete.d.ts +0 -16
- package/src/lib/Forms/ControlRadio.d.ts +0 -66
- package/src/lib/Forms/ControlSelect.d.ts +0 -67
- package/src/lib/Forms/ControlSwitch.d.ts +0 -19
- package/src/lib/Forms/ControlTime.d.ts +0 -18
- package/src/lib/Forms/CopyButton.d.ts +0 -20
- package/src/lib/Forms/useAutocomplete.d.ts +0 -10
- package/src/lib/InfoItem/InfoItem.d.ts +0 -10
- package/src/lib/InfoItem/styles.d.ts +0 -12
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +0 -10
- package/src/lib/JsonPathPicker/PropertyStep.d.ts +0 -11
- package/src/lib/JsonView/JsonView.d.ts +0 -7
- package/src/lib/Loader/Loader.d.ts +0 -21
- package/src/lib/Modals/JsonModalView.d.ts +0 -10
- package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +0 -10
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +0 -12
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +0 -11
- package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +0 -12
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +0 -24
- package/src/lib/Property/PropertyFiller/useStyles.d.ts +0 -12
- package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/NodesList.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +0 -8
- package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +0 -3
- package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +0 -8
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +0 -7
- package/src/lib/Property/PropertyValidator/index.d.ts +0 -1
- package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +0 -7
- package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/DateValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +0 -10
- package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/StringValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +0 -9
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +0 -13
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +0 -13
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +0 -10
- package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +0 -7
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +0 -7
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +0 -8
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +0 -10
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +0 -6
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +0 -8
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +0 -7
- package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +0 -8
- package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +0 -7
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +0 -9
- package/src/lib/Property/ViewProperty/ViewProperty.d.ts +0 -9
- package/src/lib/Sidebar/Sidebar.d.ts +0 -10
- package/src/lib/Sidebar/Sidebar.styled.d.ts +0 -117
- package/src/lib/Sidebar/SidebarContext.d.ts +0 -11
- package/src/lib/Sidebar/SidebarDrawer.d.ts +0 -9
- package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +0 -7
- package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +0 -7
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +0 -8
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +0 -10
- package/src/lib/Sidebar/index.d.ts +0 -2
- package/src/lib/Status/Status.d.ts +0 -8
- package/src/lib/Status/styles.d.ts +0 -12
- package/src/lib/StepperView/StepperView.d.ts +0 -11
- package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +0 -7
- package/src/lib/Table/DataGrid/Table.d.ts +0 -49
- package/src/lib/Table/DataGrid/TableAction.d.ts +0 -13
- package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +0 -3
- package/src/lib/Table/DataGrid/TablePagination.d.ts +0 -3
- package/src/lib/Table/DataGrid/index.d.ts +0 -2
- package/src/lib/Table/DataGrid/styles.d.ts +0 -12
- package/src/lib/Table/DataGrid/usePagination.d.ts +0 -5
- package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +0 -11
- package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +0 -6
- package/src/lib/Table/SimpleTable/SimpleTable.d.ts +0 -17
- package/src/lib/Table/SimpleTable/TableActionCell.d.ts +0 -10
- package/src/lib/Table/SimpleTable/index.d.ts +0 -2
- package/src/lib/Table/SimpleTable/useTablePagination.d.ts +0 -7
- package/src/lib/Table/SimpleTable/useTableSorting.d.ts +0 -6
- package/src/lib/Table/index.d.ts +0 -2
- package/src/lib/Tabs/RouteTabs.d.ts +0 -11
- package/src/lib/Tabs/TabPanel.d.ts +0 -25
- package/src/theme/baseTheme.d.ts +0 -2
- package/src/theme/index.d.ts +0 -1
- package/src/theme/inputThemeOptions.d.ts +0 -117
- package/src/theme/stepperThemeOptions.d.ts +0 -16
- package/src/theme/tableThemeOptions.d.ts +0 -47
- package/src/theme/typographyThemeOptions.d.ts +0 -29
- package/src/utils/common.d.ts +0 -7
- package/src/utils/dem.d.ts +0 -27
- package/src/utils/hooks.d.ts +0 -7
- package/src/utils/ui-utils.d.ts +0 -8
- package/src/utils/validators.d.ts +0 -5
@@ -0,0 +1,148 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import Button from '@mui/material/Button';
|
3
|
+
import Typography from '@mui/material/Typography';
|
4
|
+
import Accordion from '@mui/material/Accordion';
|
5
|
+
import AccordionSummary from '@mui/material/AccordionSummary';
|
6
|
+
import AccordionDetails from '@mui/material/AccordionDetails';
|
7
|
+
import AccordionActions from '@mui/material/AccordionActions';
|
8
|
+
import { ExpandMore } from '@mui/icons-material';
|
9
|
+
import CreatePropertyFormFields from './CreatePropertyFormFields';
|
10
|
+
|
11
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
12
|
+
import { useController, useFormContext, useWatch } from 'react-hook-form';
|
13
|
+
import { removeArrayItem } from '../../../utils/common';
|
14
|
+
import { CustomPropertyFieldProps } from '../../../interfaces';
|
15
|
+
|
16
|
+
type Props = {
|
17
|
+
parentFieldName?: string;
|
18
|
+
hideAddButton?: boolean;
|
19
|
+
focusOnIndex?: number;
|
20
|
+
required?: boolean;
|
21
|
+
entityDefinition?: boolean;
|
22
|
+
globalParameter?: boolean;
|
23
|
+
customPropertyFields?: CustomPropertyFieldProps[];
|
24
|
+
};
|
25
|
+
|
26
|
+
const defaultPropertyValues = {
|
27
|
+
key: '',
|
28
|
+
propertyType: null,
|
29
|
+
name: '',
|
30
|
+
defaultValue: '',
|
31
|
+
defaultValues: [],
|
32
|
+
isRequired: true,
|
33
|
+
isMultiple: false,
|
34
|
+
sortOrder: 0,
|
35
|
+
isEnabled: true,
|
36
|
+
executeValue: '',
|
37
|
+
uiSettings: '',
|
38
|
+
};
|
39
|
+
|
40
|
+
export const CreatePropertiesList = ({
|
41
|
+
parentFieldName,
|
42
|
+
hideAddButton,
|
43
|
+
focusOnIndex,
|
44
|
+
required,
|
45
|
+
entityDefinition = false,
|
46
|
+
globalParameter = false,
|
47
|
+
customPropertyFields = [],
|
48
|
+
}: Props) => {
|
49
|
+
const fieldName = useMemo(
|
50
|
+
() => (parentFieldName ? `${parentFieldName}.properties` : `properties`),
|
51
|
+
[parentFieldName]
|
52
|
+
);
|
53
|
+
|
54
|
+
const { setValue, clearErrors, control } = useFormContext();
|
55
|
+
const {
|
56
|
+
fieldState: { error },
|
57
|
+
} = useController({
|
58
|
+
control,
|
59
|
+
name: fieldName,
|
60
|
+
rules: { required: required && 'Please, add properties' },
|
61
|
+
});
|
62
|
+
const properties = useWatch({ control, name: fieldName });
|
63
|
+
|
64
|
+
const refs = useRef([]);
|
65
|
+
|
66
|
+
useEffect(() => {
|
67
|
+
if (typeof focusOnIndex === 'number' && refs.current[focusOnIndex]) {
|
68
|
+
refs.current[focusOnIndex].scrollIntoView({
|
69
|
+
behavior: 'smooth',
|
70
|
+
block: 'start',
|
71
|
+
});
|
72
|
+
}
|
73
|
+
}, [focusOnIndex, refs]);
|
74
|
+
|
75
|
+
const handleAddParameter = useCallback(() => {
|
76
|
+
if (properties) {
|
77
|
+
setValue(`${fieldName}.${properties.length}`, defaultPropertyValues);
|
78
|
+
} else {
|
79
|
+
setValue(fieldName, [defaultPropertyValues]);
|
80
|
+
}
|
81
|
+
clearErrors(fieldName);
|
82
|
+
}, [properties, fieldName, clearErrors, setValue]);
|
83
|
+
|
84
|
+
const handleRemoveParameter = useCallback(
|
85
|
+
(index) => {
|
86
|
+
setValue(`${fieldName}`, removeArrayItem(properties, index));
|
87
|
+
},
|
88
|
+
[properties, fieldName, setValue]
|
89
|
+
);
|
90
|
+
|
91
|
+
return (
|
92
|
+
<>
|
93
|
+
{error && error.message && (
|
94
|
+
<Grid sm={12}>
|
95
|
+
<Typography color="secondary">{error.message}</Typography>
|
96
|
+
</Grid>
|
97
|
+
)}
|
98
|
+
{properties &&
|
99
|
+
properties.map((property, index) => (
|
100
|
+
<Grid key={index} sm={12} ref={(ref) => (refs.current[index] = ref)}>
|
101
|
+
<Accordion defaultExpanded elevation={3}>
|
102
|
+
<AccordionSummary expandIcon={<ExpandMore />}>
|
103
|
+
<Typography
|
104
|
+
color={error && error[index] ? 'secondary' : 'initial'}
|
105
|
+
style={{ wordBreak: 'break-word' }}
|
106
|
+
>
|
107
|
+
{property.name || `Property ${index + 1}`}
|
108
|
+
</Typography>
|
109
|
+
</AccordionSummary>
|
110
|
+
<AccordionDetails>
|
111
|
+
<CreatePropertyFormFields
|
112
|
+
propertyFieldName={`${fieldName}.${index}`}
|
113
|
+
entityDefinition={entityDefinition}
|
114
|
+
globalParameter={globalParameter}
|
115
|
+
customPropertyFields={customPropertyFields}
|
116
|
+
/>
|
117
|
+
</AccordionDetails>
|
118
|
+
<AccordionActions>
|
119
|
+
<Button
|
120
|
+
variant="contained"
|
121
|
+
size="small"
|
122
|
+
color="secondary"
|
123
|
+
onClick={() => handleRemoveParameter(index)}
|
124
|
+
>
|
125
|
+
Remove
|
126
|
+
</Button>
|
127
|
+
</AccordionActions>
|
128
|
+
</Accordion>
|
129
|
+
</Grid>
|
130
|
+
))}
|
131
|
+
|
132
|
+
{!hideAddButton && (
|
133
|
+
<Grid xs={12}>
|
134
|
+
<Button
|
135
|
+
variant="contained"
|
136
|
+
size="small"
|
137
|
+
color="primary"
|
138
|
+
onClick={handleAddParameter}
|
139
|
+
>
|
140
|
+
Add property
|
141
|
+
</Button>
|
142
|
+
</Grid>
|
143
|
+
)}
|
144
|
+
</>
|
145
|
+
);
|
146
|
+
};
|
147
|
+
|
148
|
+
export default CreatePropertiesList;
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import {
|
3
|
+
ControlCheckbox,
|
4
|
+
ControlAutocomplete,
|
5
|
+
ControlNumberInput,
|
6
|
+
ControlAceEditor,
|
7
|
+
ControlDebouncedInput,
|
8
|
+
} from '../../Forms';
|
9
|
+
import { PropertyAdditionalFields } from './PropertyAdditionalFields';
|
10
|
+
import { PropertyValueField } from '../PropertyValueField';
|
11
|
+
import { PropertyValidator } from '../PropertyValidator';
|
12
|
+
import CustomPropertyField from './CustomPropertyField';
|
13
|
+
import { PropertyValidatorContext } from '../PropertyValidator/PropertyValidatorContext';
|
14
|
+
import { useMemo, useEffect } from 'react';
|
15
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
16
|
+
import useCustomFields from './useCustomFields';
|
17
|
+
|
18
|
+
import { CustomPropertyFieldProps, PropertyType } from '../../../interfaces';
|
19
|
+
|
20
|
+
type Props = {
|
21
|
+
propertyFieldName: string;
|
22
|
+
entityDefinition?: boolean;
|
23
|
+
globalParameter?: boolean;
|
24
|
+
customPropertyFields?: CustomPropertyFieldProps[];
|
25
|
+
};
|
26
|
+
|
27
|
+
const propertyTypes = Object.values(PropertyType)
|
28
|
+
.sort((a, b) => a.localeCompare(b))
|
29
|
+
.map((propType) => ({
|
30
|
+
value: propType,
|
31
|
+
label: propType
|
32
|
+
.replace('_', ' ')
|
33
|
+
.toLowerCase()
|
34
|
+
.replace(/(^\w)|([-\s]\w)/g, (c) => c.toUpperCase()),
|
35
|
+
}));
|
36
|
+
|
37
|
+
export const CreatePropertyFormFields = ({
|
38
|
+
propertyFieldName,
|
39
|
+
entityDefinition = false,
|
40
|
+
globalParameter = false,
|
41
|
+
customPropertyFields = [],
|
42
|
+
}: Props) => {
|
43
|
+
const { control, setValue } = useFormContext();
|
44
|
+
const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
|
45
|
+
const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
|
46
|
+
const isRequired = useWatch({ control, name: `${propertyFieldName}.isRequired` });
|
47
|
+
|
48
|
+
const { customCheckboxes, customFields } = useCustomFields(customPropertyFields);
|
49
|
+
|
50
|
+
const valueLabel = useMemo(() => {
|
51
|
+
let label = globalParameter ? 'Value' : 'Default Value';
|
52
|
+
if (isMultiple) {
|
53
|
+
label += 's';
|
54
|
+
}
|
55
|
+
return label;
|
56
|
+
}, [globalParameter, isMultiple]);
|
57
|
+
|
58
|
+
const handlePropertyTypeChange = (_, value) => {
|
59
|
+
const fieldName = `${propertyFieldName}.propertyType`;
|
60
|
+
const valueFieldName = `${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`;
|
61
|
+
if (isMultiple) {
|
62
|
+
setValue(valueFieldName, []);
|
63
|
+
} else {
|
64
|
+
setValue(valueFieldName, null);
|
65
|
+
}
|
66
|
+
setValue(fieldName, value);
|
67
|
+
};
|
68
|
+
|
69
|
+
useEffect(() => {
|
70
|
+
if (propertyType && typeof propertyType === 'string') {
|
71
|
+
setValue(`${propertyFieldName}.propertyType`, propertyTypes.find(el => el.value === propertyType));
|
72
|
+
}
|
73
|
+
}, [propertyType, setValue, propertyFieldName])
|
74
|
+
|
75
|
+
return (
|
76
|
+
<Grid container direction="column" spacing={2}>
|
77
|
+
<Grid>
|
78
|
+
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.key`} label="Key" />
|
79
|
+
</Grid>
|
80
|
+
<Grid>
|
81
|
+
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.name`} label="Name" />
|
82
|
+
</Grid>
|
83
|
+
<Grid>
|
84
|
+
<ControlAutocomplete
|
85
|
+
required
|
86
|
+
control={control}
|
87
|
+
name={`${propertyFieldName}.propertyType`}
|
88
|
+
label="Type"
|
89
|
+
options={propertyTypes}
|
90
|
+
onChange={handlePropertyTypeChange}
|
91
|
+
/>
|
92
|
+
</Grid>
|
93
|
+
<Grid>
|
94
|
+
<ControlNumberInput required control={control} name={`${propertyFieldName}.sortOrder`} label="Sort Order" />
|
95
|
+
</Grid>
|
96
|
+
|
97
|
+
<Grid>
|
98
|
+
<ControlAceEditor control={control} name={`${propertyFieldName}.uiSettings`} label="UI Settings" validateJson />
|
99
|
+
</Grid>
|
100
|
+
<Grid>
|
101
|
+
<ControlCheckbox control={control} name={`${propertyFieldName}.isMultiple`} label="Multiple" />
|
102
|
+
<ControlCheckbox control={control} name={`${propertyFieldName}.isEnabled`} label="Enabled" />
|
103
|
+
<ControlCheckbox control={control} name={`${propertyFieldName}.isRequired`} label="Required" />
|
104
|
+
{entityDefinition && (
|
105
|
+
<ControlCheckbox
|
106
|
+
control={control}
|
107
|
+
name={`${propertyFieldName}.isViewableInList`}
|
108
|
+
label="Is viewable in list"
|
109
|
+
/>
|
110
|
+
)}
|
111
|
+
{customCheckboxes.length ? (
|
112
|
+
<>
|
113
|
+
{customCheckboxes.map((field, index) => (
|
114
|
+
<ControlCheckbox
|
115
|
+
key={index}
|
116
|
+
control={control}
|
117
|
+
name={`${propertyFieldName}.${field.name}`}
|
118
|
+
label={field.label}
|
119
|
+
/>
|
120
|
+
))}
|
121
|
+
</>
|
122
|
+
) : null}
|
123
|
+
</Grid>
|
124
|
+
{propertyType && (
|
125
|
+
<>
|
126
|
+
<Grid>
|
127
|
+
<PropertyValidatorContext.Provider value={propertyType.value ?? propertyType}>
|
128
|
+
<PropertyValidator name={`${propertyFieldName}.validationNode`} />
|
129
|
+
</PropertyValidatorContext.Provider>
|
130
|
+
</Grid>
|
131
|
+
<PropertyAdditionalFields
|
132
|
+
propertyType={typeof propertyType === 'string' ? propertyType : propertyType.value}
|
133
|
+
propertyFieldName={propertyFieldName}
|
134
|
+
globalParameter={globalParameter}
|
135
|
+
entityDefinition={entityDefinition}
|
136
|
+
/>
|
137
|
+
<PropertyValueField
|
138
|
+
propertyFieldName={propertyFieldName}
|
139
|
+
name={`${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`}
|
140
|
+
label={valueLabel}
|
141
|
+
required={globalParameter ? isRequired : false}
|
142
|
+
/>
|
143
|
+
</>
|
144
|
+
)}
|
145
|
+
{customFields.length ? (
|
146
|
+
<>
|
147
|
+
{customFields.map((field, index) => (
|
148
|
+
<Grid key={index}>
|
149
|
+
<CustomPropertyField {...field} propertyFieldName={propertyFieldName} />
|
150
|
+
</Grid>
|
151
|
+
))}
|
152
|
+
</>
|
153
|
+
) : null}
|
154
|
+
</Grid>
|
155
|
+
);
|
156
|
+
};
|
157
|
+
|
158
|
+
export default CreatePropertyFormFields;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { useMemo } from 'react';
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
3
|
+
import { CustomPropertyFieldProps } from '../../../interfaces';
|
4
|
+
import { ControlAceEditor, ControlAutocomplete, ControlInput, ControlNumberInput, ControlSelect } from '../../Forms';
|
5
|
+
|
6
|
+
type Props = CustomPropertyFieldProps & { propertyFieldName: string };
|
7
|
+
|
8
|
+
export const CustomPropertyField = ({
|
9
|
+
name,
|
10
|
+
label = '',
|
11
|
+
propertyFieldName,
|
12
|
+
type,
|
13
|
+
decimal = false,
|
14
|
+
options = [],
|
15
|
+
required = false,
|
16
|
+
}: Props) => {
|
17
|
+
const { control } = useFormContext();
|
18
|
+
const fieldName = useMemo(() => `${propertyFieldName}.${name}`, [name, propertyFieldName]);
|
19
|
+
|
20
|
+
switch (type) {
|
21
|
+
case 'text':
|
22
|
+
return <ControlInput control={control} name={fieldName} label={label} required={required} />;
|
23
|
+
case 'number':
|
24
|
+
return (
|
25
|
+
<ControlNumberInput control={control} name={fieldName} label={label} decimal={decimal} required={required} />
|
26
|
+
);
|
27
|
+
case 'select':
|
28
|
+
return <ControlSelect control={control} name={fieldName} label={label} options={options} required={required} />;
|
29
|
+
case 'autocomplete':
|
30
|
+
return (
|
31
|
+
<ControlAutocomplete control={control} name={fieldName} label={label} options={options} required={required} />
|
32
|
+
);
|
33
|
+
case 'json':
|
34
|
+
return <ControlAceEditor control={control} name={fieldName} label={label} mode="json" required={required} />;
|
35
|
+
default:
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
export default CustomPropertyField;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import { ControlNumberInput, ControlSelect } from '../../../Forms';
|
3
|
+
import { RoundingMode } from '../../../../interfaces';
|
4
|
+
|
5
|
+
import { useFormContext } from 'react-hook-form';
|
6
|
+
|
7
|
+
type Props = {
|
8
|
+
propertyFieldName: string;
|
9
|
+
};
|
10
|
+
|
11
|
+
const roundingModes = Object.values(RoundingMode).sort((a, b) => a.localeCompare(b));
|
12
|
+
|
13
|
+
const BigDecimalPropertyFields = ({ propertyFieldName }: Props) => {
|
14
|
+
const { control } = useFormContext();
|
15
|
+
|
16
|
+
return (
|
17
|
+
<>
|
18
|
+
<Grid>
|
19
|
+
<ControlNumberInput
|
20
|
+
required
|
21
|
+
control={control}
|
22
|
+
defaultValue={2}
|
23
|
+
name={`${propertyFieldName}.precisionScale`}
|
24
|
+
label="Precision Scale"
|
25
|
+
/>
|
26
|
+
</Grid>
|
27
|
+
<Grid>
|
28
|
+
<ControlSelect
|
29
|
+
required
|
30
|
+
control={control}
|
31
|
+
name={`${propertyFieldName}.roundingMode`}
|
32
|
+
label="Rounding Mode"
|
33
|
+
defaultValue={RoundingMode.HALF_UP}
|
34
|
+
options={roundingModes}
|
35
|
+
/>
|
36
|
+
</Grid>
|
37
|
+
</>
|
38
|
+
);
|
39
|
+
};
|
40
|
+
|
41
|
+
export default BigDecimalPropertyFields;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import { ControlInput } from '../../../Forms';
|
3
|
+
|
4
|
+
import { useFormContext } from 'react-hook-form';
|
5
|
+
|
6
|
+
type Props = {
|
7
|
+
propertyFieldName: string;
|
8
|
+
defaultValue?: string;
|
9
|
+
};
|
10
|
+
|
11
|
+
const DateAdditionalFields = ({ propertyFieldName, defaultValue = '' }: Props) => {
|
12
|
+
const { control } = useFormContext();
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Grid>
|
16
|
+
<ControlInput
|
17
|
+
required
|
18
|
+
control={control}
|
19
|
+
defaultValue={defaultValue}
|
20
|
+
name={`${propertyFieldName}.format`}
|
21
|
+
label="Format"
|
22
|
+
/>
|
23
|
+
</Grid>
|
24
|
+
);
|
25
|
+
};
|
26
|
+
|
27
|
+
export default DateAdditionalFields;
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import Button from '@mui/material/Button';
|
3
|
+
import Typography from '@mui/material/Typography';
|
4
|
+
import Dialog from '@mui/material/Dialog';
|
5
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
6
|
+
import DialogContent from '@mui/material/DialogContent';
|
7
|
+
import DialogActions from '@mui/material/DialogActions';
|
8
|
+
import Stepper from '@mui/material/Stepper';
|
9
|
+
import Step from '@mui/material/Step';
|
10
|
+
import StepLabel from '@mui/material/StepLabel';
|
11
|
+
import StepContent from '@mui/material/StepContent';
|
12
|
+
import CreatePropertiesList from '../CreatePropertiesList';
|
13
|
+
import EntityPropertiesShortView from '../../ViewProperty/EntityPropertiesShortView';
|
14
|
+
|
15
|
+
import { useCallback, useState } from 'react';
|
16
|
+
import { useFormContext, useWatch } from 'react-hook-form';
|
17
|
+
import { useToggle } from '../../../../utils/hooks';
|
18
|
+
|
19
|
+
type Props = {
|
20
|
+
parentPropertyFieldName: string;
|
21
|
+
entityDefinition?: boolean;
|
22
|
+
globalParameter?: boolean;
|
23
|
+
};
|
24
|
+
|
25
|
+
const defaultPropertyValues = {
|
26
|
+
key: '',
|
27
|
+
propertyType: '',
|
28
|
+
name: '',
|
29
|
+
defaultValue: '',
|
30
|
+
isRequired: true,
|
31
|
+
isMultiple: false,
|
32
|
+
sortOrder: 0,
|
33
|
+
isEnabled: true,
|
34
|
+
};
|
35
|
+
|
36
|
+
const EntityAdditionalFields = ({
|
37
|
+
parentPropertyFieldName,
|
38
|
+
entityDefinition = false,
|
39
|
+
globalParameter = false,
|
40
|
+
}: Props) => {
|
41
|
+
const { control, setValue, getValues, trigger } = useFormContext();
|
42
|
+
const properties = useWatch({
|
43
|
+
control,
|
44
|
+
name: `${parentPropertyFieldName}.properties`,
|
45
|
+
defaultValue: getValues(`${parentPropertyFieldName}.properties`) || [],
|
46
|
+
});
|
47
|
+
const parentPropertyName = useWatch({ control, name: `${parentPropertyFieldName}.name` });
|
48
|
+
|
49
|
+
const parametersModal = useToggle();
|
50
|
+
|
51
|
+
const [focusedProperty, setFocusedProperty] = useState(0);
|
52
|
+
|
53
|
+
const handleAddParameter = useCallback(() => {
|
54
|
+
if (properties) {
|
55
|
+
const propertyIndex = properties.length;
|
56
|
+
setValue(`${parentPropertyFieldName}.properties.${propertyIndex}`, defaultPropertyValues);
|
57
|
+
setFocusedProperty(propertyIndex);
|
58
|
+
} else {
|
59
|
+
setValue(`${parentPropertyFieldName}.properties`, [defaultPropertyValues]);
|
60
|
+
}
|
61
|
+
}, [properties, parentPropertyFieldName, setValue]);
|
62
|
+
|
63
|
+
const handleStepperClick = (index) => setFocusedProperty(index);
|
64
|
+
|
65
|
+
const handleSubmitClick = async () => {
|
66
|
+
const isValid = await trigger(`${parentPropertyFieldName}.properties`);
|
67
|
+
if (isValid) {
|
68
|
+
parametersModal.onClose();
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
return (
|
73
|
+
<>
|
74
|
+
<Grid>
|
75
|
+
<Typography variant="h6">Properties</Typography>
|
76
|
+
</Grid>
|
77
|
+
<Grid>
|
78
|
+
<EntityPropertiesShortView properties={properties} />
|
79
|
+
</Grid>
|
80
|
+
<Grid>
|
81
|
+
<Button variant="contained" color="primary" onClick={parametersModal.onOpen}>
|
82
|
+
Edit properties
|
83
|
+
</Button>
|
84
|
+
</Grid>
|
85
|
+
|
86
|
+
<Dialog disableEscapeKeyDown open={parametersModal.open} onClose={handleSubmitClick} fullWidth maxWidth="md">
|
87
|
+
<DialogTitle>{parentPropertyName || 'Entity'} Properties</DialogTitle>
|
88
|
+
<DialogContent style={{ height: '500px', overflow: 'hidden' }}>
|
89
|
+
<Grid container direction="row" spacing={2} style={{ height: '100%' }}>
|
90
|
+
<Grid xs={3} style={{ backgroundColor: '#f9f9f9' }}>
|
91
|
+
<Stepper nonLinear activeStep={focusedProperty} orientation="vertical" style={{ paddingLeft: '4px' }}>
|
92
|
+
{properties.map((property, index) => (
|
93
|
+
<Step key={index} onClick={() => handleStepperClick(index)} style={{ cursor: 'pointer' }}>
|
94
|
+
<StepLabel StepIconProps={{ icon: '' }} style={{ wordBreak: 'break-word' }}>
|
95
|
+
{property.name || '(no name)'}
|
96
|
+
</StepLabel>
|
97
|
+
<StepContent></StepContent>
|
98
|
+
</Step>
|
99
|
+
))}
|
100
|
+
</Stepper>
|
101
|
+
<Button variant="contained" size="small" color="primary" onClick={handleAddParameter}>
|
102
|
+
Add property
|
103
|
+
</Button>
|
104
|
+
</Grid>
|
105
|
+
<Grid
|
106
|
+
container
|
107
|
+
wrap="nowrap"
|
108
|
+
direction="column"
|
109
|
+
xs={9}
|
110
|
+
spacing={2}
|
111
|
+
style={{ height: '100%', overflowY: 'auto' }}
|
112
|
+
>
|
113
|
+
<CreatePropertiesList
|
114
|
+
hideAddButton
|
115
|
+
parentFieldName={parentPropertyFieldName}
|
116
|
+
focusOnIndex={focusedProperty}
|
117
|
+
entityDefinition={entityDefinition}
|
118
|
+
globalParameter={globalParameter}
|
119
|
+
/>
|
120
|
+
</Grid>
|
121
|
+
</Grid>
|
122
|
+
</DialogContent>
|
123
|
+
<DialogActions>
|
124
|
+
<Button variant="contained" color="primary" onClick={handleSubmitClick}>
|
125
|
+
Ok
|
126
|
+
</Button>
|
127
|
+
</DialogActions>
|
128
|
+
</Dialog>
|
129
|
+
</>
|
130
|
+
);
|
131
|
+
};
|
132
|
+
|
133
|
+
export default EntityAdditionalFields;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
2
|
+
import { ControlInput } from '../../../Forms';
|
3
|
+
|
4
|
+
import { useFormContext } from 'react-hook-form';
|
5
|
+
|
6
|
+
type Props = {
|
7
|
+
propertyFieldName: string;
|
8
|
+
};
|
9
|
+
|
10
|
+
const EntityReferencePropertyFields = ({ propertyFieldName }: Props) => {
|
11
|
+
const { control } = useFormContext();
|
12
|
+
|
13
|
+
return (
|
14
|
+
<>
|
15
|
+
<Grid>
|
16
|
+
<ControlInput required control={control} name={`${propertyFieldName}.definitionCode`} label="Definition Code" />
|
17
|
+
</Grid>
|
18
|
+
<Grid>
|
19
|
+
<ControlInput
|
20
|
+
required
|
21
|
+
control={control}
|
22
|
+
name={`${propertyFieldName}.definitionVersion`}
|
23
|
+
label="Definition Version"
|
24
|
+
/>
|
25
|
+
</Grid>
|
26
|
+
<Grid>
|
27
|
+
<ControlInput
|
28
|
+
required
|
29
|
+
control={control}
|
30
|
+
name={`${propertyFieldName}.labelPropertyCode`}
|
31
|
+
label="Label Property Code"
|
32
|
+
/>
|
33
|
+
</Grid>
|
34
|
+
<Grid>
|
35
|
+
<ControlInput
|
36
|
+
required
|
37
|
+
control={control}
|
38
|
+
name={`${propertyFieldName}.valuePropertyCode`}
|
39
|
+
label="Value Property Code"
|
40
|
+
/>
|
41
|
+
</Grid>
|
42
|
+
</>
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
export default EntityReferencePropertyFields;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import {
|
2
|
+
PropertyType,
|
3
|
+
DATE_DEFAULT_FORMAT,
|
4
|
+
DATE_TIME_DEFAULT_FORMAT,
|
5
|
+
TIME_DEFAULT_FORMAT,
|
6
|
+
} from '../../../../interfaces';
|
7
|
+
import BigDecimalPropertyFields from './BigDecimalPropertyFields';
|
8
|
+
import DateAdditionalFields from './DateAdditionalFields';
|
9
|
+
import EntityAdditionalFields from './EntityAdditionalFields';
|
10
|
+
import EntityReferencePropertyFields from './EntityReferencePropertyFields';
|
11
|
+
import StringPropertyFields from './StringPropertyFields';
|
12
|
+
|
13
|
+
type Props = {
|
14
|
+
propertyType: PropertyType;
|
15
|
+
propertyFieldName: string;
|
16
|
+
entityDefinition?: boolean;
|
17
|
+
globalParameter?: boolean;
|
18
|
+
};
|
19
|
+
|
20
|
+
export const PropertyAdditionalFields = ({
|
21
|
+
propertyType,
|
22
|
+
propertyFieldName,
|
23
|
+
entityDefinition = false,
|
24
|
+
globalParameter = false,
|
25
|
+
}: Props) => {
|
26
|
+
switch (propertyType) {
|
27
|
+
case PropertyType.STRING:
|
28
|
+
return <StringPropertyFields propertyFieldName={propertyFieldName} />;
|
29
|
+
case PropertyType.BIG_DECIMAL:
|
30
|
+
return <BigDecimalPropertyFields propertyFieldName={propertyFieldName} />;
|
31
|
+
case PropertyType.DATE:
|
32
|
+
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={DATE_DEFAULT_FORMAT} />;
|
33
|
+
case PropertyType.TIME:
|
34
|
+
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={TIME_DEFAULT_FORMAT} />;
|
35
|
+
case PropertyType.DATE_TIME:
|
36
|
+
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={DATE_TIME_DEFAULT_FORMAT} />;
|
37
|
+
case PropertyType.ENTITY_REFERENCE:
|
38
|
+
return <EntityReferencePropertyFields propertyFieldName={propertyFieldName} />;
|
39
|
+
case PropertyType.ENTITY:
|
40
|
+
return (
|
41
|
+
<EntityAdditionalFields
|
42
|
+
parentPropertyFieldName={propertyFieldName}
|
43
|
+
globalParameter={globalParameter}
|
44
|
+
entityDefinition={entityDefinition}
|
45
|
+
/>
|
46
|
+
);
|
47
|
+
default:
|
48
|
+
return null;
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
export default PropertyAdditionalFields;
|