@dartech/arsenal-ui 0.0.1 → 0.0.2
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/{index.ts → index.d.ts} +3 -3
- package/index.esm.js +1 -0
- package/index.umd.js +1 -0
- package/package.json +5 -2
- package/src/interfaces/common.d.ts +10 -0
- package/src/interfaces/definition.d.ts +117 -0
- package/src/interfaces/{index.ts → index.d.ts} +3 -3
- package/src/interfaces/ui.d.ts +33 -0
- package/src/lib/Alert/Alert.d.ts +53 -0
- package/src/lib/Alert/index.d.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
- package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +8 -0
- package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.d.ts +9 -0
- package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +2 -2
- package/src/lib/Definition/{index.ts → index.d.ts} +2 -2
- package/src/lib/DemPropertyField/DemPropertyField.d.ts +59 -0
- package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.d.ts +8 -0
- package/src/lib/DemPropertyField/DemPropertyView/{index.ts → index.d.ts} +1 -1
- package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.d.ts +9 -0
- package/src/lib/DemPropertyField/MultipleDemField/{index.tsx → index.d.ts} +1 -1
- package/src/lib/DemPropertyField/RestrictedValuesEditor.d.ts +6 -0
- package/src/lib/DemPropertyField/SingleDemField/SingleDemField.d.ts +9 -0
- package/src/lib/DemPropertyField/SingleDemField/{index.ts → index.d.ts} +1 -1
- package/src/lib/DemPropertyField/{index.ts → index.d.ts} +2 -2
- package/src/lib/DemPropertyField/styles.d.ts +2 -0
- package/src/lib/DemPropertyField/widgets/DemBooleanWidget.d.ts +7 -0
- package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.d.ts +9 -0
- package/src/lib/DemPropertyField/widgets/DemDateWidget.d.ts +9 -0
- package/src/lib/DemPropertyField/widgets/DemFieldWidget.d.ts +11 -0
- package/src/lib/DemPropertyField/widgets/DemFloatWidget.d.ts +10 -0
- package/src/lib/DemPropertyField/widgets/DemIntegerWidget.d.ts +10 -0
- package/src/lib/DemPropertyField/widgets/DemJsonWidget.d.ts +9 -0
- package/src/lib/DemPropertyField/widgets/DemStringWidget.d.ts +10 -0
- package/src/lib/DemPropertyField/widgets/DemTimeWidget.d.ts +9 -0
- package/src/lib/DemPropertyField/widgets/{index.ts → index.d.ts} +1 -1
- package/src/lib/Forms/BackButton.d.ts +7 -0
- package/src/lib/Forms/ControlAceEditor.d.ts +20 -0
- package/src/lib/Forms/ControlAutocomplete.d.ts +49 -0
- package/src/lib/Forms/ControlCheckbox.d.ts +30 -0
- package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
- package/src/lib/Forms/ControlInput.d.ts +54 -0
- package/src/lib/Forms/ControlNumberInput.d.ts +43 -0
- package/src/lib/Forms/ControlRadioBtn.d.ts +26 -0
- package/src/lib/Forms/ControlSelect.d.ts +66 -0
- package/src/lib/Forms/CopyButton.d.ts +21 -0
- package/src/lib/Forms/{index.ts → index.d.ts} +10 -10
- package/src/lib/InfoItem/InfoItem.d.ts +10 -0
- package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
- package/src/lib/InfoItem/styles.d.ts +2 -0
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
- package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
- package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
- package/src/lib/JsonView/JsonView.d.ts +9 -0
- package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Loader/Loader.d.ts +21 -0
- package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
- package/src/lib/Modals/JsonModalView.d.ts +10 -0
- package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/EntityValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
- package/src/lib/Property/PropertyValueField/PropertyValue.d.ts +10 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/ValueComponent.d.ts +15 -0
- package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +2 -1
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +9 -0
- package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
- package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
- package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +9 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
- package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
- package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/{index.ts → index.d.ts} +4 -4
- package/src/lib/Status/Status.d.ts +7 -0
- package/src/lib/Status/{index.ts → index.d.ts} +1 -1
- package/src/lib/Status/styles.d.ts +2 -0
- package/src/lib/Table/Table.d.ts +49 -0
- package/src/lib/Table/TableColumnMenu.d.ts +3 -0
- package/src/lib/Table/TablePagination.d.ts +3 -0
- package/src/lib/Table/index.d.ts +1 -0
- package/src/lib/Table/styles.d.ts +2 -0
- package/src/lib/Table/usePagination.d.ts +5 -0
- package/src/lib/Table/useTableQueryPagination.d.ts +11 -0
- package/src/lib/Table/useTableQuerySorting.d.ts +6 -0
- package/src/lib/Tabs/RouteTabs.d.ts +11 -0
- package/src/lib/Tabs/TabPanel.d.ts +25 -0
- package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
- package/src/lib/TemplateContent/ExpressionDecorator.d.ts +5 -0
- package/src/lib/TemplateContent/TemplateContentEditor.d.ts +9 -0
- package/src/lib/TemplateContent/{index.ts → index.d.ts} +1 -1
- package/src/lib/{index.ts → index.d.ts} +14 -14
- package/src/utils/common.d.ts +7 -0
- package/src/utils/dem.d.ts +7 -0
- package/src/utils/hooks.d.ts +7 -0
- package/src/utils/{index.ts → index.d.ts} +5 -5
- package/src/utils/ui-utils.d.ts +7 -0
- package/src/utils/validators.d.ts +12 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -22
- package/jest.config.js +0 -9
- package/project.json +0 -69
- package/rollup.config.js +0 -135
- package/src/interfaces/common.ts +0 -12
- package/src/interfaces/definition.ts +0 -143
- package/src/interfaces/ui.ts +0 -35
- package/src/lib/Alert/Alert.tsx +0 -108
- package/src/lib/Alert/index.ts +0 -1
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -74
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -85
- package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +0 -96
- package/src/lib/DemPropertyField/DemPropertyField.tsx +0 -93
- package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +0 -44
- package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +0 -293
- package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +0 -63
- package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +0 -156
- package/src/lib/DemPropertyField/styles.ts +0 -50
- package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +0 -26
- package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +0 -34
- package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +0 -33
- package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +0 -67
- package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +0 -49
- package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +0 -63
- package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +0 -33
- package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +0 -35
- package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +0 -46
- package/src/lib/Forms/BackButton.tsx +0 -45
- package/src/lib/Forms/ControlAceEditor.tsx +0 -103
- package/src/lib/Forms/ControlAutocomplete.tsx +0 -134
- package/src/lib/Forms/ControlCheckbox.tsx +0 -57
- package/src/lib/Forms/ControlDebouncedInput.tsx +0 -69
- package/src/lib/Forms/ControlInput.tsx +0 -102
- package/src/lib/Forms/ControlNumberInput.tsx +0 -144
- package/src/lib/Forms/ControlRadioBtn.tsx +0 -46
- package/src/lib/Forms/ControlSelect.tsx +0 -135
- package/src/lib/Forms/CopyButton.tsx +0 -49
- package/src/lib/InfoItem/InfoItem.tsx +0 -39
- package/src/lib/InfoItem/styles.ts +0 -17
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -71
- package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -74
- package/src/lib/JsonView/JsonView.tsx +0 -43
- package/src/lib/Loader/Loader.tsx +0 -41
- package/src/lib/Modals/JsonModalView.tsx +0 -52
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -41
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -59
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -59
- package/src/lib/Property/PropertyValueField/EntityValueField.tsx +0 -33
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -64
- package/src/lib/Property/PropertyValueField/PropertyValue.tsx +0 -97
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -86
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -21
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -68
- package/src/lib/Property/PropertyValueField/ValueComponent.tsx +0 -63
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -167
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -131
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -147
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -98
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -50
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -41
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -139
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -46
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
- package/src/lib/Status/Status.tsx +0 -15
- package/src/lib/Status/styles.ts +0 -14
- package/src/lib/Table/Table.tsx +0 -116
- package/src/lib/Table/TableColumnMenu.tsx +0 -12
- package/src/lib/Table/TablePagination.tsx +0 -42
- package/src/lib/Table/index.ts +0 -1
- package/src/lib/Table/styles.ts +0 -59
- package/src/lib/Table/usePagination.ts +0 -15
- package/src/lib/Table/useTableQueryPagination.ts +0 -49
- package/src/lib/Table/useTableQuerySorting.ts +0 -52
- package/src/lib/Tabs/RouteTabs.tsx +0 -54
- package/src/lib/Tabs/TabPanel.tsx +0 -42
- package/src/lib/TemplateContent/ExpressionDecorator.tsx +0 -7
- package/src/lib/TemplateContent/TemplateContentEditor.tsx +0 -144
- package/src/utils/common.ts +0 -68
- package/src/utils/dem.ts +0 -78
- package/src/utils/hooks.ts +0 -41
- package/src/utils/ui-utils.tsx +0 -71
- package/src/utils/validators.ts +0 -130
- package/tsconfig.json +0 -24
- package/tsconfig.lib.json +0 -22
- package/tsconfig.spec.json +0 -19
@@ -1,131 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
2
|
-
import Button from '@material-ui/core/Button';
|
3
|
-
import Typography from '@material-ui/core/Typography';
|
4
|
-
import Accordion from '@material-ui/core/Accordion';
|
5
|
-
import AccordionSummary from '@material-ui/core/AccordionSummary';
|
6
|
-
import AccordionDetails from '@material-ui/core/AccordionDetails';
|
7
|
-
import AccordionActions from '@material-ui/core/AccordionActions';
|
8
|
-
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
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';
|
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: '',
|
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({ control, name: fieldName, rules: { required: required && 'Please, add properties' } });
|
58
|
-
const properties = useWatch({ control, name: fieldName });
|
59
|
-
|
60
|
-
const refs = useRef([]);
|
61
|
-
|
62
|
-
useEffect(() => {
|
63
|
-
if (typeof focusOnIndex === 'number' && refs.current[focusOnIndex]) {
|
64
|
-
refs.current[focusOnIndex].scrollIntoView({
|
65
|
-
behavior: 'smooth',
|
66
|
-
block: 'start',
|
67
|
-
});
|
68
|
-
}
|
69
|
-
}, [focusOnIndex, refs]);
|
70
|
-
|
71
|
-
const handleAddParameter = useCallback(() => {
|
72
|
-
if (properties) {
|
73
|
-
setValue(`${fieldName}.${properties.length}`, defaultPropertyValues);
|
74
|
-
} else {
|
75
|
-
setValue(fieldName, [defaultPropertyValues]);
|
76
|
-
}
|
77
|
-
clearErrors(fieldName);
|
78
|
-
}, [properties, fieldName]);
|
79
|
-
|
80
|
-
const handleRemoveParameter = useCallback(
|
81
|
-
(index) => {
|
82
|
-
setValue(`${fieldName}`, removeArrayItem(properties, index));
|
83
|
-
},
|
84
|
-
[properties, fieldName]
|
85
|
-
);
|
86
|
-
|
87
|
-
return (
|
88
|
-
<>
|
89
|
-
{error && error.message && (
|
90
|
-
<Grid item sm={12} md={8} lg={6}>
|
91
|
-
<Typography color="secondary">{error.message}</Typography>
|
92
|
-
</Grid>
|
93
|
-
)}
|
94
|
-
{properties &&
|
95
|
-
properties.map((property, index) => (
|
96
|
-
<Grid item key={index} sm={12} md={8} lg={6} innerRef={(ref) => (refs.current[index] = ref)}>
|
97
|
-
<Accordion defaultExpanded elevation={3}>
|
98
|
-
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
99
|
-
<Typography color={error && error[index] ? 'secondary' : 'initial'} style={{ wordBreak: 'break-word' }}>
|
100
|
-
{property.name || `Property ${index + 1}`}
|
101
|
-
</Typography>
|
102
|
-
</AccordionSummary>
|
103
|
-
<AccordionDetails>
|
104
|
-
<CreatePropertyFormFields
|
105
|
-
propertyFieldName={`${fieldName}.${index}`}
|
106
|
-
entityDefinition={entityDefinition}
|
107
|
-
globalParameter={globalParameter}
|
108
|
-
customPropertyFields={customPropertyFields}
|
109
|
-
/>
|
110
|
-
</AccordionDetails>
|
111
|
-
<AccordionActions>
|
112
|
-
<Button variant="contained" size="small" color="secondary" onClick={() => handleRemoveParameter(index)}>
|
113
|
-
Remove
|
114
|
-
</Button>
|
115
|
-
</AccordionActions>
|
116
|
-
</Accordion>
|
117
|
-
</Grid>
|
118
|
-
))}
|
119
|
-
|
120
|
-
{!hideAddButton && (
|
121
|
-
<Grid item xs={12}>
|
122
|
-
<Button variant="contained" size="small" color="primary" onClick={handleAddParameter}>
|
123
|
-
Add property
|
124
|
-
</Button>
|
125
|
-
</Grid>
|
126
|
-
)}
|
127
|
-
</>
|
128
|
-
);
|
129
|
-
};
|
130
|
-
|
131
|
-
export default CreatePropertiesList;
|
@@ -1,147 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
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 CustomPropertyField from './CustomPropertyField';
|
12
|
-
|
13
|
-
import { useMemo } from 'react';
|
14
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
15
|
-
import useCustomFields from './useCustomFields';
|
16
|
-
|
17
|
-
import { CustomPropertyFieldProps, PropertyType } from '../../../interfaces';
|
18
|
-
|
19
|
-
type Props = {
|
20
|
-
propertyFieldName: string;
|
21
|
-
entityDefinition?: boolean;
|
22
|
-
globalParameter?: boolean;
|
23
|
-
customPropertyFields?: CustomPropertyFieldProps[];
|
24
|
-
};
|
25
|
-
|
26
|
-
const propertyTypes = Object.values(PropertyType)
|
27
|
-
.sort((a, b) => a.localeCompare(b))
|
28
|
-
.map((propType) => ({
|
29
|
-
value: propType,
|
30
|
-
label: propType
|
31
|
-
.replace('_', ' ')
|
32
|
-
.toLowerCase()
|
33
|
-
.replace(/(^\w)|([-\s]\w)/g, (c) => c.toUpperCase()),
|
34
|
-
}));
|
35
|
-
|
36
|
-
const CreatePropertyFormFields = ({
|
37
|
-
propertyFieldName,
|
38
|
-
entityDefinition = false,
|
39
|
-
globalParameter = false,
|
40
|
-
customPropertyFields = [],
|
41
|
-
}: Props) => {
|
42
|
-
const { control, setValue } = useFormContext();
|
43
|
-
const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
|
44
|
-
const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
|
45
|
-
const isRequired = useWatch({ control, name: `${propertyFieldName}.isRequired` });
|
46
|
-
|
47
|
-
const { customCheckboxes, customFields } = useCustomFields(customPropertyFields);
|
48
|
-
|
49
|
-
const valueLabel = useMemo(() => {
|
50
|
-
let label = globalParameter ? 'Value' : 'Default Value';
|
51
|
-
if (isMultiple) {
|
52
|
-
label += 's';
|
53
|
-
}
|
54
|
-
return label;
|
55
|
-
}, [globalParameter, isMultiple]);
|
56
|
-
|
57
|
-
const handlePropertyTypeChange = (fieldName, value) => {
|
58
|
-
const valueFieldName = `${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`;
|
59
|
-
if (isMultiple) {
|
60
|
-
setValue(valueFieldName, []);
|
61
|
-
} else {
|
62
|
-
setValue(valueFieldName, null);
|
63
|
-
}
|
64
|
-
setValue(fieldName, value);
|
65
|
-
};
|
66
|
-
|
67
|
-
return (
|
68
|
-
<Grid container direction="column" spacing={2}>
|
69
|
-
<Grid item>
|
70
|
-
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.key`} label="Key" />
|
71
|
-
</Grid>
|
72
|
-
<Grid item>
|
73
|
-
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.name`} label="Name" />
|
74
|
-
</Grid>
|
75
|
-
<Grid item>
|
76
|
-
<ControlAutocomplete
|
77
|
-
required
|
78
|
-
control={control}
|
79
|
-
name={`${propertyFieldName}.propertyType`}
|
80
|
-
label="Type"
|
81
|
-
options={propertyTypes}
|
82
|
-
onChange={handlePropertyTypeChange}
|
83
|
-
/>
|
84
|
-
</Grid>
|
85
|
-
<Grid item>
|
86
|
-
<ControlNumberInput required control={control} name={`${propertyFieldName}.sortOrder`} label="Sort Order" />
|
87
|
-
</Grid>
|
88
|
-
|
89
|
-
<Grid item>
|
90
|
-
<ControlAceEditor control={control} name={`${propertyFieldName}.uiSettings`} label="UI Settings" validateJson />
|
91
|
-
</Grid>
|
92
|
-
<Grid item>
|
93
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isMultiple`} label="Multiple" />
|
94
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isEnabled`} label="Enabled" />
|
95
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isRequired`} label="Required" />
|
96
|
-
{entityDefinition && (
|
97
|
-
<ControlCheckbox
|
98
|
-
control={control}
|
99
|
-
name={`${propertyFieldName}.isViewableInList`}
|
100
|
-
label="Is viewable in list"
|
101
|
-
/>
|
102
|
-
)}
|
103
|
-
{customCheckboxes.length ? (
|
104
|
-
<>
|
105
|
-
{customCheckboxes.map((field, index) => (
|
106
|
-
<ControlCheckbox
|
107
|
-
key={index}
|
108
|
-
control={control}
|
109
|
-
name={`${propertyFieldName}.${field.name}`}
|
110
|
-
label={field.label}
|
111
|
-
/>
|
112
|
-
))}
|
113
|
-
</>
|
114
|
-
) : null}
|
115
|
-
</Grid>
|
116
|
-
{propertyType && (
|
117
|
-
<>
|
118
|
-
<PropertyAdditionalFields
|
119
|
-
propertyType={typeof propertyType === 'string' ? propertyType : propertyType.value}
|
120
|
-
propertyFieldName={propertyFieldName}
|
121
|
-
globalParameter={globalParameter}
|
122
|
-
entityDefinition={entityDefinition}
|
123
|
-
/>
|
124
|
-
<Grid item>
|
125
|
-
<PropertyValueField
|
126
|
-
propertyFieldName={propertyFieldName}
|
127
|
-
name={`${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`}
|
128
|
-
label={valueLabel}
|
129
|
-
required={globalParameter ? isRequired : false}
|
130
|
-
/>
|
131
|
-
</Grid>
|
132
|
-
</>
|
133
|
-
)}
|
134
|
-
{customFields.length ? (
|
135
|
-
<>
|
136
|
-
{customFields.map((field, index) => (
|
137
|
-
<Grid item key={index}>
|
138
|
-
<CustomPropertyField {...field} propertyFieldName={propertyFieldName} />
|
139
|
-
</Grid>
|
140
|
-
))}
|
141
|
-
</>
|
142
|
-
) : null}
|
143
|
-
</Grid>
|
144
|
-
);
|
145
|
-
};
|
146
|
-
|
147
|
-
export default CreatePropertyFormFields;
|
@@ -1,40 +0,0 @@
|
|
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;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
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 item>
|
19
|
-
<ControlNumberInput
|
20
|
-
required
|
21
|
-
control={control}
|
22
|
-
defaultValue={2}
|
23
|
-
name={`${propertyFieldName}.precisionScale`}
|
24
|
-
label="Precision Scale"
|
25
|
-
/>
|
26
|
-
</Grid>
|
27
|
-
<Grid item>
|
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;
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
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 item>
|
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;
|
@@ -1,133 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
2
|
-
import Button from '@material-ui/core/Button';
|
3
|
-
import Typography from '@material-ui/core/Typography';
|
4
|
-
import Dialog from '@material-ui/core/Dialog';
|
5
|
-
import DialogTitle from '@material-ui/core/DialogTitle';
|
6
|
-
import DialogContent from '@material-ui/core/DialogContent';
|
7
|
-
import DialogActions from '@material-ui/core/DialogActions';
|
8
|
-
import Stepper from '@material-ui/core/Stepper';
|
9
|
-
import Step from '@material-ui/core/Step';
|
10
|
-
import StepLabel from '@material-ui/core/StepLabel';
|
11
|
-
import StepContent from '@material-ui/core/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';
|
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
|
-
|
48
|
-
const parentPropertyName = useWatch({ control, name: `${parentPropertyFieldName}.name` });
|
49
|
-
|
50
|
-
const { open: parametersModalOpen, onClose: onParametersModalClose, onOpen: onParametersModalOpen } = useToggle();
|
51
|
-
|
52
|
-
const [focusedProperty, setFocusedProperty] = useState(0);
|
53
|
-
|
54
|
-
const handleAddParameter = useCallback(() => {
|
55
|
-
if (properties) {
|
56
|
-
setValue(`${parentPropertyFieldName}.properties.${properties.length}`, defaultPropertyValues);
|
57
|
-
} else {
|
58
|
-
setValue(`${parentPropertyFieldName}.properties`, [defaultPropertyValues]);
|
59
|
-
}
|
60
|
-
}, [properties, parentPropertyFieldName, setValue]);
|
61
|
-
|
62
|
-
const handleStepperClick = (index) => setFocusedProperty(index);
|
63
|
-
|
64
|
-
const handleSubmitClick = async () => {
|
65
|
-
const isValid = await trigger(`${parentPropertyFieldName}.properties`);
|
66
|
-
if (isValid) {
|
67
|
-
onParametersModalClose();
|
68
|
-
}
|
69
|
-
};
|
70
|
-
|
71
|
-
return (
|
72
|
-
<>
|
73
|
-
<Grid item>
|
74
|
-
<Typography variant="h6">Properties</Typography>
|
75
|
-
</Grid>
|
76
|
-
<Grid item>
|
77
|
-
<EntityPropertiesShortView properties={properties} showName showType />
|
78
|
-
</Grid>
|
79
|
-
<Grid item>
|
80
|
-
<Button variant="contained" color="primary" onClick={onParametersModalOpen}>
|
81
|
-
Edit properties
|
82
|
-
</Button>
|
83
|
-
</Grid>
|
84
|
-
|
85
|
-
<Dialog disableEscapeKeyDown open={parametersModalOpen} onClose={handleSubmitClick} fullWidth maxWidth="md">
|
86
|
-
<DialogTitle>{parentPropertyName || 'Entity'} Properties</DialogTitle>
|
87
|
-
<DialogContent style={{ height: '500px', overflow: 'hidden' }}>
|
88
|
-
<Grid container direction="row" spacing={2} style={{ height: '100%' }}>
|
89
|
-
<Grid item xs={3} style={{ backgroundColor: '#f9f9f9' }}>
|
90
|
-
<Stepper nonLinear activeStep={focusedProperty} orientation="vertical" style={{ paddingLeft: '4px' }}>
|
91
|
-
{properties.map((property, index) => (
|
92
|
-
<Step key={index} onClick={() => handleStepperClick(index)} style={{ cursor: 'pointer' }}>
|
93
|
-
<StepLabel StepIconProps={{ icon: '' }} style={{ wordBreak: 'break-word' }}>
|
94
|
-
{property.name || '(no name)'}
|
95
|
-
</StepLabel>
|
96
|
-
<StepContent></StepContent>
|
97
|
-
</Step>
|
98
|
-
))}
|
99
|
-
</Stepper>
|
100
|
-
<Button variant="contained" size="small" color="primary" onClick={handleAddParameter}>
|
101
|
-
Add property
|
102
|
-
</Button>
|
103
|
-
</Grid>
|
104
|
-
<Grid
|
105
|
-
item
|
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
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
import Grid from '@material-ui/core/Grid';
|
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 item>
|
16
|
-
<ControlInput required control={control} name={`${propertyFieldName}.definitionCode`} label="Definition Code" />
|
17
|
-
</Grid>
|
18
|
-
<Grid item>
|
19
|
-
<ControlInput
|
20
|
-
required
|
21
|
-
control={control}
|
22
|
-
name={`${propertyFieldName}.definitionVersion`}
|
23
|
-
label="Definition Version"
|
24
|
-
/>
|
25
|
-
</Grid>
|
26
|
-
<Grid item>
|
27
|
-
<ControlInput
|
28
|
-
required
|
29
|
-
control={control}
|
30
|
-
name={`${propertyFieldName}.labelPropertyCode`}
|
31
|
-
label="Label Property Code"
|
32
|
-
/>
|
33
|
-
</Grid>
|
34
|
-
<Grid item>
|
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;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx
DELETED
@@ -1,52 +0,0 @@
|
|
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;
|