@evoke-platform/ui-components 1.0.0-dev.226 → 1.0.0-dev.227
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 +61 -60
- 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
@@ -16,13 +16,13 @@ export const DropdownRepeatableFieldInput = (props) => {
|
|
16
16
|
if (manyToManyPropertyId) {
|
17
17
|
const enums = endObjectInstances
|
18
18
|
.map((endObjectInstance) => {
|
19
|
-
const normalizedInstance =
|
19
|
+
const normalizedInstance = { ...endObjectInstance };
|
20
20
|
normalizeDates([normalizedInstance], endObject);
|
21
21
|
return normalizedInstance;
|
22
22
|
})
|
23
23
|
.map((endObjectInstance) => ({
|
24
24
|
label: endObjectInstance.name,
|
25
|
-
subLabel:
|
25
|
+
subLabel: layout?.secondaryTextExpression
|
26
26
|
? compileExpression(endObjectInstance, layout.secondaryTextExpression)
|
27
27
|
: undefined,
|
28
28
|
endObjectId: endObjectInstance.id,
|
@@ -32,7 +32,7 @@ export const DropdownRepeatableFieldInput = (props) => {
|
|
32
32
|
...enums,
|
33
33
|
...selectedOptions
|
34
34
|
.filter((selectedOption) => !enums.find((availableOption) => availableOption.endObjectId === selectedOption.endObjectId))
|
35
|
-
.map((option) => (
|
35
|
+
.map((option) => ({ ...option, hidden: true })),
|
36
36
|
]);
|
37
37
|
}
|
38
38
|
}, [endObjectInstances, layout]);
|
@@ -64,12 +64,15 @@ export const DropdownRepeatableFieldInput = (props) => {
|
|
64
64
|
return template(instance);
|
65
65
|
};
|
66
66
|
return (React.createElement(React.Fragment, null, !readOnly ? (property && (React.createElement(React.Fragment, null,
|
67
|
-
React.createElement(FormField, { id: id, property:
|
67
|
+
React.createElement(FormField, { id: id, property: {
|
68
|
+
...property,
|
69
|
+
type: 'array',
|
68
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
69
|
-
enum: selectOptions
|
71
|
+
enum: selectOptions,
|
72
|
+
}, onChange: handleChange, defaultValue: selectedOptions, isOptionEqualToValue: (option, value) => isDropdownRepeatableFieldInputOption(value) &&
|
70
73
|
isDropdownRepeatableFieldInputOption(option) &&
|
71
|
-
option.endObjectId === value.endObjectId, size: fieldHeight
|
72
|
-
return isObject(props) && isDropdownRepeatableFieldInputOption(option) ? (React.createElement("li",
|
74
|
+
option.endObjectId === value.endObjectId, size: fieldHeight ?? 'medium', renderOption: (props, option) => {
|
75
|
+
return isObject(props) && isDropdownRepeatableFieldInputOption(option) ? (React.createElement("li", { ...props, key: option.endObjectId },
|
73
76
|
React.createElement(Typography, null,
|
74
77
|
option.label,
|
75
78
|
React.createElement("br", null),
|
@@ -79,9 +82,9 @@ export const DropdownRepeatableFieldInput = (props) => {
|
|
79
82
|
return options.filter((option) => !option.hidden);
|
80
83
|
},
|
81
84
|
inputValue: searchValue,
|
82
|
-
renderInput: (params) => (React.createElement(TextField,
|
85
|
+
renderInput: (params) => (React.createElement(TextField, { ...params, onChange: (event) => {
|
83
86
|
setSearchValue(event.target.value);
|
84
|
-
} }))
|
87
|
+
} })),
|
85
88
|
loading: loading,
|
86
89
|
} }),
|
87
90
|
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(', ')))));
|
@@ -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 { LocalDateTime } from '@js-joda/core';
|
12
3
|
import { get, isObject, pick, startCase } from 'lodash';
|
@@ -40,7 +31,6 @@ const styles = {
|
|
40
31
|
},
|
41
32
|
};
|
42
33
|
const RepeatableField = (props) => {
|
43
|
-
var _a, _b;
|
44
34
|
const { property, instance, canUpdateProperty, apiServices, queryAddresses, user, viewLayout } = props;
|
45
35
|
const [relatedInstances, setRelatedInstances] = useState([]);
|
46
36
|
const [relatedObject, setRelatedObject] = useState();
|
@@ -59,17 +49,21 @@ const RepeatableField = (props) => {
|
|
59
49
|
const [error, setError] = useState(false);
|
60
50
|
const DEFAULT_CREATE_ACTION = '_create';
|
61
51
|
const { instanceChanges } = useNotification();
|
62
|
-
const fetchRelatedInstances = useCallback(() =>
|
63
|
-
var _c;
|
52
|
+
const fetchRelatedInstances = useCallback(async () => {
|
64
53
|
if (openDialog)
|
65
54
|
return;
|
66
55
|
let relatedObject;
|
67
56
|
if (property.objectId) {
|
68
57
|
try {
|
69
|
-
relatedObject =
|
58
|
+
relatedObject = await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective`));
|
70
59
|
let defaultTableViewLayout;
|
71
|
-
if (
|
72
|
-
defaultTableViewLayout =
|
60
|
+
if (relatedObject.viewLayout?.table) {
|
61
|
+
defaultTableViewLayout = {
|
62
|
+
id: 'default',
|
63
|
+
name: 'Default',
|
64
|
+
objectId: relatedObject.id,
|
65
|
+
...relatedObject?.viewLayout.table,
|
66
|
+
};
|
73
67
|
}
|
74
68
|
if (viewLayout) {
|
75
69
|
apiServices
|
@@ -85,16 +79,16 @@ const RepeatableField = (props) => {
|
|
85
79
|
catch (err) {
|
86
80
|
console.error(error);
|
87
81
|
}
|
88
|
-
if (property.relatedPropertyId &&
|
82
|
+
if (property.relatedPropertyId && instance?.id) {
|
89
83
|
const filterProperty = `${property.relatedPropertyId}.id`;
|
90
|
-
const filter = { where: { [filterProperty]: instance
|
84
|
+
const filter = { where: { [filterProperty]: instance?.id }, limit: 100 };
|
91
85
|
const objectId = property.objectId;
|
92
86
|
try {
|
93
87
|
const timeout = setTimeout(() => {
|
94
88
|
setLoading(false);
|
95
89
|
}, 300);
|
96
90
|
setLoading(true);
|
97
|
-
const instances =
|
91
|
+
const instances = await apiServices.get(getPrefixedUrl(`/objects/${objectId}/instances`), {
|
98
92
|
params: { filter: JSON.stringify(filter) },
|
99
93
|
});
|
100
94
|
clearTimeout(timeout);
|
@@ -109,7 +103,7 @@ const RepeatableField = (props) => {
|
|
109
103
|
}
|
110
104
|
}
|
111
105
|
relatedObject && checkCreateAccess(relatedObject);
|
112
|
-
}
|
106
|
+
}, [apiServices, property, viewLayout]);
|
113
107
|
const checkCreateAccess = (relatedObject) => {
|
114
108
|
if (property.objectId && canUpdateProperty) {
|
115
109
|
apiServices
|
@@ -117,22 +111,21 @@ const RepeatableField = (props) => {
|
|
117
111
|
params: { action: 'execute', field: '_create', scope: 'data' },
|
118
112
|
})
|
119
113
|
.then((checkAccess) => {
|
120
|
-
|
121
|
-
const action = (_a = relatedObject.actions) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === '_create');
|
114
|
+
const action = relatedObject.actions?.find((item) => item.id === '_create');
|
122
115
|
if (action) {
|
123
116
|
let relatedObjectProperty;
|
124
117
|
let validationCriteria;
|
125
118
|
if (action.parameters) {
|
126
119
|
relatedObjectProperty = action.parameters.find((param) => param.id === property.relatedPropertyId);
|
127
|
-
validationCriteria =
|
120
|
+
validationCriteria = relatedObjectProperty?.validation?.criteria;
|
128
121
|
}
|
129
122
|
else if (action.inputProperties) {
|
130
123
|
relatedObjectProperty = action.inputProperties.find((inputProp) => inputProp.key === property.relatedPropertyId);
|
131
|
-
validationCriteria =
|
124
|
+
validationCriteria = relatedObjectProperty?.validate?.criteria;
|
132
125
|
}
|
133
126
|
else {
|
134
|
-
relatedObjectProperty = (
|
135
|
-
validationCriteria =
|
127
|
+
relatedObjectProperty = (relatedObject.properties ?? []).find((prop) => prop.id === property.relatedPropertyId);
|
128
|
+
validationCriteria = relatedObjectProperty?.validation?.criteria;
|
136
129
|
}
|
137
130
|
if (relatedObjectProperty) {
|
138
131
|
if (validationCriteria) {
|
@@ -156,24 +149,24 @@ const RepeatableField = (props) => {
|
|
156
149
|
}
|
157
150
|
};
|
158
151
|
useEffect(() => {
|
159
|
-
(() =>
|
152
|
+
(async () => {
|
160
153
|
try {
|
161
|
-
const users =
|
154
|
+
const users = await apiServices.get(getPrefixedUrl(`/users`));
|
162
155
|
setUsers(users);
|
163
156
|
}
|
164
157
|
catch (error) {
|
165
158
|
console.error(error);
|
166
159
|
}
|
167
|
-
})
|
160
|
+
})();
|
168
161
|
}, [apiServices]);
|
169
162
|
useEffect(() => {
|
170
163
|
fetchRelatedInstances();
|
171
164
|
}, [fetchRelatedInstances, reloadOnErrorTrigger, instance]);
|
172
165
|
useEffect(() => {
|
173
|
-
if (relatedObject
|
166
|
+
if (relatedObject?.rootObjectId) {
|
174
167
|
const callback = () => fetchRelatedInstances();
|
175
|
-
instanceChanges
|
176
|
-
return () => instanceChanges
|
168
|
+
instanceChanges?.subscribe(relatedObject?.rootObjectId, callback);
|
169
|
+
return () => instanceChanges?.unsubscribe(relatedObject?.rootObjectId, callback);
|
177
170
|
}
|
178
171
|
}, [instanceChanges, relatedObject]);
|
179
172
|
const deleteRow = (id) => {
|
@@ -207,8 +200,7 @@ const RepeatableField = (props) => {
|
|
207
200
|
},
|
208
201
|
'min-width': '44px',
|
209
202
|
}, variant: "text", onClick: () => setReloadOnErrorTrigger((prevState) => !prevState) }, "Retry")));
|
210
|
-
const save = (actionType, input, instanceId, setSubmitting) =>
|
211
|
-
var _d, _e, _f, _g, _h, _j;
|
203
|
+
const save = async (actionType, input, instanceId, setSubmitting) => {
|
212
204
|
setSubmitting && setSubmitting(true);
|
213
205
|
// date-time fields are stored in the database in ISO format so convert all
|
214
206
|
// LocalDateTime objects to ISO format.
|
@@ -220,13 +212,13 @@ const RepeatableField = (props) => {
|
|
220
212
|
let isSuccessful = false;
|
221
213
|
let error;
|
222
214
|
if (actionType === 'create') {
|
223
|
-
const updatedInput =
|
215
|
+
const updatedInput = { ...input, [property?.relatedPropertyId]: { id: instance?.id } };
|
224
216
|
try {
|
225
|
-
const instance =
|
217
|
+
const instance = await apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/actions`), {
|
226
218
|
actionId: DEFAULT_CREATE_ACTION,
|
227
219
|
input: updatedInput,
|
228
220
|
});
|
229
|
-
const hasAccess =
|
221
|
+
const hasAccess = property?.relatedPropertyId && property.relatedPropertyId in instance;
|
230
222
|
hasAccess && setRelatedInstances([...relatedInstances, instance]);
|
231
223
|
setSubmitting && setSubmitting(false);
|
232
224
|
// clear out dialog
|
@@ -242,23 +234,25 @@ const RepeatableField = (props) => {
|
|
242
234
|
isError: true,
|
243
235
|
});
|
244
236
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
245
|
-
error =
|
237
|
+
error = err.response?.data?.error;
|
246
238
|
setSubmitting && setSubmitting(false);
|
247
239
|
}
|
248
240
|
}
|
249
241
|
else {
|
250
|
-
const relatedObjectId = relatedObject
|
242
|
+
const relatedObjectId = relatedObject?.id;
|
251
243
|
try {
|
252
|
-
|
244
|
+
await apiServices.post(getPrefixedUrl(`/objects/${relatedObjectId}/instances/${instanceId}/actions`), {
|
253
245
|
actionId: `_${actionType}`,
|
254
|
-
input: pick(input,
|
246
|
+
input: pick(input, relatedObject?.properties
|
247
|
+
?.filter((property) => !property.formula && property.type !== 'collection')
|
248
|
+
.map((property) => property.id) ?? []),
|
255
249
|
});
|
256
250
|
if (actionType === 'delete') {
|
257
251
|
setRelatedInstances((prevInstances) => prevInstances.filter((instance) => instance.id !== instanceId));
|
258
252
|
setSubmitting && setSubmitting(false);
|
259
253
|
}
|
260
254
|
else {
|
261
|
-
setRelatedInstances((prevInstances) => prevInstances.map((i) => (i.id ===
|
255
|
+
setRelatedInstances((prevInstances) => prevInstances.map((i) => (i.id === instance?.id ? instance : i)));
|
262
256
|
setSubmitting && setSubmitting(false);
|
263
257
|
}
|
264
258
|
// clear out dialog
|
@@ -274,27 +268,30 @@ const RepeatableField = (props) => {
|
|
274
268
|
isError: true,
|
275
269
|
});
|
276
270
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
277
|
-
error =
|
271
|
+
error = err.response?.data?.error;
|
278
272
|
}
|
279
273
|
}
|
280
274
|
return { isSuccessful, error };
|
281
|
-
}
|
275
|
+
};
|
282
276
|
const retrieveViewLayout = () => {
|
283
|
-
var _a, _b, _c, _d;
|
284
277
|
let properties = [];
|
285
|
-
if (
|
278
|
+
if (tableViewLayout?.properties?.length) {
|
286
279
|
for (const prop of tableViewLayout.properties) {
|
287
280
|
const propertyId = prop.id.split('.')[0];
|
288
|
-
const property =
|
281
|
+
const property = relatedObject?.properties?.find((p) => p.id === propertyId);
|
289
282
|
if (property) {
|
290
283
|
if ((property.type === 'object' && property.id !== property.relatedPropertyId) ||
|
291
284
|
property.type === 'address' ||
|
292
285
|
property.type === 'user') {
|
293
|
-
properties.push(
|
286
|
+
properties.push({
|
287
|
+
...property,
|
288
|
+
id: ['user', 'object'].includes(property.type) && !prop.id.endsWith('.name')
|
294
289
|
? `${prop.id}.name`
|
295
|
-
: prop.id,
|
290
|
+
: prop.id,
|
291
|
+
name: property.type === 'address'
|
296
292
|
? `${property.name} - ${startCase(prop.id.split('.')[1])}`
|
297
|
-
: property.name
|
293
|
+
: property.name,
|
294
|
+
});
|
298
295
|
}
|
299
296
|
else {
|
300
297
|
properties.push(property);
|
@@ -304,7 +301,12 @@ const RepeatableField = (props) => {
|
|
304
301
|
}
|
305
302
|
else {
|
306
303
|
properties =
|
307
|
-
|
304
|
+
relatedObject?.properties
|
305
|
+
?.filter((prop) => !['address', 'image', 'collection'].includes(prop.type))
|
306
|
+
.map((prop) => ({
|
307
|
+
...prop,
|
308
|
+
id: prop.type === 'object' || prop.type === 'user' ? `${prop.id}.name` : prop.id,
|
309
|
+
})) ?? [];
|
308
310
|
}
|
309
311
|
return properties;
|
310
312
|
};
|
@@ -342,7 +344,7 @@ const RepeatableField = (props) => {
|
|
342
344
|
React.createElement(Skeleton, null),
|
343
345
|
React.createElement(Skeleton, null))) : (React.createElement(React.Fragment, null,
|
344
346
|
React.createElement(Box, { sx: { padding: '10px 0' } },
|
345
|
-
!
|
347
|
+
!relatedInstances?.length ? (!error ? (React.createElement(Typography, { sx: { color: 'rgb(114 124 132)', fontSize: '14px' } }, "No items added")) : (React.createElement(ErrorComponent, null))) : (React.createElement(TableContainer, { sx: {
|
346
348
|
borderRadius: '6px',
|
347
349
|
border: '1px solid #919EAB3D',
|
348
350
|
boxShadow: 'none',
|
@@ -350,12 +352,11 @@ const RepeatableField = (props) => {
|
|
350
352
|
} },
|
351
353
|
React.createElement(Table, { stickyHeader: true, sx: { minWidth: 650 } },
|
352
354
|
React.createElement(TableHead, { sx: { backgroundColor: '#F4F6F8' } },
|
353
|
-
React.createElement(TableRow, null,
|
354
|
-
columns
|
355
|
-
React.createElement(TableCell, { sx:
|
356
|
-
React.createElement(TableBody, null, relatedInstances
|
357
|
-
columns
|
358
|
-
var _a;
|
355
|
+
React.createElement(TableRow, null,
|
356
|
+
columns?.map((prop) => React.createElement(TableCell, { sx: styles.tableCell }, prop.name)),
|
357
|
+
React.createElement(TableCell, { sx: { ...styles.tableCell, width: '80px' } }))),
|
358
|
+
React.createElement(TableBody, null, relatedInstances?.map((relatedInstance, index) => (React.createElement(TableRow, { key: relatedInstance.id },
|
359
|
+
columns?.map((prop) => {
|
359
360
|
return (React.createElement(TableCell, { sx: { color: '#212B36', fontSize: '16px' } },
|
360
361
|
React.createElement(Typography, { key: prop.id, sx: prop.id === 'name'
|
361
362
|
? {
|
@@ -369,7 +370,7 @@ const RepeatableField = (props) => {
|
|
369
370
|
: undefined },
|
370
371
|
getValue(relatedInstance, prop.id, prop.type),
|
371
372
|
prop.type === 'user' &&
|
372
|
-
|
373
|
+
users?.find((user) => get(relatedInstance, `${prop.id.split('.')[0]}.id`) === user.id)?.status === 'Inactive' && React.createElement("span", null, ' (Inactive)'))));
|
373
374
|
}),
|
374
375
|
canUpdateProperty && (React.createElement(TableCell, { sx: { width: '80px' } },
|
375
376
|
React.createElement(IconButton, { "aria-label": `edit-collection-instance-${index}`, onClick: () => editRow(relatedInstance.id) },
|
@@ -379,9 +380,9 @@ const RepeatableField = (props) => {
|
|
379
380
|
React.createElement(Tooltip, { title: "Delete" },
|
380
381
|
React.createElement(TrashCan, { sx: { ':hover': { color: '#A12723' } } })))))))))))),
|
381
382
|
hasCreateAction && (React.createElement(Button, { variant: "contained", sx: styles.addButton, onClick: addRow }, "Add"))),
|
382
|
-
relatedObject && openDialog && (React.createElement(ActionDialog, { object: relatedObject, open: openDialog, apiServices: apiServices, onClose: () => setOpenDialog(false), instanceInput: dialogType === 'update' ?
|
383
|
+
relatedObject && openDialog && (React.createElement(ActionDialog, { object: relatedObject, open: openDialog, apiServices: apiServices, onClose: () => setOpenDialog(false), instanceInput: dialogType === 'update' ? relatedInstances.find((i) => i.id === selectedRow) ?? {} : {}, handleSubmit: save,
|
383
384
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
384
|
-
objectInputCommonProps: { apiServices }, action:
|
385
|
+
objectInputCommonProps: { apiServices }, action: relatedObject?.actions?.find((a) => a.id ===
|
385
386
|
(dialogType === 'create' ? '_create' : dialogType === 'update' ? '_update' : '_delete')), instanceId: selectedRow, relatedProperty: property, queryAddresses: queryAddresses, user: user })),
|
386
387
|
React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({ isError: snackbarError.isError, showAlert: false }), message: snackbarError.message, error: snackbarError.isError })));
|
387
388
|
};
|
@@ -12,11 +12,14 @@ const apiBaseUrl = process.env.REACT_APP_API_ROOT || `${window.location.origin}/
|
|
12
12
|
export class RepeatableFieldComponent extends ReactComponent {
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
14
14
|
constructor(component, options, data) {
|
15
|
-
|
16
|
-
|
15
|
+
super({
|
16
|
+
...component,
|
17
|
+
canUpdateProperty: !component.readOnly,
|
18
|
+
hideLabel: true,
|
19
|
+
}, options, data);
|
17
20
|
this.errorDetails = {};
|
18
21
|
this.criteria = component.validate.criteria;
|
19
|
-
this.updatedCriteria =
|
22
|
+
this.updatedCriteria = cloneDeep(component.validate.criteria) ?? {};
|
20
23
|
}
|
21
24
|
init() {
|
22
25
|
if (this.criteria) {
|
@@ -33,9 +36,8 @@ export class RepeatableFieldComponent extends ReactComponent {
|
|
33
36
|
compKey = inputProp;
|
34
37
|
}
|
35
38
|
this.on(`changed-${compKey}`, () => {
|
36
|
-
var _a;
|
37
39
|
const data = dot.dot(this.root._data);
|
38
|
-
this.updatedCriteria =
|
40
|
+
this.updatedCriteria = cloneDeep(this.criteria) ?? {};
|
39
41
|
for (const inputProp of inputProps) {
|
40
42
|
updateCriteriaInputs(this.updatedCriteria, inputProp, data[inputProp], true);
|
41
43
|
}
|
@@ -49,7 +51,7 @@ export class RepeatableFieldComponent extends ReactComponent {
|
|
49
51
|
const inputId = `${this.component.id}-input`;
|
50
52
|
return ReactDOM.render(React.createElement("div", null, !this.component.hidden ? (React.createElement(ApiBaseUrlProvider, { url: apiBaseUrl },
|
51
53
|
React.createElement(NotificationProvider, null,
|
52
|
-
React.createElement(FormComponentWrapper,
|
54
|
+
React.createElement(FormComponentWrapper, { ...this.component, inputId: inputId, viewOnly: !this.component.canUpdateProperty }, this.component.property.manyToManyPropertyId ? (React.createElement(DropdownRepeatableField, { id: inputId, property: this.component.property, instance: this.component.instance, apiServices: this.component.apiServices, criteria: this.updatedCriteria, readOnly: !this.component.canUpdateProperty, initialMiddleObjectInstances: this.component.initialMiddleObjectInstances, middleObject: this.component.middleObject, getMiddleObjectInstances: this.component.getMiddleObjectInstances, fieldHeight: this.component.fieldHeight, viewLayout: this.component.viewLayout })) : (React.createElement(RepeatableField, { ...this.component })))))) : null), element);
|
53
55
|
}
|
54
56
|
detachReact(element) {
|
55
57
|
ReactDOM.unmountComponentAtNode(element);
|
package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts
CHANGED
@@ -6,7 +6,9 @@ export declare class UserComponent extends ReactComponent {
|
|
6
6
|
[x: string]: any;
|
7
7
|
static schema: any;
|
8
8
|
errorDetails: any;
|
9
|
-
component: BaseFormComponentProps
|
9
|
+
component: BaseFormComponentProps & {
|
10
|
+
initialValue?: string;
|
11
|
+
};
|
10
12
|
componentRoot?: Root;
|
11
13
|
criteria: Record<string, unknown> | undefined;
|
12
14
|
updatedCriteria: Record<string, unknown>;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
1
|
import { ReactComponent } from '@formio/react';
|
3
2
|
import { cloneDeep, isEmpty } from 'lodash';
|
4
3
|
import React from 'react';
|
@@ -8,21 +7,25 @@ import { isPropertyVisible, transformToWhere } from '../../utils';
|
|
8
7
|
import { UserProperty } from './UserProperty';
|
9
8
|
export class UserComponent extends ReactComponent {
|
10
9
|
constructor(component, options, data) {
|
11
|
-
|
12
|
-
|
10
|
+
super({
|
11
|
+
...component,
|
12
|
+
canUpdateProperty: !component.readOnly,
|
13
|
+
hideLabel: true,
|
14
|
+
}, options, data);
|
13
15
|
this.handleChangeUserProperty = (value) => {
|
16
|
+
delete this.errorDetails['api-error'];
|
14
17
|
// set the value on the form instance at this.root.data
|
15
18
|
const updatedValue = value ? { name: value.label, id: value.value } : '';
|
16
19
|
this.setValue(updatedValue);
|
17
20
|
// update the value in the component instance
|
18
|
-
this.updateValue(updatedValue
|
21
|
+
this.updateValue(updatedValue ?? {}, { modified: true });
|
19
22
|
this.handleValidation();
|
20
23
|
this.attach(this.element);
|
21
24
|
this.component.autoSave && this.component.autoSave(value);
|
22
25
|
};
|
23
26
|
this.errorDetails = {};
|
24
27
|
this.criteria = component.validate.criteria;
|
25
|
-
this.updatedCriteria =
|
28
|
+
this.updatedCriteria = cloneDeep(component.validate.criteria) ?? {};
|
26
29
|
this.handleChangeUserProperty = this.handleChangeUserProperty.bind(this);
|
27
30
|
}
|
28
31
|
init() {
|
@@ -45,6 +48,42 @@ export class UserComponent extends ReactComponent {
|
|
45
48
|
}
|
46
49
|
}
|
47
50
|
});
|
51
|
+
if (this.component.initialValue && /^{{.*}}$/.test(this.component.initialValue)) {
|
52
|
+
const regex = /^{{input\.(?<relatedObjectProperty>[a-zA-Z][a-zA-Z0-9_]*)\.(?<nestedProperty>[a-zA-Z][a-zA-Z0-9_]*)}}$/;
|
53
|
+
const groups = regex.exec(this.component.initialValue)?.groups;
|
54
|
+
if (groups?.relatedObjectProperty && groups?.nestedProperty) {
|
55
|
+
this.on(`changed-${groups.relatedObjectProperty}`, (value) => {
|
56
|
+
if (value) {
|
57
|
+
this.setValue(value?.[groups.nestedProperty]);
|
58
|
+
this.updateValue(value?.[groups.nestedProperty], { modified: true });
|
59
|
+
this.attach(this.element);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}
|
64
|
+
this.on(`api-error`, (details) => {
|
65
|
+
const error = details.find((detail) => detail.code === 'errorMessage' && detail.path.replace('/', '') === this.component.key);
|
66
|
+
if (error) {
|
67
|
+
if (!this.root.customErrors.find((err) => err.formattedKeyOrPath === this.component.key && err.message === error.message)) {
|
68
|
+
this.root.customErrors = [
|
69
|
+
...this.root.customErrors,
|
70
|
+
{
|
71
|
+
...error,
|
72
|
+
code: 'api-error',
|
73
|
+
component: this.component,
|
74
|
+
formattedKeyOrPath: this.component.key,
|
75
|
+
},
|
76
|
+
];
|
77
|
+
}
|
78
|
+
this.errorDetails['api-error'] = error?.message;
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
this.root.customErrors = this.root.customErrors.filter((item) => item.formattedKeyOrPath !== this.component.key);
|
82
|
+
delete this.errorDetails['api-error'];
|
83
|
+
}
|
84
|
+
this.attach(this.element);
|
85
|
+
this.attachReact(this.element);
|
86
|
+
});
|
48
87
|
}
|
49
88
|
clearErrors() {
|
50
89
|
this.errorDetails = {};
|
@@ -68,10 +107,9 @@ export class UserComponent extends ReactComponent {
|
|
68
107
|
* Synchronizes out-of-the-box formio errors with this field's errorDetails object
|
69
108
|
*/
|
70
109
|
manageFormErrors() {
|
71
|
-
|
72
|
-
const outOfTheBoxError = (_a = this.root.errors.find((error) => {
|
110
|
+
const outOfTheBoxError = this.root.errors.find((error) => {
|
73
111
|
return error.component.key === this.component.key;
|
74
|
-
})
|
112
|
+
})?.message;
|
75
113
|
// add OoB formio error to errorDetails object to show under field
|
76
114
|
if (outOfTheBoxError) {
|
77
115
|
this.errorDetails['rootError'] = outOfTheBoxError;
|
@@ -85,15 +123,20 @@ export class UserComponent extends ReactComponent {
|
|
85
123
|
this.element && this.attach(this.element);
|
86
124
|
}
|
87
125
|
attachReact(element) {
|
88
|
-
|
89
|
-
|
126
|
+
const updatedComponent = {
|
127
|
+
...this.component,
|
128
|
+
instance: {
|
129
|
+
...this.component.instance,
|
130
|
+
[this.component.key]: isEmpty(this.dataValue) ? null : this.dataValue,
|
131
|
+
},
|
132
|
+
};
|
90
133
|
if (!this.componentRoot) {
|
91
134
|
this.componentRoot = createRoot(element, { onRecoverableError: console.error });
|
92
135
|
}
|
93
136
|
// FormIO uses id for an enclosing div, so we need to give the input field a different id.
|
94
137
|
const inputId = `${this.component.id}-input`;
|
95
138
|
return this.componentRoot.render(React.createElement("div", null,
|
96
|
-
React.createElement(FormComponentWrapper,
|
97
|
-
React.createElement(UserProperty,
|
139
|
+
React.createElement(FormComponentWrapper, { ...updatedComponent, inputId: inputId, errorMessage: this.errorMessages() },
|
140
|
+
React.createElement(UserProperty, { ...updatedComponent, id: inputId, value: this.dataValue ?? '', handleChangeUserProperty: this.handleChangeUserProperty, error: this.hasErrors(), filter: this.criteria ? { where: transformToWhere(this.updatedCriteria) } : undefined }))));
|
98
141
|
}
|
99
142
|
}
|
@@ -10,8 +10,8 @@ export const UserProperty = (props) => {
|
|
10
10
|
const [users, setUsers] = useState();
|
11
11
|
const [userValue, setUserValue] = useState();
|
12
12
|
useEffect(() => {
|
13
|
-
if (value === '$_CURRENT' &&
|
14
|
-
const loggedInUser = users
|
13
|
+
if (value === '$_CURRENT' && user?.id) {
|
14
|
+
const loggedInUser = users?.find((u) => u.id === user.id);
|
15
15
|
if (loggedInUser) {
|
16
16
|
setUserValue({ label: loggedInUser.name, value: loggedInUser.id });
|
17
17
|
handleChangeUserProperty({ label: loggedInUser.name, value: loggedInUser.id });
|
@@ -31,7 +31,7 @@ export const UserProperty = (props) => {
|
|
31
31
|
setLoadingOptions(true);
|
32
32
|
apiServices.get(getPrefixedUrl(`/users`), (error, userList) => {
|
33
33
|
setUsers(userList);
|
34
|
-
setOptions((userList
|
34
|
+
setOptions((userList ?? []).map((user) => ({ label: user.name, value: user.id })));
|
35
35
|
setLoadingOptions(false);
|
36
36
|
});
|
37
37
|
}
|
@@ -58,33 +58,33 @@ export const UserProperty = (props) => {
|
|
58
58
|
},
|
59
59
|
} }, children));
|
60
60
|
}, sx: {
|
61
|
-
'& button.MuiButtonBase-root':
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
'& button.MuiButtonBase-root': {
|
62
|
+
...(!loadingOptions && value
|
63
|
+
? {
|
64
|
+
visibility: 'visible',
|
65
|
+
}
|
66
|
+
: {}),
|
67
|
+
},
|
66
68
|
}, noOptionsText: 'No options available', renderOption: (props, option) => {
|
67
|
-
|
68
|
-
return (React.createElement("li", Object.assign({}, props, { key: option.id }),
|
69
|
+
return (React.createElement("li", { ...props, key: option.id },
|
69
70
|
React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } },
|
70
71
|
option.label,
|
71
72
|
" ",
|
72
73
|
'',
|
73
|
-
|
74
|
+
users?.find((user) => option.value === user.id)?.status === 'Inactive' ? (React.createElement("span", null, "(Inactive)")) : (''))));
|
74
75
|
}, onOpen: () => {
|
75
76
|
setOpenOptions(true);
|
76
|
-
}, onClose: () => setOpenOptions(false), value: userValue
|
77
|
-
var _a, _b, _c, _d;
|
77
|
+
}, onClose: () => setOpenOptions(false), value: userValue ?? '', options: options, getOptionLabel: (option) => {
|
78
78
|
if (typeof option === 'string') {
|
79
|
-
return
|
79
|
+
return options.find((o) => o.value === option)?.label ?? '';
|
80
80
|
}
|
81
81
|
else {
|
82
82
|
{
|
83
|
-
if (
|
83
|
+
if (users?.find((user) => option.value === user.id)?.status === 'Inactive') {
|
84
84
|
return option.label + ' (Inactive)';
|
85
85
|
}
|
86
86
|
else {
|
87
|
-
return
|
87
|
+
return option.label ?? '';
|
88
88
|
}
|
89
89
|
}
|
90
90
|
}
|
@@ -96,20 +96,22 @@ export const UserProperty = (props) => {
|
|
96
96
|
if (typeof value === 'string') {
|
97
97
|
return option.value === value;
|
98
98
|
}
|
99
|
-
return option.value ===
|
99
|
+
return option.value === value?.value;
|
100
100
|
}, onChange: (event, value) => {
|
101
101
|
handleChangeUserProperty(value);
|
102
|
-
}, selectOnFocus: false, renderInput: (params) => (React.createElement(TextField,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
102
|
+
}, selectOnFocus: false, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', sx: {
|
103
|
+
...(!loadingOptions && value
|
104
|
+
? {
|
105
|
+
'.MuiOutlinedInput-root': {
|
106
|
+
background: 'white',
|
107
|
+
border: 'auto',
|
108
|
+
},
|
109
|
+
'& fieldset': { borderColor: 'auto' },
|
110
|
+
'&:hover .MuiOutlinedInput-notchedOutline': {
|
111
|
+
border: 'auto',
|
112
|
+
},
|
113
|
+
caretColor: 'white',
|
114
|
+
}
|
115
|
+
: {}),
|
116
|
+
}, size: fieldHeight ?? 'medium' })), error: error }))));
|
115
117
|
};
|