@evoke-platform/ui-components 1.0.0-dev.226 → 1.0.0-dev.228
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/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/Alert/Alert.js +8 -9
- 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.js +33 -15
- package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
- package/dist/published/components/core/Avatar/Avatar.js +7 -4
- 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 +4 -16
- package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -15
- package/dist/published/components/core/Dialog/Dialog.js +1 -1
- package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +2 -13
- 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/Divider/Divider.js +1 -1
- package/dist/published/components/core/Drawer/Drawer.js +1 -1
- package/dist/published/components/core/FieldError/FieldError.js +1 -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/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 +3 -14
- 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/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 +11 -4
- package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
- package/dist/published/components/core/Snackbar/Snackbar.js +2 -2
- package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +3 -15
- 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/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/TextField/TextField.js +12 -6
- 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 +15 -2
- package/dist/published/components/core/Typography/index.js +1 -1
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +33 -29
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +1 -2
- package/dist/published/components/custom/BuilderGrid/EmptyContent.js +4 -5
- package/dist/published/components/custom/BuilderGrid/EmptyContentIllustration.js +6 -1
- package/dist/published/components/custom/BuilderGrid/ToolbarActions.js +3 -1
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +46 -27
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.test.js +12 -21
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +27 -34
- package/dist/published/components/custom/DataGrid/DataGrid.js +38 -33
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +3 -5
- package/dist/published/components/custom/DataGrid/Toolbar.js +3 -4
- package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +11 -1
- package/dist/published/components/custom/Form/Common/Form.js +106 -80
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +20 -11
- package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +9 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +10 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +24 -28
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +49 -64
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +109 -34
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +2 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +13 -25
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +30 -9
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +26 -31
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +5 -4
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +70 -22
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +93 -75
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +2 -2
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +17 -26
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +20 -24
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +22 -33
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +12 -9
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +105 -82
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +8 -6
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +55 -12
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +32 -30
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +12 -9
- package/dist/published/components/custom/Form/types.d.ts +5 -5
- package/dist/published/components/custom/Form/utils.js +611 -446
- package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +41 -54
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +7 -8
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +5 -14
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +10 -11
- package/dist/published/components/custom/FormField/FormField.js +10 -10
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +22 -30
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +8 -17
- package/dist/published/components/custom/FormField/Select/Select.js +5 -6
- package/dist/published/components/custom/FormField/Select/Select.test.js +18 -27
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
- package/dist/published/components/custom/HistoryLog/DisplayedProperty.js +12 -13
- package/dist/published/components/custom/HistoryLog/HistoryData.js +49 -45
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +5 -5
- package/dist/published/components/custom/HistoryLog/index.js +5 -6
- package/dist/published/components/custom/Menubar/Menubar.js +2 -2
- package/dist/published/components/custom/MultiSelect/MultiSelect.js +38 -50
- package/dist/published/components/custom/MultiSelect/SortableItem.js +1 -1
- package/dist/published/components/custom/RepeatableField/RepeatableField.js +14 -16
- package/dist/published/components/custom/UserAvatar/UserAvatar.js +12 -5
- package/dist/published/components/custom/util.js +1 -1
- 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/FileWithExtension.js +8 -4
- package/dist/published/icons/custom/Inherited.js +8 -6
- package/dist/published/icons/custom/Overrides.js +9 -7
- package/dist/published/icons/custom/TrashCan.js +10 -8
- package/dist/published/icons/custom/UploadCloud.js +9 -7
- package/dist/published/stories/Accordion.stories.js +2 -2
- package/dist/published/stories/Alert.stories.js +1 -1
- package/dist/published/stories/AlertTitle.stories.js +1 -1
- package/dist/published/stories/Autocomplete.stories.js +2 -2
- package/dist/published/stories/Avatar.stories.js +1 -1
- package/dist/published/stories/Backdrop.stories.js +1 -1
- package/dist/published/stories/Badge.stories.js +1 -1
- package/dist/published/stories/Box.stories.js +2 -2
- package/dist/published/stories/Breadcrumbs.stories.js +1 -1
- package/dist/published/stories/Button.stories.js +1 -1
- package/dist/published/stories/ButtonGroup.stories.js +1 -1
- package/dist/published/stories/Card.stories.js +1 -1
- package/dist/published/stories/Checkbox.stories.js +1 -1
- package/dist/published/stories/Chip.stories.js +1 -1
- package/dist/published/stories/CircularProgress.stories.js +1 -1
- package/dist/published/stories/Collapse.stories.js +1 -1
- package/dist/published/stories/Container.stories.js +1 -1
- package/dist/published/stories/CriteriaBuilder.stories.js +7 -3
- package/dist/published/stories/DataGrid.stories.js +3 -3
- package/dist/published/stories/DatePicker.stories.js +3 -14
- package/dist/published/stories/Dialog.stories.js +1 -1
- package/dist/published/stories/Divider.stories.js +1 -1
- package/dist/published/stories/Drawer.stories.js +2 -2
- package/dist/published/stories/FormControl.stories.js +1 -1
- package/dist/published/stories/FormControlLabel.stories.js +1 -1
- package/dist/published/stories/FormField.stories.js +3 -12
- package/dist/published/stories/FormGroup.stories.js +1 -1
- package/dist/published/stories/FormHelperText.stories.js +1 -1
- package/dist/published/stories/FormLabel.stories.js +1 -1
- package/dist/published/stories/Grid.stories.js +1 -1
- package/dist/published/stories/HistoryLog.stories.js +1 -1
- package/dist/published/stories/IconButton.stories.js +4 -4
- package/dist/published/stories/LinearProgress.stories.js +1 -1
- package/dist/published/stories/Link.stories.js +1 -1
- package/dist/published/stories/List.stories.js +2 -2
- package/dist/published/stories/Menu.stories.js +2 -2
- package/dist/published/stories/MenuBar.stories.js +1 -1
- package/dist/published/stories/MultiSelect.stories.js +3 -3
- package/dist/published/stories/Palette.stories.js +11 -11
- package/dist/published/stories/Paper.stories.js +1 -1
- package/dist/published/stories/RadioGroup.stories.js +1 -1
- package/dist/published/stories/RepeatableField.stories.js +6 -7
- package/dist/published/stories/RichTextViewer.stories.js +1 -1
- package/dist/published/stories/Skeleton.stories.js +1 -1
- package/dist/published/stories/Snackbar.stories.js +1 -1
- package/dist/published/stories/Stack.stories.js +1 -1
- package/dist/published/stories/StaticDatePicker.stories.js +3 -14
- package/dist/published/stories/Stepper.stories.js +3 -3
- package/dist/published/stories/Switch.stories.js +1 -1
- package/dist/published/stories/Table.stories.js +2 -2
- package/dist/published/stories/Tabs.stories.js +6 -17
- package/dist/published/stories/TextField.stories.js +1 -1
- package/dist/published/stories/TimePicker.stories.js +3 -14
- package/dist/published/stories/TimePickerSelect.stories.js +3 -14
- package/dist/published/stories/ToggleButton.stories.js +4 -4
- package/dist/published/theme/UIThemeProvider.js +1 -2
- package/package.json +1 -1
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import cleanDeep from 'clean-deep';
|
2
2
|
import Handlebars from 'handlebars';
|
3
|
-
import { cloneDeep, debounce, isEmpty, isNil
|
3
|
+
import { cloneDeep, debounce, isEmpty, isNil } from 'lodash';
|
4
4
|
import React, { useCallback, useEffect, useState } from 'react';
|
5
5
|
import { Close } from '../../../../../icons';
|
6
6
|
import { Autocomplete, Button, Dialog, IconButton, Link, Paper, TextField, Tooltip, Typography, } from '../../../../core';
|
@@ -8,7 +8,6 @@ import { Box } from '../../../../layout';
|
|
8
8
|
import { getPrefixedUrl, normalizeDates, transformToWhere } from '../../utils';
|
9
9
|
import { RelatedObjectInstance } from './RelatedObjectInstance';
|
10
10
|
export const ObjectPropertyInput = (props) => {
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
12
11
|
const { id, instance, property, apiServices, defaultPages, handleChangeObjectProperty, nestedFieldsView, canUpdateProperty, error, navigateTo, mode, displayOption, filter, defaultValueCriteria, sortBy, orderBy, setSnackbarError, isModal, user, viewLayout, } = props;
|
13
12
|
const [relatedObject, setRelatedObject] = useState();
|
14
13
|
const [openCreateDialog, setOpenCreateDialog] = useState(false);
|
@@ -20,14 +19,23 @@ export const ObjectPropertyInput = (props) => {
|
|
20
19
|
const [layout, setLayout] = useState();
|
21
20
|
const DEFAULT_CREATE_ACTION = '_create';
|
22
21
|
useEffect(() => {
|
23
|
-
var _a, _b;
|
24
22
|
if (relatedObject) {
|
25
23
|
let defaultViewLayout;
|
26
|
-
if (
|
27
|
-
defaultViewLayout =
|
24
|
+
if (relatedObject?.viewLayout?.dropdown && displayOption === 'dropdown') {
|
25
|
+
defaultViewLayout = {
|
26
|
+
id: 'default',
|
27
|
+
name: 'Default',
|
28
|
+
objectId: relatedObject.id,
|
29
|
+
...relatedObject.viewLayout.dropdown,
|
30
|
+
};
|
28
31
|
}
|
29
|
-
else if (
|
30
|
-
defaultViewLayout =
|
32
|
+
else if (relatedObject?.viewLayout?.table && displayOption === 'dialogBox') {
|
33
|
+
defaultViewLayout = {
|
34
|
+
id: 'default',
|
35
|
+
name: 'Default',
|
36
|
+
objectId: relatedObject.id,
|
37
|
+
...relatedObject.viewLayout.table,
|
38
|
+
};
|
31
39
|
}
|
32
40
|
if (viewLayout) {
|
33
41
|
apiServices
|
@@ -41,10 +49,9 @@ export const ObjectPropertyInput = (props) => {
|
|
41
49
|
}
|
42
50
|
}, [displayOption, relatedObject, viewLayout]);
|
43
51
|
useEffect(() => {
|
44
|
-
var _a;
|
45
52
|
if (!isEmpty(defaultValueCriteria) && !selectedInstance && !instance[property.id]) {
|
46
53
|
const updatedFilter = cleanDeep({
|
47
|
-
where: transformToWhere({ $and: [defaultValueCriteria,
|
54
|
+
where: transformToWhere({ $and: [defaultValueCriteria, filter?.where ?? {}] }),
|
48
55
|
order: orderBy && sortBy ? encodeURIComponent(sortBy + ' ' + orderBy) : undefined,
|
49
56
|
limit: 1,
|
50
57
|
});
|
@@ -57,7 +64,7 @@ export const ObjectPropertyInput = (props) => {
|
|
57
64
|
}
|
58
65
|
if (instances) {
|
59
66
|
setSelectedInstance(instances[0]);
|
60
|
-
handleChangeObjectProperty(property.id,
|
67
|
+
handleChangeObjectProperty(property.id, instances[0]);
|
61
68
|
}
|
62
69
|
setLoadingOptions(false);
|
63
70
|
});
|
@@ -141,7 +148,6 @@ export const ObjectPropertyInput = (props) => {
|
|
141
148
|
],
|
142
149
|
},
|
143
150
|
}, PaperComponent: ({ children }) => {
|
144
|
-
var _a;
|
145
151
|
return (React.createElement(Paper, { sx: {
|
146
152
|
borderRadius: '12px',
|
147
153
|
boxShadow: '0px 24px 48px 0px rgba(145, 158, 171, 0.2)',
|
@@ -163,7 +169,7 @@ export const ObjectPropertyInput = (props) => {
|
|
163
169
|
} },
|
164
170
|
children,
|
165
171
|
mode !== 'existingOnly' &&
|
166
|
-
|
172
|
+
relatedObject?.actions?.some((a) => a.id === DEFAULT_CREATE_ACTION) && (React.createElement(Button, { fullWidth: true, sx: {
|
167
173
|
justifyContent: 'flex-start',
|
168
174
|
pl: 2,
|
169
175
|
minHeight: '48px',
|
@@ -175,43 +181,46 @@ export const ObjectPropertyInput = (props) => {
|
|
175
181
|
setOpenCreateDialog(true);
|
176
182
|
}, color: 'inherit' }, "+ Add New"))));
|
177
183
|
}, sx: {
|
178
|
-
'& button.MuiButtonBase-root':
|
179
|
-
(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
+
'& button.MuiButtonBase-root': {
|
185
|
+
...(!loadingOptions &&
|
186
|
+
(instance?.[property.id]?.id || selectedInstance?.id)
|
187
|
+
? {
|
188
|
+
visibility: 'visible',
|
189
|
+
}
|
190
|
+
: {}),
|
191
|
+
},
|
184
192
|
}, noOptionsText: 'No options available', renderOption: (props, option) => {
|
185
|
-
return (React.createElement("li",
|
193
|
+
return (React.createElement("li", { ...props, key: option.id },
|
186
194
|
React.createElement(Box, null,
|
187
195
|
React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } }, option.label),
|
188
|
-
|
196
|
+
layout?.secondaryTextExpression ? (React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px', color: '#637381' } }, compileExpression(layout?.secondaryTextExpression, options.find((o) => o.id === option.value)))) : null)));
|
189
197
|
}, onOpen: () => {
|
190
|
-
|
191
|
-
if (((_a = instance === null || instance === void 0 ? void 0 : instance[property.id]) === null || _a === void 0 ? void 0 : _a.id) || (selectedInstance === null || selectedInstance === void 0 ? void 0 : selectedInstance.id)) {
|
198
|
+
if (instance?.[property.id]?.id || selectedInstance?.id) {
|
192
199
|
setOpenOptions(false);
|
193
200
|
}
|
194
201
|
else {
|
195
202
|
setOpenOptions(true);
|
196
203
|
}
|
197
|
-
}, onClose: () => setOpenOptions(false), value:
|
204
|
+
}, onClose: () => setOpenOptions(false), value: instance?.[property.id]?.id || selectedInstance?.id
|
198
205
|
? {
|
199
|
-
value:
|
200
|
-
|
206
|
+
value: instance?.[property.id]?.id ??
|
207
|
+
selectedInstance?.id ??
|
208
|
+
'',
|
209
|
+
label: instance?.[property.id]?.name ??
|
210
|
+
selectedInstance?.name ??
|
211
|
+
'',
|
201
212
|
}
|
202
213
|
: null, isOptionEqualToValue: (option, value) => {
|
203
214
|
if (typeof value === 'string') {
|
204
215
|
return option.value === value;
|
205
216
|
}
|
206
|
-
return option.value ===
|
217
|
+
return option.value === value?.value;
|
207
218
|
}, options: options.map((o) => ({ label: o.name, value: o.id })), getOptionLabel: (option) => {
|
208
|
-
var _a, _b;
|
209
219
|
return typeof option === 'string'
|
210
|
-
?
|
220
|
+
? options.find((o) => o.id === option)?.name ?? ''
|
211
221
|
: option.label;
|
212
222
|
}, onKeyDownCapture: (e) => {
|
213
|
-
|
214
|
-
if (((_a = instance === null || instance === void 0 ? void 0 : instance[property.id]) === null || _a === void 0 ? void 0 : _a.id) || (selectedInstance === null || selectedInstance === void 0 ? void 0 : selectedInstance.id)) {
|
223
|
+
if (instance?.[property.id]?.id || selectedInstance?.id) {
|
215
224
|
e.preventDefault();
|
216
225
|
}
|
217
226
|
}, loading: loadingOptions, onChange: (event, value) => {
|
@@ -221,46 +230,48 @@ export const ObjectPropertyInput = (props) => {
|
|
221
230
|
handleChangeObjectProperty(property.id, null);
|
222
231
|
}
|
223
232
|
else {
|
224
|
-
const selectedInstance = options.find((o) => o.id ===
|
233
|
+
const selectedInstance = options.find((o) => o.id === value?.value);
|
225
234
|
setSelectedInstance(selectedInstance);
|
226
|
-
handleChangeObjectProperty(property.id,
|
235
|
+
handleChangeObjectProperty(property.id, selectedInstance);
|
227
236
|
}
|
228
|
-
}, selectOnFocus: false, onBlur: () => setDropdownInput(undefined), renderInput: (params) => {
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
((
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
(
|
252
|
-
|
237
|
+
}, selectOnFocus: false, onBlur: () => setDropdownInput(undefined), renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', readOnly: !loadingOptions &&
|
238
|
+
!!(instance?.[property.id]?.id ||
|
239
|
+
selectedInstance?.id), onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
|
240
|
+
if (navigationSlug &&
|
241
|
+
['DIV', 'INPUT'].includes(e.target?.nodeName) &&
|
242
|
+
(instance?.[property.id]?.id ||
|
243
|
+
selectedInstance?.id)) {
|
244
|
+
navigateTo &&
|
245
|
+
navigateTo(navigationSlug.replace(':instanceId', instance?.[property.id]?.id ??
|
246
|
+
selectedInstance?.id ??
|
247
|
+
''));
|
248
|
+
}
|
249
|
+
if (openOptions &&
|
250
|
+
e.target?.nodeName === 'svg') {
|
251
|
+
setOpenOptions(false);
|
252
|
+
}
|
253
|
+
else if (!['DIV', 'INPUT'].includes(e.target?.nodeName) &&
|
254
|
+
!selectedInstance) {
|
255
|
+
setOptions(options);
|
256
|
+
setOpenOptions(true);
|
257
|
+
}
|
258
|
+
}, sx: {
|
259
|
+
...(!loadingOptions &&
|
260
|
+
(instance?.[property.id]?.id ||
|
261
|
+
selectedInstance?.id)
|
253
262
|
? {
|
254
263
|
'.MuiOutlinedInput-root': {
|
255
264
|
background: 'white',
|
256
265
|
border: 'auto',
|
257
|
-
'.MuiOutlinedInput-input':
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
266
|
+
'.MuiOutlinedInput-input': {
|
267
|
+
...(navigationSlug
|
268
|
+
? {
|
269
|
+
color: 'rgb(1, 78, 123)',
|
270
|
+
textDecoration: 'underline',
|
271
|
+
cursor: 'pointer',
|
272
|
+
}
|
273
|
+
: {}),
|
274
|
+
},
|
264
275
|
},
|
265
276
|
'& fieldset': { borderColor: 'auto' },
|
266
277
|
'&:hover .MuiOutlinedInput-notchedOutline': {
|
@@ -268,27 +279,34 @@ export const ObjectPropertyInput = (props) => {
|
|
268
279
|
},
|
269
280
|
caretColor: 'white',
|
270
281
|
}
|
271
|
-
: {})
|
272
|
-
|
273
|
-
padding: (
|
282
|
+
: {}),
|
283
|
+
} })), readOnly: !loadingOptions && !canUpdateProperty, error: error }))) : (React.createElement(Box, { sx: {
|
284
|
+
padding: (instance?.[property.id]?.name ?? selectedInstance?.name)
|
274
285
|
? '16.5px 14px'
|
275
286
|
: '10.5px 0',
|
276
287
|
} },
|
277
|
-
(
|
288
|
+
(instance?.[property.id]?.name ??
|
289
|
+
selectedInstance?.name ??
|
290
|
+
'') && (React.createElement(Link, { sx: {
|
278
291
|
textDecoration: 'none',
|
279
292
|
marginRight: 1,
|
280
|
-
textDecorationLine: navigationSlug &&
|
281
|
-
cursor: navigationSlug &&
|
293
|
+
textDecorationLine: navigationSlug && instance?.[property.id] && !isModal ? 'underline' : 'none',
|
294
|
+
cursor: navigationSlug && instance?.[property.id] && !isModal ? 'pointer' : 'auto',
|
282
295
|
fontSize: '16px',
|
283
296
|
fontWeight: 400,
|
284
297
|
lineHeight: '24px',
|
285
298
|
textAlign: 'left',
|
286
|
-
color: navigationSlug &&
|
287
|
-
}, variant: "body2", href: navigationSlug &&
|
288
|
-
? `${process.env.REACT_APP_API_ROOT ? '' : '/app'}${navigationSlug.replace(':instanceId',
|
289
|
-
|
299
|
+
color: navigationSlug && instance?.[property.id] && !isModal ? '#0075A7' : '#212B36',
|
300
|
+
}, variant: "body2", href: navigationSlug && instance?.[property.id] && !isModal
|
301
|
+
? `${process.env.REACT_APP_API_ROOT ? '' : '/app'}${navigationSlug.replace(':instanceId', instance?.[property.id]?.id ??
|
302
|
+
selectedInstance?.id ??
|
303
|
+
'')}`
|
304
|
+
: undefined, "aria-label": instance?.[property.id]?.name ??
|
305
|
+
selectedInstance?.name }, instance?.[property.id]?.name ??
|
306
|
+
selectedInstance?.name ??
|
307
|
+
'')),
|
290
308
|
canUpdateProperty &&
|
291
|
-
(
|
309
|
+
(instance?.[property.id] || selectedInstance || (nestedFieldsView && instance?.id)) ? (React.createElement(Tooltip, { title: `Unlink` },
|
292
310
|
React.createElement("span", null,
|
293
311
|
React.createElement(IconButton, { onClick: (event) => {
|
294
312
|
event.stopPropagation();
|
@@ -1,11 +1,11 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { ApiServices, Obj, ObjectInstance, Property,
|
2
|
+
import { ApiServices, Obj, ObjectInstance, Property, TableViewLayout, UserAccount } from '@evoke-platform/context';
|
3
3
|
export declare type RelatedObjectInstanceProps = {
|
4
4
|
relatedObject?: Obj;
|
5
5
|
property: Property;
|
6
6
|
apiServices: ApiServices;
|
7
7
|
setSelectedInstance: (selectedInstance: ObjectInstance) => void;
|
8
|
-
handleChangeObjectProperty: (propertyId: string, instance?:
|
8
|
+
handleChangeObjectProperty: (propertyId: string, instance?: ObjectInstance | null) => void;
|
9
9
|
instance: ObjectInstance;
|
10
10
|
handleClose: () => void;
|
11
11
|
mode: 'default' | 'existingOnly';
|
@@ -1,15 +1,6 @@
|
|
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
1
|
import { useAuthenticationContext, } from '@evoke-platform/context';
|
11
2
|
import { LocalDateTime } from '@js-joda/core';
|
12
|
-
import { isObject
|
3
|
+
import { isObject } from 'lodash';
|
13
4
|
import React, { useState } from 'react';
|
14
5
|
import { InfoRounded } from '../../../../../icons';
|
15
6
|
import { Alert, Button, FormControlLabel, Radio, RadioGroup } from '../../../../core';
|
@@ -29,30 +20,28 @@ const styles = {
|
|
29
20
|
};
|
30
21
|
const DEFAULT_CREATE_ACTION = '_create';
|
31
22
|
export const RelatedObjectInstance = (props) => {
|
32
|
-
var _a;
|
33
23
|
const { relatedObject, property, setSelectedInstance, handleChangeObjectProperty, handleClose, apiServices, setSnackbarError, nestedFieldsView, mode, displayOption, setOptions, options, filter, user, layout, } = props;
|
34
24
|
const [relationType, setRelationType] = useState(displayOption === 'dropdown' ? 'new' : 'existing');
|
35
25
|
const [selectedRow, setSelectedRow] = useState();
|
36
26
|
const [errors, setErrors] = useState([]);
|
37
|
-
const userAccount = user
|
38
|
-
const linkExistingInstance = () =>
|
27
|
+
const userAccount = user ?? useAuthenticationContext()?.account;
|
28
|
+
const linkExistingInstance = async () => {
|
39
29
|
if (selectedRow) {
|
40
30
|
setSelectedInstance(selectedRow);
|
41
|
-
handleChangeObjectProperty(property.id,
|
31
|
+
handleChangeObjectProperty(property.id, selectedRow);
|
42
32
|
}
|
43
33
|
onClose();
|
44
|
-
}
|
45
|
-
const queryAddresses = (query) =>
|
46
|
-
return
|
34
|
+
};
|
35
|
+
const queryAddresses = async (query) => {
|
36
|
+
return await apiServices.get(getPrefixedUrl(`/locations/search`), {
|
47
37
|
params: { query: query },
|
48
38
|
});
|
49
|
-
}
|
39
|
+
};
|
50
40
|
const onClose = () => {
|
51
41
|
handleClose();
|
52
42
|
setErrors([]);
|
53
43
|
};
|
54
|
-
const createNewInstance = (submission) =>
|
55
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
44
|
+
const createNewInstance = async (submission) => {
|
56
45
|
if (!relatedObject) {
|
57
46
|
// Handle the case where relatedObject is undefined
|
58
47
|
return { isSuccessful: false };
|
@@ -67,11 +56,11 @@ export const RelatedObjectInstance = (props) => {
|
|
67
56
|
}), {});
|
68
57
|
}
|
69
58
|
try {
|
70
|
-
const instance =
|
59
|
+
const instance = await apiServices.post(getPrefixedUrl(`/objects/${relatedObject.id}/instances/actions`), {
|
71
60
|
actionId: DEFAULT_CREATE_ACTION,
|
72
61
|
input: submission,
|
73
62
|
});
|
74
|
-
handleChangeObjectProperty(property.id,
|
63
|
+
handleChangeObjectProperty(property.id, instance);
|
75
64
|
setSelectedInstance(instance);
|
76
65
|
setSnackbarError && setSnackbarError({ showAlert: true, message: 'New instance created', isError: false });
|
77
66
|
normalizeDates([instance]);
|
@@ -84,14 +73,16 @@ export const RelatedObjectInstance = (props) => {
|
|
84
73
|
setSnackbarError &&
|
85
74
|
setSnackbarError({
|
86
75
|
showAlert: true,
|
87
|
-
message:
|
76
|
+
message: err.response?.data?.error?.details?.[0]?.message ??
|
77
|
+
err.data?.error?.message ??
|
78
|
+
`An error occurred. The new instance was not created.`,
|
88
79
|
isError: true,
|
89
80
|
});
|
90
|
-
error =
|
81
|
+
error = err.response?.data?.error;
|
91
82
|
onClose();
|
92
83
|
}
|
93
84
|
return { isSuccessful, error };
|
94
|
-
}
|
85
|
+
};
|
95
86
|
return (React.createElement(Box, { sx: { background: nestedFieldsView ? '#F4F6F8' : 'none', borderRadius: '8px' } },
|
96
87
|
React.createElement(Box, { sx: { padding: '8px 24px 20px', '.MuiInputBase-root': { background: '#FFFF', borderRadius: '8px' } } },
|
97
88
|
!nestedFieldsView && displayOption !== 'dropdown' && mode !== 'existingOnly' && (React.createElement(Grid, { container: true },
|
@@ -102,7 +93,7 @@ export const RelatedObjectInstance = (props) => {
|
|
102
93
|
}, value: relationType },
|
103
94
|
React.createElement(FormControlLabel, { value: "existing", control: React.createElement(Radio, null), label: "Existing" }),
|
104
95
|
React.createElement(FormControlLabel, { value: "new", control: React.createElement(Radio, null), label: "New" }))))),
|
105
|
-
|
96
|
+
errors?.length ? (React.createElement(Alert, { severity: "error", sx: { margin: '10px 0', borderRadius: '8px' }, icon: React.createElement(InfoRounded, { sx: { color: '#A22723' } }) }, errors.length === 1 ? (React.createElement(React.Fragment, null,
|
106
97
|
"There is ",
|
107
98
|
React.createElement("strong", null, "1"),
|
108
99
|
" error")) : (React.createElement(React.Fragment, null,
|
@@ -1,12 +1,3 @@
|
|
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
1
|
import { concat } from 'lodash';
|
11
2
|
import React, { useEffect, useState } from 'react';
|
12
3
|
import { Close } from '../../../../../icons';
|
@@ -56,8 +47,7 @@ export const ActionDialog = (props) => {
|
|
56
47
|
apiServices.get(getPrefixedUrl(`/objects/${object.id}/instances/${instanceId}/checkAccess`), {
|
57
48
|
params: { action: 'execute', field: action.id },
|
58
49
|
}, (error, result) => {
|
59
|
-
|
60
|
-
setHasAccess((_a = result === null || result === void 0 ? void 0 : result.result) !== null && _a !== void 0 ? _a : false);
|
50
|
+
setHasAccess(result?.result ?? false);
|
61
51
|
setLoading(false);
|
62
52
|
});
|
63
53
|
}
|
@@ -67,29 +57,35 @@ export const ActionDialog = (props) => {
|
|
67
57
|
}
|
68
58
|
}, [object, instanceId]);
|
69
59
|
useEffect(() => {
|
70
|
-
|
71
|
-
|
72
|
-
? (_c = (((_b = action.form) === null || _b === void 0 ? void 0 : _b.entries) && action.parameters
|
60
|
+
const input = (action?.form?.entries && action.parameters) || action?.inputProperties
|
61
|
+
? (action.form?.entries && action.parameters
|
73
62
|
? convertFormToComponents(action.form.entries, action.parameters, object)
|
74
|
-
: action
|
63
|
+
: action?.inputProperties)?.filter((inputProperty) => inputProperty?.key !== relatedProperty?.relatedPropertyId)
|
75
64
|
: undefined;
|
76
|
-
const updatedAction =
|
77
|
-
|
78
|
-
|
65
|
+
const updatedAction = {
|
66
|
+
...action,
|
67
|
+
form: input ? { entries: convertComponentsToForm(input) } : undefined,
|
68
|
+
};
|
69
|
+
const properties = object?.properties?.filter((prop) => prop?.id !== relatedProperty?.relatedPropertyId);
|
70
|
+
setUpdatedObject({
|
71
|
+
...object,
|
72
|
+
properties,
|
73
|
+
actions: concat(object?.actions?.filter((a) => a?.id !== action.id) ?? [], [updatedAction]),
|
74
|
+
});
|
79
75
|
}, [object]);
|
80
76
|
return (React.createElement(Dialog, { maxWidth: 'md', fullWidth: true, open: open, onClose: (e, reason) => reason !== 'backdropClick' && onClose },
|
81
77
|
React.createElement(DialogTitle, { sx: styles.dialogTitle },
|
82
78
|
React.createElement(IconButton, { sx: styles.closeIcon, onClick: onClose },
|
83
79
|
React.createElement(Close, { fontSize: "small" })),
|
84
|
-
action && hasAccess && !loading ? action
|
85
|
-
React.createElement(DialogContent, null, hasAccess ? (React.createElement(Box, { sx: { width: '100%', marginTop: '10px' } },
|
80
|
+
action && hasAccess && !loading ? action?.name : ''),
|
81
|
+
React.createElement(DialogContent, null, hasAccess ? (React.createElement(Box, { sx: { width: '100%', marginTop: '10px' } }, action?.type === 'delete' ? (React.createElement(React.Fragment, null,
|
86
82
|
React.createElement(Typography, null,
|
87
|
-
"Are you sure you want to delete this ",
|
88
|
-
object
|
83
|
+
"Are you sure you want to delete this ",
|
84
|
+
object?.name,
|
89
85
|
"?"),
|
90
86
|
React.createElement(Box, { sx: { padding: '25ox 0 10px 0', display: 'flex', justifyContent: 'flex-end' } },
|
91
|
-
React.createElement(Button, { sx:
|
92
|
-
React.createElement(LoadingButton, { sx:
|
87
|
+
React.createElement(Button, { sx: { ...styles.button, ...styles.cancelBtn }, onClick: onClose }, "Cancel"),
|
88
|
+
React.createElement(LoadingButton, { sx: { ...styles.button, ...styles.deleteBtn }, onClick: () => handleSubmit('delete', undefined, instanceId, setSubmitting), loading: submitting }, "Delete")))) : (updatedObject && (React.createElement(Form, { actionId: action.id, actionType: action.type, apiServices: objectInputCommonProps.apiServices, object: updatedObject, instance: instanceInput, onSave: async (data, setSubmitting) => handleSubmit(action.type, data, instanceId, setSubmitting), objectInputCommonProps: objectInputCommonProps, closeModal: onClose, queryAddresses: queryAddresses, user: user }))))) : (React.createElement(React.Fragment, null, loading ? (React.createElement(React.Fragment, null,
|
93
89
|
React.createElement(Skeleton, { height: '30px', animation: 'wave' }),
|
94
90
|
React.createElement(Skeleton, { height: '30px', animation: 'wave' }),
|
95
91
|
React.createElement(Skeleton, { height: '30px', animation: 'wave' }))) : (React.createElement(ErrorComponent, { code: 'AccessDenied', message: 'You do not have permission to perform this action.', styles: { boxShadow: 'none' } })))))));
|
@@ -1,12 +1,3 @@
|
|
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
1
|
import { useNotification, } from '@evoke-platform/context';
|
11
2
|
import { debounce, isEmpty, isObject } from 'lodash';
|
12
3
|
import React, { useCallback, useEffect, useState } from 'react';
|
@@ -14,7 +5,6 @@ import { Skeleton } from '../../../../../core';
|
|
14
5
|
import { getMiddleObject, getPrefixedUrl, transformToWhere } from '../../../utils';
|
15
6
|
import { DropdownRepeatableFieldInput } from './DropdownRepeatableFieldInput';
|
16
7
|
export const DropdownRepeatableField = (props) => {
|
17
|
-
var _a;
|
18
8
|
const { id, property, criteria, instance, readOnly, apiServices, initialMiddleObjectInstances, middleObject, getMiddleObjectInstances, fieldHeight, viewLayout, } = props;
|
19
9
|
const [middleObjectInstances, setMiddleObjectInstances] = useState(initialMiddleObjectInstances);
|
20
10
|
const [endObject, setEndObject] = useState();
|
@@ -29,29 +19,24 @@ export const DropdownRepeatableField = (props) => {
|
|
29
19
|
});
|
30
20
|
const [searchValue, setSearchValue] = useState('');
|
31
21
|
const { instanceChanges } = useNotification();
|
32
|
-
const fetchMiddleObjectInstances = () =>
|
33
|
-
const newInstances =
|
22
|
+
const fetchMiddleObjectInstances = async () => {
|
23
|
+
const newInstances = await getMiddleObjectInstances();
|
34
24
|
setMiddleObjectInstances(newInstances);
|
35
|
-
}
|
25
|
+
};
|
36
26
|
const setDropDownSelections = (instances) => {
|
37
27
|
setSelectedOptions(instances
|
38
28
|
.filter((currInstance) => property.manyToManyPropertyId in currInstance)
|
39
|
-
.map((currInstance) => {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
middleObjectId: currInstance.id,
|
45
|
-
});
|
46
|
-
})
|
29
|
+
.map((currInstance) => ({
|
30
|
+
label: currInstance[property.manyToManyPropertyId]?.name,
|
31
|
+
endObjectId: currInstance[property.manyToManyPropertyId].id,
|
32
|
+
middleObjectId: currInstance.id,
|
33
|
+
}))
|
47
34
|
.sort((instanceA, instanceB) => instanceA.label.localeCompare(instanceB.label)));
|
48
35
|
};
|
49
36
|
useEffect(() => {
|
50
|
-
|
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);
|
37
|
+
const endObjectProperty = middleObject?.properties?.find((currProperty) => property.manyToManyPropertyId === currProperty.id);
|
52
38
|
if (endObjectProperty && endObjectProperty.objectId) {
|
53
39
|
apiServices.get(getPrefixedUrl(`/objects/${endObjectProperty.objectId}/effective`), { params: { filter: { fields: ['id', 'name', 'properties', 'viewLayout'] } } }, (error, effectiveObject) => {
|
54
|
-
var _a;
|
55
40
|
if (error) {
|
56
41
|
console.error(error);
|
57
42
|
}
|
@@ -61,8 +46,13 @@ export const DropdownRepeatableField = (props) => {
|
|
61
46
|
const endObject = effectiveObject;
|
62
47
|
setEndObject(endObject);
|
63
48
|
let defaultLayout;
|
64
|
-
if (
|
65
|
-
defaultLayout =
|
49
|
+
if (endObject.viewLayout?.dropdown) {
|
50
|
+
defaultLayout = {
|
51
|
+
id: 'default',
|
52
|
+
name: 'Default',
|
53
|
+
objectId: endObject.id,
|
54
|
+
...endObject.viewLayout.dropdown,
|
55
|
+
};
|
66
56
|
}
|
67
57
|
if (viewLayout) {
|
68
58
|
apiServices
|
@@ -78,23 +68,22 @@ export const DropdownRepeatableField = (props) => {
|
|
78
68
|
}
|
79
69
|
}, [middleObject, apiServices, viewLayout, property]);
|
80
70
|
useEffect(() => {
|
81
|
-
instanceChanges
|
71
|
+
instanceChanges?.subscribe(middleObject.rootObjectId, () => {
|
82
72
|
fetchMiddleObjectInstances();
|
83
73
|
});
|
84
|
-
return () => instanceChanges
|
74
|
+
return () => instanceChanges?.unsubscribe(middleObject.rootObjectId);
|
85
75
|
}, [instanceChanges, fetchMiddleObjectInstances]);
|
86
76
|
const fetchEndObjectInstances = useCallback((searchedName) => {
|
87
|
-
var _a;
|
88
77
|
if (property.objectId && property.manyToManyPropertyId) {
|
89
78
|
setLoading(true);
|
90
|
-
const endObjectProperty =
|
91
|
-
if (endObjectProperty
|
79
|
+
const endObjectProperty = middleObject.properties?.find((currProperty) => property.manyToManyPropertyId === currProperty.id);
|
80
|
+
if (endObjectProperty?.objectId) {
|
92
81
|
const filter = {
|
93
82
|
limit: 100,
|
94
83
|
order: 'name ASC',
|
95
84
|
};
|
96
85
|
let searchCriteria = criteria && !isEmpty(criteria) ? transformToWhere(criteria) : {};
|
97
|
-
if (searchedName
|
86
|
+
if (searchedName?.length) {
|
98
87
|
const nameCriteria = transformToWhere({
|
99
88
|
name: {
|
100
89
|
like: searchedName,
|
@@ -164,5 +153,5 @@ export const DropdownRepeatableField = (props) => {
|
|
164
153
|
}
|
165
154
|
});
|
166
155
|
};
|
167
|
-
return initialLoading ? (React.createElement(Skeleton, null)) : (React.createElement(React.Fragment, null, middleObjectInstances && endObject && (React.createElement(DropdownRepeatableFieldInput, { id: id, property: property, readOnly: readOnly || !
|
156
|
+
return initialLoading ? (React.createElement(Skeleton, null)) : (React.createElement(React.Fragment, null, middleObjectInstances && endObject && (React.createElement(DropdownRepeatableFieldInput, { id: id, property: property, readOnly: readOnly || !middleObject.actions?.some((action) => action.id === '_create'), layout: layout, middleObjectInstances: middleObjectInstances, endObjectInstances: 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 }))));
|
168
157
|
};
|