@evoke-platform/ui-components 1.0.0-dev.216 → 1.0.0-dev.218
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/LICENSE +1 -1
- package/colors.ts +1 -1
- package/dist/published/components/core/Accordion/Accordion.js +1 -1
- package/dist/published/components/core/Accordion/AccordionActions/AccordionActions.js +1 -1
- package/dist/published/components/core/Accordion/AccordionDetails/AccordionDetails.js +1 -1
- package/dist/published/components/core/Accordion/AccordionSummary/AccordionSummary.js +1 -1
- package/dist/published/components/core/Accordion/index.d.ts +2 -2
- package/dist/published/components/core/Accordion/index.js +2 -2
- package/dist/published/components/core/Alert/Alert.js +3 -3
- package/dist/published/components/core/AlertTitle/AlertTitle.js +1 -1
- package/dist/published/components/core/AppBar/AppBar.js +1 -1
- package/dist/published/components/core/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/published/components/core/Autocomplete/Autocomplete.js +2 -2
- package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
- package/dist/published/components/core/Avatar/Avatar.js +1 -1
- package/dist/published/components/core/Backdrop/Backdrop.js +1 -1
- package/dist/published/components/core/Badge/Badge.js +1 -1
- package/dist/published/components/core/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/published/components/core/Button/Button.js +1 -1
- package/dist/published/components/core/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/published/components/core/Card/Card.js +1 -1
- package/dist/published/components/core/Checkbox/Checkbox.js +1 -1
- package/dist/published/components/core/Chip/Chip.js +1 -1
- package/dist/published/components/core/CircularProgress/CircularProgress.js +1 -1
- package/dist/published/components/core/Collapse/Collapse.js +1 -1
- package/dist/published/components/core/DatePicker/DatePicker.js +3 -3
- package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -3
- package/dist/published/components/core/Dialog/Dialog.js +1 -1
- package/dist/published/components/core/Dialog/DialogActions/DialogActions.d.ts +2 -2
- package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +1 -1
- package/dist/published/components/core/Dialog/DialogContent/DialogContent.js +1 -1
- package/dist/published/components/core/Dialog/DialogContentText/DialogContentText.js +1 -1
- package/dist/published/components/core/Dialog/DialogTitle/DialogTitle.js +1 -1
- package/dist/published/components/core/Dialog/index.d.ts +2 -2
- package/dist/published/components/core/Dialog/index.js +2 -2
- package/dist/published/components/core/Divider/Divider.js +1 -1
- package/dist/published/components/core/Drawer/Drawer.js +1 -1
- package/dist/published/components/core/FieldError/FieldError.js +2 -2
- package/dist/published/components/core/FormElements/FormControl/FormControl.js +1 -1
- package/dist/published/components/core/FormElements/FormControlLabel/FormControlLabel.js +1 -1
- package/dist/published/components/core/FormElements/FormGroup/FormGroup.js +1 -1
- package/dist/published/components/core/FormElements/FormHelperText/FormHelperText.js +1 -1
- package/dist/published/components/core/FormElements/FormLabel/FormLabel.js +1 -1
- package/dist/published/components/core/FormElements/index.d.ts +3 -3
- package/dist/published/components/core/FormElements/index.js +3 -3
- package/dist/published/components/core/IconButton/IconButton.js +1 -1
- package/dist/published/components/core/LinearProgress/LinearProgress.js +1 -1
- package/dist/published/components/core/Link/Link.js +1 -1
- package/dist/published/components/core/List/List.js +1 -1
- package/dist/published/components/core/List/ListItem.js +1 -1
- package/dist/published/components/core/List/ListItemText/ListItemText.js +1 -1
- package/dist/published/components/core/LoadingButton/LoadingButton.js +1 -1
- package/dist/published/components/core/LocalizationProvider/LocalizationProvider.js +4 -4
- package/dist/published/components/core/Menu/Menu.js +1 -1
- package/dist/published/components/core/Menu/MenuItem/MenuItem.js +1 -1
- package/dist/published/components/core/Menu/index.d.ts +1 -1
- package/dist/published/components/core/Menu/index.js +1 -1
- package/dist/published/components/core/Paper/Paper.js +1 -1
- package/dist/published/components/core/Popover/Popover.js +1 -1
- package/dist/published/components/core/Popper/Popper.js +1 -1
- package/dist/published/components/core/RadioGroup/Radio.js +1 -1
- package/dist/published/components/core/RadioGroup/RadioGroup.js +1 -1
- package/dist/published/components/core/Select/Select.js +1 -1
- package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
- package/dist/published/components/core/Snackbar/Snackbar.d.ts +2 -2
- package/dist/published/components/core/Snackbar/Snackbar.js +1 -1
- package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +2 -2
- package/dist/published/components/core/Stepper/Step/Step.js +1 -1
- package/dist/published/components/core/Stepper/StepButton/StepButton.js +1 -1
- package/dist/published/components/core/Stepper/StepConnector/StepConnector.js +1 -1
- package/dist/published/components/core/Stepper/StepContent/StepContent.js +1 -1
- package/dist/published/components/core/Stepper/StepIcon/StepIcon.js +1 -1
- package/dist/published/components/core/Stepper/StepLabel/StepLabel.js +1 -1
- package/dist/published/components/core/Stepper/Stepper.js +1 -1
- package/dist/published/components/core/Stepper/index.d.ts +5 -5
- package/dist/published/components/core/Stepper/index.js +5 -5
- package/dist/published/components/core/Switch/Switch.js +1 -1
- package/dist/published/components/core/Table/Table.js +1 -1
- package/dist/published/components/core/Tabs/Tab/Tab.js +1 -1
- package/dist/published/components/core/Tabs/Tabs.js +1 -1
- package/dist/published/components/core/Tabs/index.d.ts +2 -2
- package/dist/published/components/core/Tabs/index.js +2 -2
- package/dist/published/components/core/TextField/TextField.js +1 -1
- package/dist/published/components/core/TextField/TextField.test.js +1 -1
- package/dist/published/components/core/ToggleButton/ToggleButton.js +1 -1
- package/dist/published/components/core/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
- package/dist/published/components/core/Tooltip/Tooltip.js +1 -1
- package/dist/published/components/core/Typography/index.js +1 -1
- package/dist/published/components/core/index.d.ts +23 -23
- package/dist/published/components/core/index.js +22 -22
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.d.ts +3 -3
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +1 -1
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.d.ts +2 -2
- package/dist/published/components/custom/BuilderGrid/ToolbarActions.d.ts +2 -2
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.d.ts +3 -3
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +2 -2
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.d.ts +1 -1
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +3 -3
- package/dist/published/components/custom/DataGrid/DataGrid.d.ts +1 -1
- package/dist/published/components/custom/DataGrid/DataGrid.js +4 -5
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +1 -1
- package/dist/published/components/custom/DataGrid/Toolbar.d.ts +1 -1
- package/dist/published/components/custom/DataGrid/Toolbar.js +3 -3
- package/dist/published/components/custom/ErrorComponent/ErrorComponent.d.ts +2 -2
- package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +2 -2
- package/dist/published/components/custom/Form/Common/Form.d.ts +38 -0
- package/dist/published/components/custom/Form/Common/Form.js +413 -0
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.d.ts +26 -0
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +79 -0
- package/dist/published/components/custom/Form/Common/index.d.ts +2 -0
- package/dist/published/components/custom/Form/Common/index.js +2 -0
- package/dist/published/components/custom/Form/FormComponents/ButtonComponent.d.ts +37 -0
- package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +150 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.d.ts +17 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +80 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.d.ts +23 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +154 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.d.ts +15 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +172 -0
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +41 -0
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +409 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +15 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +111 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +23 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +112 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.d.ts +20 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +229 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +34 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +150 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.d.ts +3 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +306 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +24 -0
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +126 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.d.ts +21 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +96 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.d.ts +15 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +158 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.d.ts +39 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +89 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.d.ts +12 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +369 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.d.ts +20 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +57 -0
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +26 -0
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +99 -0
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.d.ts +23 -0
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +115 -0
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.d.ts +20 -0
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +83 -0
- package/dist/published/components/custom/Form/FormComponents/index.d.ts +8 -0
- package/dist/published/components/custom/Form/FormComponents/index.js +8 -0
- package/dist/published/components/custom/Form/index.d.ts +3 -0
- package/dist/published/components/custom/Form/index.js +3 -0
- package/dist/published/components/custom/Form/types.d.ts +109 -0
- package/dist/published/components/custom/Form/types.js +1 -0
- package/dist/published/components/custom/Form/utils.d.ts +45 -0
- package/dist/published/components/custom/Form/utils.js +1036 -0
- package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +1 -1
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +1 -1
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +3 -3
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +4 -4
- package/dist/published/components/custom/FormField/FormField.d.ts +4 -4
- package/dist/published/components/custom/FormField/FormField.js +1 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +1 -1
- package/dist/published/components/custom/FormField/Select/Select.test.js +1 -1
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
- package/dist/published/components/custom/Menubar/Menubar.js +1 -1
- package/dist/published/components/custom/Menubar/Menubar.test.js +2 -2
- package/dist/published/components/custom/MultiSelect/MultiSelect.js +7 -7
- package/dist/published/components/custom/MultiSelect/SortableItem.js +2 -2
- package/dist/published/components/custom/RepeatableField/RepeatableField.js +4 -4
- package/dist/published/components/custom/index.d.ts +1 -0
- package/dist/published/components/custom/index.js +1 -0
- package/dist/published/components/custom/util.js +1 -1
- package/dist/published/components/layout/Box/Box.d.ts +2 -2
- package/dist/published/components/layout/Box/Box.js +1 -1
- package/dist/published/components/layout/Container/Container.js +1 -1
- package/dist/published/components/layout/Grid/Grid.js +1 -1
- package/dist/published/components/layout/Stack/Stack.js +1 -1
- package/dist/published/icons/custom/TrashCan.d.ts +1 -1
- package/dist/published/icons/custom/TrashCan.js +1 -1
- package/dist/published/icons/custom/index.d.ts +1 -1
- package/dist/published/icons/custom/index.js +1 -1
- package/dist/published/index.d.ts +3 -3
- package/dist/published/index.js +2 -2
- package/dist/published/stories/Accordion.stories.d.ts +1 -1
- package/dist/published/stories/Accordion.stories.js +2 -2
- package/dist/published/stories/Alert.stories.d.ts +1 -1
- package/dist/published/stories/AlertTitle.stories.d.ts +1 -1
- package/dist/published/stories/Appbar.stories.d.ts +1 -1
- package/dist/published/stories/Appbar.stories.js +2 -2
- package/dist/published/stories/Autocomplete.stories.d.ts +1 -1
- package/dist/published/stories/Autocomplete.stories.js +3 -3
- package/dist/published/stories/Avatar.stories.d.ts +1 -1
- package/dist/published/stories/Backdrop.stories.d.ts +1 -1
- package/dist/published/stories/Backdrop.stories.js +3 -3
- package/dist/published/stories/Badge.stories.d.ts +1 -1
- package/dist/published/stories/Badge.stories.js +1 -1
- package/dist/published/stories/Box.stories.d.ts +1 -1
- package/dist/published/stories/Breadcrumbs.stories.d.ts +1 -1
- package/dist/published/stories/Button.stories.d.ts +1 -1
- package/dist/published/stories/ButtonGroup.stories.d.ts +1 -1
- package/dist/published/stories/Card.stories.d.ts +1 -1
- package/dist/published/stories/Card.stories.js +1 -1
- package/dist/published/stories/Checkbox.stories.d.ts +1 -1
- package/dist/published/stories/Chip.stories.d.ts +1 -1
- package/dist/published/stories/CircularProgress.stories.d.ts +1 -1
- package/dist/published/stories/Collapse.stories.d.ts +1 -1
- package/dist/published/stories/Collapse.stories.js +1 -1
- package/dist/published/stories/Container.stories.d.ts +1 -1
- package/dist/published/stories/Container.stories.js +3 -3
- package/dist/published/stories/DataGrid.stories.d.ts +1 -1
- package/dist/published/stories/DataGrid.stories.js +1 -1
- package/dist/published/stories/DatePicker.stories.d.ts +1 -1
- package/dist/published/stories/Dialog.stories.d.ts +1 -1
- package/dist/published/stories/Dialog.stories.js +3 -3
- package/dist/published/stories/Divider.stories.d.ts +1 -1
- package/dist/published/stories/Drawer.stories.d.ts +1 -1
- package/dist/published/stories/Drawer.stories.js +4 -4
- package/dist/published/stories/FormControl.stories.d.ts +1 -1
- package/dist/published/stories/FormControl.stories.js +1 -1
- package/dist/published/stories/FormControlLabel.stories.d.ts +1 -1
- package/dist/published/stories/FormGroup.stories.d.ts +1 -1
- package/dist/published/stories/FormHelperText.stories.d.ts +1 -1
- package/dist/published/stories/FormLabel.stories.d.ts +1 -1
- package/dist/published/stories/FormLabel.stories.js +2 -2
- package/dist/published/stories/Grid.stories.d.ts +1 -1
- package/dist/published/stories/IconButton.stories.d.ts +1 -1
- package/dist/published/stories/IconButton.stories.js +1 -1
- package/dist/published/stories/LinearProgress.stories.d.ts +1 -1
- package/dist/published/stories/Link.stories.d.ts +1 -1
- package/dist/published/stories/List.stories.d.ts +1 -1
- package/dist/published/stories/List.stories.js +3 -3
- package/dist/published/stories/Menu.stories.d.ts +1 -1
- package/dist/published/stories/Menu.stories.js +3 -3
- package/dist/published/stories/MenuBar.stories.d.ts +1 -1
- package/dist/published/stories/MenuBar.stories.js +1 -1
- package/dist/published/stories/MultiSelect.stories.d.ts +1 -1
- package/dist/published/stories/MultiSelect.stories.js +1 -1
- package/dist/published/stories/Palette.stories.d.ts +1 -1
- package/dist/published/stories/Palette.stories.js +1 -1
- package/dist/published/stories/Paper.stories.d.ts +1 -1
- package/dist/published/stories/Paper.stories.js +1 -1
- package/dist/published/stories/RadioGroup.stories.d.ts +1 -1
- package/dist/published/stories/RadioGroup.stories.js +1 -1
- package/dist/published/stories/RepeatableField.stories.d.ts +1 -1
- package/dist/published/stories/RepeatableField.stories.js +1 -1
- package/dist/published/stories/Skeleton.stories.d.ts +1 -1
- package/dist/published/stories/Snackbar.stories.d.ts +1 -1
- package/dist/published/stories/Snackbar.stories.js +3 -3
- package/dist/published/stories/Stack.stories.d.ts +1 -1
- package/dist/published/stories/StaticDatePicker.stories.d.ts +1 -1
- package/dist/published/stories/Stepper.stories.d.ts +2 -2
- package/dist/published/stories/Stepper.stories.js +6 -6
- package/dist/published/stories/Switch.stories.d.ts +1 -1
- package/dist/published/stories/Table.stories.d.ts +1 -1
- package/dist/published/stories/Table.stories.js +1 -1
- package/dist/published/stories/Tabs.stories.d.ts +1 -1
- package/dist/published/stories/TextField.stories.d.ts +1 -1
- package/dist/published/stories/TimePicker.stories.d.ts +1 -1
- package/dist/published/stories/TimePicker.stories.js +1 -1
- package/dist/published/stories/TimePickerSelect.stories.d.ts +1 -1
- package/dist/published/stories/ToggleButton.stories.d.ts +1 -1
- package/dist/published/stories/ToggleButton.stories.js +3 -3
- package/dist/published/stories/Typography.stories.d.ts +1 -1
- package/dist/published/stories/Typography.stories.js +1 -1
- package/dist/published/styles/form-component.css +152 -0
- package/dist/published/theme/UIThemeProvider.d.ts +2 -2
- package/dist/published/theme/UIThemeProvider.js +1 -1
- package/dist/published/util/date.d.ts +1 -1
- package/dist/published/util/date.js +1 -1
- package/icons.ts +1 -1
- package/package.json +21 -7
@@ -0,0 +1,158 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import { useNotification, } from '@evoke-platform/context';
|
11
|
+
import { debounce, isEmpty, isObject } from 'lodash';
|
12
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
13
|
+
import { Skeleton } from '../../../../../core';
|
14
|
+
import { getMiddleObject, getPrefixedUrl, transformToWhere } from '../../../utils';
|
15
|
+
import { DropdownRepeatableFieldInput } from './DropdownRepeatableFieldInput';
|
16
|
+
export const DropdownRepeatableField = (props) => {
|
17
|
+
var _a;
|
18
|
+
const { id, property, criteria, instance, readOnly, apiServices, initialMiddleObjectInstances, middleObject, getMiddleObjectInstances, fieldHeight, } = props;
|
19
|
+
const [middleObjectInstances, setMiddleObjectInstances] = useState(initialMiddleObjectInstances);
|
20
|
+
const [endObject, setEndObject] = useState();
|
21
|
+
const [endObjectInstances, setEndObjectInstances] = useState([]);
|
22
|
+
const [viewLayout, setViewLayout] = useState();
|
23
|
+
const [loading, setLoading] = useState(false);
|
24
|
+
const [initialLoading, setInitialLoading] = useState(true);
|
25
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
26
|
+
const [snackbarError, setSnackbarError] = useState({
|
27
|
+
showAlert: false,
|
28
|
+
isError: true,
|
29
|
+
});
|
30
|
+
const [searchValue, setSearchValue] = useState('');
|
31
|
+
const { instanceChanges } = useNotification();
|
32
|
+
const fetchMiddleObjectInstances = () => __awaiter(void 0, void 0, void 0, function* () {
|
33
|
+
const newInstances = yield getMiddleObjectInstances();
|
34
|
+
setMiddleObjectInstances(newInstances);
|
35
|
+
});
|
36
|
+
const setDropDownSelections = (instances) => {
|
37
|
+
setSelectedOptions(instances
|
38
|
+
.filter((currInstance) => property.manyToManyPropertyId in currInstance)
|
39
|
+
.map((currInstance) => {
|
40
|
+
var _a;
|
41
|
+
return ({
|
42
|
+
label: (_a = currInstance[property.manyToManyPropertyId]) === null || _a === void 0 ? void 0 : _a.name,
|
43
|
+
endObjectId: currInstance[property.manyToManyPropertyId].id,
|
44
|
+
middleObjectId: currInstance.id,
|
45
|
+
});
|
46
|
+
})
|
47
|
+
.sort((instanceA, instanceB) => instanceA.label.localeCompare(instanceB.label)));
|
48
|
+
};
|
49
|
+
useEffect(() => {
|
50
|
+
var _a;
|
51
|
+
const endObjectProperty = (_a = middleObject === null || middleObject === void 0 ? void 0 : middleObject.properties) === null || _a === void 0 ? void 0 : _a.find((currProperty) => property.manyToManyPropertyId === currProperty.id);
|
52
|
+
if (endObjectProperty && endObjectProperty.objectId) {
|
53
|
+
apiServices.get(getPrefixedUrl(`/objects/${endObjectProperty.objectId}/effective`), { params: { filter: { fields: ['id', 'name', 'properties', 'viewLayout'] } } }, (error, effectiveObject) => {
|
54
|
+
var _a;
|
55
|
+
if (error) {
|
56
|
+
console.error(error);
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
// If there's no error then the effective object is defined.
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
61
|
+
const endObject = effectiveObject;
|
62
|
+
setEndObject(endObject);
|
63
|
+
if ((_a = endObject.viewLayout) === null || _a === void 0 ? void 0 : _a.dropdown) {
|
64
|
+
setViewLayout(endObject.viewLayout.dropdown);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
}, [middleObject, apiServices]);
|
70
|
+
useEffect(() => {
|
71
|
+
instanceChanges === null || instanceChanges === void 0 ? void 0 : instanceChanges.subscribe(middleObject.rootObjectId, () => {
|
72
|
+
fetchMiddleObjectInstances();
|
73
|
+
});
|
74
|
+
return () => instanceChanges === null || instanceChanges === void 0 ? void 0 : instanceChanges.unsubscribe(middleObject.rootObjectId);
|
75
|
+
}, [instanceChanges, fetchMiddleObjectInstances]);
|
76
|
+
const fetchEndObjectInstances = useCallback((searchedName) => {
|
77
|
+
var _a;
|
78
|
+
if (property.objectId && property.manyToManyPropertyId) {
|
79
|
+
setLoading(true);
|
80
|
+
const endObjectProperty = (_a = middleObject.properties) === null || _a === void 0 ? void 0 : _a.find((currProperty) => property.manyToManyPropertyId === currProperty.id);
|
81
|
+
if (endObjectProperty === null || endObjectProperty === void 0 ? void 0 : endObjectProperty.objectId) {
|
82
|
+
const filter = {
|
83
|
+
limit: 100,
|
84
|
+
order: 'name ASC',
|
85
|
+
};
|
86
|
+
let searchCriteria = criteria && !isEmpty(criteria) ? transformToWhere(criteria) : {};
|
87
|
+
if (searchedName === null || searchedName === void 0 ? void 0 : searchedName.length) {
|
88
|
+
const nameCriteria = transformToWhere({
|
89
|
+
name: {
|
90
|
+
like: searchedName,
|
91
|
+
options: 'i',
|
92
|
+
},
|
93
|
+
});
|
94
|
+
searchCriteria = !isEmpty(criteria)
|
95
|
+
? {
|
96
|
+
and: [searchCriteria, nameCriteria],
|
97
|
+
}
|
98
|
+
: nameCriteria;
|
99
|
+
}
|
100
|
+
filter.where = searchCriteria;
|
101
|
+
apiServices.get(getPrefixedUrl(`/objects/${endObjectProperty.objectId}/instances`), { params: { filter: JSON.stringify(filter) } }, (error, instances) => {
|
102
|
+
if (!error && instances) {
|
103
|
+
setEndObjectInstances(instances);
|
104
|
+
}
|
105
|
+
setInitialLoading(false);
|
106
|
+
setLoading(false);
|
107
|
+
});
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}, [property.objectId, property.manyToManyPropertyId, apiServices, middleObject]);
|
111
|
+
const debouncedEndObjectSearch = useCallback(debounce(fetchEndObjectInstances, 500), [fetchEndObjectInstances]);
|
112
|
+
useEffect(() => {
|
113
|
+
debouncedEndObjectSearch(searchValue);
|
114
|
+
return () => debouncedEndObjectSearch.cancel();
|
115
|
+
}, [searchValue, debouncedEndObjectSearch]);
|
116
|
+
useEffect(() => {
|
117
|
+
fetchEndObjectInstances();
|
118
|
+
}, [criteria, middleObject, property, fetchEndObjectInstances]);
|
119
|
+
const saveMiddleInstance = (endObjectId, endObjectName) => {
|
120
|
+
if (property.objectId) {
|
121
|
+
const middleObject = getMiddleObject(instance, property, endObjectId, endObjectName);
|
122
|
+
apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/actions`), { actionId: `_create`, input: middleObject }, (error, newInstance) => {
|
123
|
+
if (!error && newInstance && isObject(newInstance)) {
|
124
|
+
setMiddleObjectInstances((prevObjectInstances) => [
|
125
|
+
...prevObjectInstances,
|
126
|
+
newInstance,
|
127
|
+
]);
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
if (error) {
|
131
|
+
setSnackbarError({
|
132
|
+
showAlert: true,
|
133
|
+
message: 'An error occured while adding an instance',
|
134
|
+
isError: true,
|
135
|
+
});
|
136
|
+
setDropDownSelections(middleObjectInstances);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
};
|
142
|
+
const removeMiddleInstance = (instanceId) => {
|
143
|
+
apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/${instanceId}/actions`), { actionId: '_delete' }, (error, res) => {
|
144
|
+
if (!error) {
|
145
|
+
setMiddleObjectInstances((prevInstances) => prevInstances.filter((curr) => curr.id !== instanceId));
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
setDropDownSelections(middleObjectInstances);
|
149
|
+
setSnackbarError({
|
150
|
+
showAlert: true,
|
151
|
+
message: 'An error occurred while deleting the instance',
|
152
|
+
isError: true,
|
153
|
+
});
|
154
|
+
}
|
155
|
+
});
|
156
|
+
};
|
157
|
+
return initialLoading ? (React.createElement(Skeleton, null)) : (React.createElement(React.Fragment, null, middleObjectInstances && endObject && (React.createElement(DropdownRepeatableFieldInput, { id: id, property: property, readOnly: readOnly || !((_a = middleObject.actions) === null || _a === void 0 ? void 0 : _a.some((action) => action.id === '_create')), viewLayout: viewLayout, middleObjectInstances: middleObjectInstances, endObjectInstances: endObjectInstances !== null && endObjectInstances !== void 0 ? endObjectInstances : [], endObject: endObject, searchValue: searchValue, loading: loading, handleSaveMiddleInstance: saveMiddleInstance, handleRemoveMiddleInstance: removeMiddleInstance, setSearchValue: setSearchValue, setSnackbarError: setSnackbarError, snackbarError: snackbarError, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, setDropdownSelections: setDropDownSelections, fieldHeight: fieldHeight }))));
|
158
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { DropdownViewLayout, Obj, ObjectInstance, Property } from '@evoke-platform/context';
|
3
|
+
import { AutocompleteOption } from '../../../../../core';
|
4
|
+
declare type DropdownRepeatableFieldInputProps = {
|
5
|
+
id: string;
|
6
|
+
property: Property;
|
7
|
+
readOnly: boolean;
|
8
|
+
viewLayout?: DropdownViewLayout;
|
9
|
+
middleObjectInstances: ObjectInstance[];
|
10
|
+
endObjectInstances: ObjectInstance[];
|
11
|
+
endObject: Obj;
|
12
|
+
searchValue: string;
|
13
|
+
loading: boolean;
|
14
|
+
fieldHeight?: 'small' | 'medium';
|
15
|
+
handleSaveMiddleInstance: (endObjectId: string, endObjectName: string) => void;
|
16
|
+
handleRemoveMiddleInstance: (instanceId: string) => void;
|
17
|
+
setSearchValue: (value: string) => void;
|
18
|
+
setSelectedOptions: (selectedOptions: DropdownRepeatableFieldInputOption[]) => void;
|
19
|
+
selectedOptions: DropdownRepeatableFieldInputOption[];
|
20
|
+
setSnackbarError: (snackbarError: {
|
21
|
+
showAlert: boolean;
|
22
|
+
message?: string;
|
23
|
+
isError: boolean;
|
24
|
+
}) => void;
|
25
|
+
snackbarError: {
|
26
|
+
showAlert: boolean;
|
27
|
+
message?: string;
|
28
|
+
isError: boolean;
|
29
|
+
};
|
30
|
+
setDropdownSelections?: (middleObjectInstances: ObjectInstance[]) => void;
|
31
|
+
};
|
32
|
+
export declare type DropdownRepeatableFieldInputOption = AutocompleteOption & {
|
33
|
+
endObjectId: string;
|
34
|
+
middleObjectId?: string;
|
35
|
+
subLabel?: string;
|
36
|
+
hidden?: boolean;
|
37
|
+
};
|
38
|
+
export declare const DropdownRepeatableFieldInput: (props: DropdownRepeatableFieldInputProps) => JSX.Element;
|
39
|
+
export {};
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import Handlebars from 'handlebars';
|
2
|
+
import { difference, isEmpty, isObject } from 'lodash';
|
3
|
+
import React, { useEffect, useState } from 'react';
|
4
|
+
import { FormField } from '../../../..';
|
5
|
+
import { Snackbar, TextField, Typography } from '../../../../../core';
|
6
|
+
import { normalizeDates } from '../../../utils';
|
7
|
+
const isDropdownRepeatableFieldInputOption = (option) => isObject(option) && 'label' in option && 'endObjectId' in option;
|
8
|
+
export const DropdownRepeatableFieldInput = (props) => {
|
9
|
+
const { id, property, readOnly, viewLayout, middleObjectInstances, endObjectInstances, endObject, searchValue, loading, handleSaveMiddleInstance, handleRemoveMiddleInstance, setSearchValue, selectedOptions, setSnackbarError, snackbarError, setDropdownSelections, fieldHeight, } = props;
|
10
|
+
const [selectOptions, setSelectOptions] = useState([]);
|
11
|
+
useEffect(() => {
|
12
|
+
setDropdownSelections && setDropdownSelections(middleObjectInstances);
|
13
|
+
}, [middleObjectInstances]);
|
14
|
+
useEffect(() => {
|
15
|
+
var _a;
|
16
|
+
const manyToManyPropertyId = property.manyToManyPropertyId;
|
17
|
+
if (manyToManyPropertyId) {
|
18
|
+
const enums = endObjectInstances
|
19
|
+
.map((endObjectInstance) => {
|
20
|
+
const normalizedInstance = Object.assign({}, endObjectInstance);
|
21
|
+
normalizeDates([normalizedInstance], endObject);
|
22
|
+
return normalizedInstance;
|
23
|
+
})
|
24
|
+
.map((endObjectInstance) => ({
|
25
|
+
label: endObjectInstance.name,
|
26
|
+
subLabel: (viewLayout === null || viewLayout === void 0 ? void 0 : viewLayout.secondaryTextExpression)
|
27
|
+
? compileExpression(endObjectInstance, viewLayout.secondaryTextExpression)
|
28
|
+
: undefined,
|
29
|
+
endObjectId: endObjectInstance.id,
|
30
|
+
value: undefined,
|
31
|
+
}));
|
32
|
+
setSelectOptions((_a = [
|
33
|
+
...enums,
|
34
|
+
...selectedOptions
|
35
|
+
.filter((selectedOption) => !enums.find((availableOption) => availableOption.endObjectId === selectedOption.endObjectId))
|
36
|
+
.map((option) => (Object.assign(Object.assign({}, option), { hidden: true }))),
|
37
|
+
]) !== null && _a !== void 0 ? _a : []);
|
38
|
+
}
|
39
|
+
}, [endObjectInstances, viewLayout]);
|
40
|
+
const handleChange = (key, newSelectedOptions) => {
|
41
|
+
// Delete middle objects that have been removed
|
42
|
+
// Add middle objects that have been added
|
43
|
+
// You can only really add or remove one value at a time
|
44
|
+
const addedValues = difference(newSelectedOptions, selectedOptions);
|
45
|
+
if (!isEmpty(addedValues)) {
|
46
|
+
addedValues.forEach((newValue) => {
|
47
|
+
if (isDropdownRepeatableFieldInputOption(newValue) &&
|
48
|
+
property.relatedPropertyId &&
|
49
|
+
property.manyToManyPropertyId) {
|
50
|
+
handleSaveMiddleInstance(newValue.endObjectId, newValue.label);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
54
|
+
const removedValues = difference(selectedOptions, newSelectedOptions);
|
55
|
+
if (!isEmpty(removedValues)) {
|
56
|
+
removedValues.forEach((removedValue) => {
|
57
|
+
if (isObject(removedValue) && removedValue.middleObjectId) {
|
58
|
+
handleRemoveMiddleInstance(removedValue.middleObjectId);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
}
|
62
|
+
};
|
63
|
+
const compileExpression = (instance, expression) => {
|
64
|
+
const template = Handlebars.compile(expression);
|
65
|
+
return template(instance);
|
66
|
+
};
|
67
|
+
return (React.createElement(React.Fragment, null, !readOnly ? (property && (React.createElement(React.Fragment, null,
|
68
|
+
React.createElement(FormField, { id: id, property: Object.assign(Object.assign({}, property), { type: 'array',
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
70
|
+
enum: selectOptions }), onChange: handleChange, defaultValue: selectedOptions, isOptionEqualToValue: (option, value) => isDropdownRepeatableFieldInputOption(value) &&
|
71
|
+
isDropdownRepeatableFieldInputOption(option) &&
|
72
|
+
option.endObjectId === value.endObjectId, size: fieldHeight !== null && fieldHeight !== void 0 ? fieldHeight : 'medium', renderOption: (props, option) => {
|
73
|
+
return isObject(props) && isDropdownRepeatableFieldInputOption(option) ? (React.createElement("li", Object.assign({}, props, { key: option.endObjectId }),
|
74
|
+
React.createElement(Typography, null,
|
75
|
+
option.label,
|
76
|
+
React.createElement("br", null),
|
77
|
+
React.createElement(Typography, { variant: "caption", color: "#586069" }, option.subLabel ? option.subLabel : '')))) : null;
|
78
|
+
}, disableCloseOnSelect: true, additionalProps: {
|
79
|
+
filterOptions: (options) => {
|
80
|
+
return options.filter((option) => !option.hidden);
|
81
|
+
},
|
82
|
+
inputValue: searchValue,
|
83
|
+
renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { onChange: (event) => {
|
84
|
+
setSearchValue(event.target.value);
|
85
|
+
} }))),
|
86
|
+
loading: loading,
|
87
|
+
} }),
|
88
|
+
React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({ isError: snackbarError.isError, showAlert: false }), message: snackbarError.message, error: snackbarError.isError })))) : (React.createElement(Typography, null, selectedOptions && selectedOptions.map((option) => option.label).join(', ')))));
|
89
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { ApiServices, ObjectInstance, Property, UserAccount } from '@evoke-platform/context';
|
3
|
+
export declare type ObjectPropertyInputProps = {
|
4
|
+
property: Property;
|
5
|
+
instance: ObjectInstance;
|
6
|
+
canUpdateProperty: boolean;
|
7
|
+
apiServices: ApiServices;
|
8
|
+
queryAddresses?: unknown;
|
9
|
+
user?: UserAccount;
|
10
|
+
};
|
11
|
+
declare const RepeatableField: (props: ObjectPropertyInputProps) => JSX.Element;
|
12
|
+
export default RepeatableField;
|