@irontec/ivoz-ui 1.7.13 → 1.7.16

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.
Files changed (26) hide show
  1. package/components/List/Filter/ContentFilterSelector/ContentFilterRow.js +51 -14
  2. package/components/List/Filter/ContentFilterSelector/ContentFilterRow.styles.js +4 -0
  3. package/components/shared/ConfirmDialog.d.ts +2 -2
  4. package/components/shared/ConfirmDialog.js +20 -19
  5. package/components/shared/ConfirmEditDialog.js +27 -25
  6. package/components/shared/Modal/Modal.d.ts +22 -0
  7. package/components/shared/Modal/Modal.js +22 -0
  8. package/components/shared/Modal/Modal.styles.d.ts +32 -0
  9. package/components/shared/Modal/Modal.styles.js +17 -0
  10. package/entities/DefaultEntityBehavior/AutoSelectOptions.d.ts +6 -0
  11. package/entities/DefaultEntityBehavior/AutoSelectOptions.js +51 -0
  12. package/entities/DefaultEntityBehavior/DynamicAutocompleteGetter.d.ts +3 -0
  13. package/entities/DefaultEntityBehavior/DynamicAutocompleteGetter.js +19 -0
  14. package/entities/DefaultEntityBehavior.d.ts +4 -3
  15. package/entities/DefaultEntityBehavior.js +6 -2
  16. package/entities/EntityInterface.d.ts +6 -0
  17. package/package.json +1 -1
  18. package/services/entity/EntityService.d.ts +2 -1
  19. package/services/entity/EntityService.js +3 -0
  20. package/services/form/Field/DynamicAutocomplete/DynamicAutocomplete.d.ts +3 -1
  21. package/services/form/Field/DynamicAutocomplete/DynamicAutocomplete.js +73 -44
  22. package/services/form/Field/TextField/TextField.styles.js +1 -0
  23. package/services/form/FormFieldFactory/Factory/DynamicAutocompleteFactory.d.ts +4 -4
  24. package/services/form/FormFieldFactory/Factory/DynamicAutocompleteFactory.js +40 -3
  25. package/services/form/FormFieldFactory/FormFieldFactory.d.ts +1 -0
  26. package/services/form/FormFieldFactory/FormFieldFactory.js +14 -3
@@ -6,9 +6,11 @@ import { memo, useEffect, useMemo, useState } from 'react';
6
6
  import { LightButton, TonalButton, } from '../../../../components/shared/Button/Button.styles';
7
7
  import { isPropertyFk, isPropertyScalar, } from '../../../../services/api/ParsedApiSpecInterface';
8
8
  import { StyledDropdown } from '../../../../services/form/Field/Dropdown/Dropdown.styles';
9
+ import { StyledDynamicAutocomplete } from '../../../../services/form/Field/DynamicAutocomplete/DynamicAutocomplete.styles';
9
10
  import { StyledTextField } from '../../../../services/form/Field/TextField/TextField.styles';
10
11
  import _ from '../../../../services/translations/translate';
11
12
  import FilterIconFactory from '../icons/FilterIconFactory';
13
+ import StoreContainer from '../../../../store/StoreContainer';
12
14
  const StyledDropdownMemo = memo(StyledDropdown, (prev, next) => {
13
15
  return prev.value === next.value;
14
16
  });
@@ -36,19 +38,50 @@ export default function ContentFilterRow(props) {
36
38
  setValue(row.value);
37
39
  }, [row]);
38
40
  const column = columns[name];
39
- let enumValue = null;
40
- if (isPropertyFk(column)) {
41
- enumValue = fkChoices[name] || {};
42
- }
43
- else if (column.enum) {
44
- enumValue = column.enum;
45
- }
46
- else if (column.type === 'boolean') {
47
- enumValue = {
48
- true: _('True'),
49
- false: _('False'),
41
+ const [selectOptions, setSelectOptions] = useState(null);
42
+ const { useDynamicAutocomplete, entityName, enumValue } = useMemo(() => {
43
+ var _a;
44
+ let enumVal = null;
45
+ let useDynamic = false;
46
+ let entName = '';
47
+ if (isPropertyFk(column)) {
48
+ const entities = StoreContainer.store.getState().entities.entities;
49
+ entName = ((_a = column.$ref) === null || _a === void 0 ? void 0 : _a.replace('#/definitions/', '')) || '';
50
+ const entity = entities === null || entities === void 0 ? void 0 : entities[entName];
51
+ if (entity === null || entity === void 0 ? void 0 : entity.dynamicSelectOptions) {
52
+ useDynamic = true;
53
+ }
54
+ else {
55
+ enumVal = fkChoices[name] || {};
56
+ }
57
+ }
58
+ else if (column.enum) {
59
+ enumVal = column.enum;
60
+ }
61
+ else if (column.type === 'boolean') {
62
+ enumVal = {
63
+ true: _('True'),
64
+ false: _('False'),
65
+ };
66
+ }
67
+ return {
68
+ useDynamicAutocomplete: useDynamic,
69
+ entityName: entName,
70
+ enumValue: enumVal,
50
71
  };
51
- }
72
+ }, [column, name, fkChoices]);
73
+ useEffect(() => {
74
+ if (!useDynamicAutocomplete || !entityName) {
75
+ return;
76
+ }
77
+ const entities = StoreContainer.store.getState().entities.entities;
78
+ const entity = entities === null || entities === void 0 ? void 0 : entities[entityName];
79
+ if (entity === null || entity === void 0 ? void 0 : entity.selectOptions) {
80
+ entity.selectOptions().then((handler) => {
81
+ setSelectOptions(() => handler);
82
+ });
83
+ }
84
+ }, [useDynamicAutocomplete, entityName]);
52
85
  const columnFormat = isPropertyScalar(column) && column.format;
53
86
  let textFieldInputType = 'text';
54
87
  const inputProps = {};
@@ -81,13 +114,17 @@ export default function ContentFilterRow(props) {
81
114
  setType(target.value);
82
115
  }, onBlur: () => {
83
116
  /* noop */
84
- }, choices: filterChoices, error: false, errorMsg: '', hasChanged: false }), type !== 'exists' && !enumValue && (_jsx(StyledTextField, { name: 'value', value: value, type: textFieldInputType, error: false, errorMsg: '', inputProps: inputProps, InputProps: {}, hasChanged: false, onChange: ({ target }) => {
117
+ }, choices: filterChoices, error: false, errorMsg: '', hasChanged: false }), type !== 'exists' && !enumValue && !useDynamicAutocomplete && (_jsx(StyledTextField, { name: 'value', value: value, type: textFieldInputType, error: false, errorMsg: '', inputProps: inputProps, InputProps: {}, hasChanged: false, onChange: ({ target }) => {
85
118
  let { value } = target;
86
119
  if (textFieldInputType === 'datetime-local') {
87
120
  value = value.replace('T', ' ');
88
121
  }
89
122
  setValue(value);
90
- } })), type !== 'exists' && enumValue && (_jsx(StyledDropdown, { name: 'value', label: '', value: value, required: false, disabled: false, onChange: ({ target }) => {
123
+ } })), type !== 'exists' && useDynamicAutocomplete && selectOptions && (_jsx(StyledDynamicAutocomplete, { name: 'value', label: '', value: value, choices: {}, multiple: false, required: false, disabled: false, onChange: ({ target }) => {
124
+ setValue(target.value);
125
+ }, onBlur: () => {
126
+ /* noop */
127
+ }, selectOptions: selectOptions, error: false, errorMsg: '', hasChanged: false })), type !== 'exists' && enumValue && !useDynamicAutocomplete && (_jsx(StyledDropdown, { name: 'value', label: '', value: value, required: false, disabled: false, onChange: ({ target }) => {
91
128
  setValue(target.value);
92
129
  }, onBlur: () => {
93
130
  /* noop */
@@ -5,6 +5,10 @@ export const StyledContentFilterRow = styled(ContentFilterRow)(({ theme }) => {
5
5
  display: 'flex',
6
6
  alignItems: 'center',
7
7
  gap: 'var(--spacing-md)',
8
+ '& > *:not(button)': {
9
+ flex: 1,
10
+ minWidth: 0,
11
+ },
8
12
  [theme.breakpoints.down('md')]: {
9
13
  flexDirection: 'column',
10
14
  gap: 'var(--spacing-sm)',
@@ -4,8 +4,8 @@ interface ConfirmDialogProps {
4
4
  open: boolean;
5
5
  doubleCheck?: boolean;
6
6
  doubleCheckExpectedStr?: string;
7
- handleClose: (event: unknown) => void;
8
- handleApply: (event: unknown) => void;
7
+ handleClose: () => void;
8
+ handleApply: (event: React.MouseEvent) => void;
9
9
  }
10
10
  export default function ConfirmDialog(props: ConfirmDialogProps): JSX.Element;
11
11
  export {};
@@ -1,20 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
3
- import Dialog from '@mui/material/Dialog';
4
- import DialogActions from '@mui/material/DialogActions';
5
- import DialogContent from '@mui/material/DialogContent';
6
- import DialogContentText from '@mui/material/DialogContentText';
7
- import DialogTitle from '@mui/material/DialogTitle';
8
- import Slide from '@mui/material/Slide';
9
- import { forwardRef, useCallback, useState, } from 'react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useState } from 'react';
10
3
  import { StyledSearchTextField } from '../../services/form/Field/TextField/TextField.styles';
11
4
  import _ from '../../services/translations/translate';
12
- import { OutlinedButton, SolidButton } from './Button/Button.styles';
13
5
  import { StyledDialogContentText } from './ConfirmDialog.styles';
14
- const Transition = forwardRef(function (props, ref) {
15
- return _jsx(Slide, Object.assign({}, props, { direction: 'up', ref: ref }));
16
- });
17
- Transition.displayName = 'ConfirmDialogTransition';
6
+ import Modal from './Modal/Modal';
18
7
  export default function ConfirmDialog(props) {
19
8
  const { text, open, doubleCheck, doubleCheckExpectedStr, handleClose, handleApply, } = props;
20
9
  const [inputVal, setInputVal] = useState('');
@@ -22,9 +11,21 @@ export default function ConfirmDialog(props) {
22
11
  const val = event.target.value;
23
12
  setInputVal(val || '');
24
13
  }, []);
25
- const handleKeyDown = (event) => {
26
- event.stopPropagation();
27
- };
28
- const sumbitEnabled = !doubleCheck || inputVal == doubleCheckExpectedStr;
29
- return (_jsxs(Dialog, Object.assign({ open: open, TransitionComponent: Transition, keepMounted: true, onClose: handleClose, "aria-labelledby": 'alert-dialog-slide-title', "aria-describedby": 'alert-dialog-slide-description', onKeyDown: handleKeyDown }, { children: [_jsx(CloseRoundedIcon, { className: 'close-icon', onClick: handleClose }), _jsx("img", { src: 'assets/img/delete-dialog.svg', className: 'modal-icon' }), _jsx(DialogTitle, Object.assign({ id: 'alert-dialog-slide-title' }, { children: _('Remove element') })), _jsxs(DialogContent, { children: [_jsx(DialogContentText, Object.assign({ id: 'alert-dialog-slide-description' }, { children: text })), doubleCheck && (_jsx(StyledDialogContentText, Object.assign({ id: 'alert-dialog-double-check-description' }, { children: _('Please type the item name, as shown in bold font above, to continue') }))), doubleCheck && (_jsx(StyledSearchTextField, { type: 'text', hasChanged: false, defaultValue: inputVal, onChange: onChangeHandler }))] }), _jsxs(DialogActions, { children: [_jsx(OutlinedButton, Object.assign({ onClick: handleClose, sx: { flexGrow: '1' }, color: 'error' }, { children: _('No, keep it') })), _jsx(SolidButton, Object.assign({ disabled: !sumbitEnabled, onClick: handleApply, sx: { flexGrow: '1' }, color: 'error' }, { children: _('Yes, delete it') }))] })] })));
14
+ const submitEnabled = !doubleCheck || inputVal == doubleCheckExpectedStr;
15
+ const customButtons = [
16
+ {
17
+ label: _('No, keep it'),
18
+ onClick: () => handleClose(),
19
+ variant: 'outlined',
20
+ autoFocus: false,
21
+ },
22
+ {
23
+ label: _('Yes, delete it'),
24
+ onClick: (event) => handleApply(event),
25
+ variant: 'solid',
26
+ autoFocus: true,
27
+ disabled: !submitEnabled,
28
+ },
29
+ ];
30
+ return (_jsx(Modal, Object.assign({ title: _('Remove element'), description: text, open: open, onClose: handleClose, buttons: customButtons, icon: 'assets/img/delete-dialog.svg', keepMounted: true }, { children: doubleCheck && (_jsxs(_Fragment, { children: [_jsx(StyledDialogContentText, Object.assign({ id: 'alert-dialog-double-check-description' }, { children: _('Please type the item name, as shown in bold font above, to continue') })), _jsx(StyledSearchTextField, { type: 'text', hasChanged: false, defaultValue: inputVal, onChange: onChangeHandler })] })) })));
30
31
  }
@@ -1,27 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect, forwardRef, } from 'react';
3
- import Dialog from '@mui/material/Dialog';
4
- import DialogTitle from '@mui/material/DialogTitle';
5
- import DialogContent from '@mui/material/DialogContent';
6
- import DialogActions from '@mui/material/DialogActions';
7
- import Button from '@mui/material/Button';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { Box } from '@mui/material';
8
4
  import LinearProgress from '@mui/material/LinearProgress';
9
- import { DialogContentText, Slide } from '@mui/material';
10
- import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
11
5
  import _ from '../../services/translations/translate';
12
- const Transition = forwardRef(function (props, ref) {
13
- return _jsx(Slide, Object.assign({}, props, { direction: 'up', ref: ref }));
14
- });
15
- Transition.displayName = 'ConfirmDialogTransition';
6
+ import Modal from './Modal/Modal';
16
7
  export const ConfirmEditionDialog = (props) => {
17
8
  const { open, handleClose, text, handleSave, formEvent } = props;
18
9
  const TOTAL_TIME = 100;
19
10
  const [progress, setProgress] = useState(TOTAL_TIME);
20
- const handleKeyDown = (event) => {
21
- if (event.key === 'Tab') {
22
- event.stopPropagation();
23
- }
24
- };
25
11
  useEffect(() => {
26
12
  let timer = null;
27
13
  if (open) {
@@ -41,11 +27,27 @@ export const ConfirmEditionDialog = (props) => {
41
27
  }
42
28
  };
43
29
  }, [open]);
44
- return (_jsxs(Dialog, Object.assign({ open: open, TransitionComponent: Transition, keepMounted: true, onClose: handleClose, onKeyDown: handleKeyDown, "aria-labelledby": 'alert-dialog-slide-title', "aria-describedby": 'alert-dialog-slide-description' }, { children: [_jsx(CloseRoundedIcon, { className: 'close-icon', onClick: handleClose }), _jsx("img", { src: 'assets/img/warning-dialog.svg', className: 'modal-icon' }), _jsx(DialogTitle, Object.assign({ id: 'alert-dialog-slide-title' }, { children: _('Save element') })), _jsxs(DialogContent, { children: [_jsx(DialogContentText, Object.assign({ id: 'alert-dialog-slide-description' }, { children: text })), _jsx(LinearProgress, { variant: 'determinate', value: progress })] }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: () => {
45
- handleClose();
46
- } }, { children: "Cancel" })), _jsx(Button, Object.assign({ hidden: progress !== 0, onClick: () => {
47
- if (formEvent) {
48
- handleSave(formEvent);
49
- }
50
- }, disabled: progress !== 0 }, { children: "Apply" }))] })] })));
30
+ const customButtons = [
31
+ {
32
+ label: _('Cancel'),
33
+ onClick: () => handleClose(),
34
+ variant: 'outlined',
35
+ autoFocus: false,
36
+ },
37
+ ...(progress === 0
38
+ ? [
39
+ {
40
+ label: _('Apply'),
41
+ onClick: () => {
42
+ if (formEvent) {
43
+ handleSave(formEvent);
44
+ }
45
+ },
46
+ variant: 'solid',
47
+ autoFocus: true,
48
+ },
49
+ ]
50
+ : []),
51
+ ];
52
+ return (_jsx(Modal, Object.assign({ title: _('Save element'), description: text, open: open, onClose: handleClose, buttons: customButtons, keepMounted: true }, { children: _jsx(Box, Object.assign({ sx: { width: '100%', mt: 2 } }, { children: _jsx(LinearProgress, { variant: 'determinate', value: progress }) })) })));
51
53
  };
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { SxProps, Theme } from '@mui/material';
3
+ interface Button {
4
+ label: React.ReactNode;
5
+ onClick: (event: React.MouseEvent) => void;
6
+ autoFocus?: boolean;
7
+ variant?: 'outlined' | 'solid';
8
+ disabled?: boolean;
9
+ }
10
+ interface ModalContentProps {
11
+ title: React.ReactNode;
12
+ description?: React.ReactNode;
13
+ children: React.ReactNode;
14
+ sx?: SxProps<Theme>;
15
+ open: boolean;
16
+ onClose: () => void;
17
+ buttons?: Button[];
18
+ icon?: string;
19
+ keepMounted?: boolean;
20
+ }
21
+ export default function Modal(props: ModalContentProps): JSX.Element;
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { StyledDialogContentBody, StyledDialogContent, StyledDialogActions, } from './Modal.styles';
3
+ import { OutlinedButton, SolidButton } from '../Button/Button.styles';
4
+ import { forwardRef } from 'react';
5
+ import Slide from '@mui/material/Slide';
6
+ import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
7
+ import { Box, Dialog, DialogContentText, DialogTitle, IconButton, } from '@mui/material';
8
+ const Transition = forwardRef(function Transition(props, ref) {
9
+ return _jsx(Slide, Object.assign({}, props, { direction: 'up', ref: ref }));
10
+ });
11
+ export default function Modal(props) {
12
+ const { title, description, children, sx, open, onClose, buttons, icon, keepMounted = false, } = props;
13
+ const handleKeyDown = (event) => {
14
+ event.stopPropagation();
15
+ };
16
+ const renderButton = (button, index) => {
17
+ var _a;
18
+ const ButtonTypeComponent = button.variant === 'outlined' ? OutlinedButton : SolidButton;
19
+ return (_jsx(ButtonTypeComponent, Object.assign({ onClick: button.onClick, autoFocus: button.autoFocus, disabled: (_a = button.disabled) !== null && _a !== void 0 ? _a : false, sx: { flex: 1 } }, { children: button.label }), index));
20
+ };
21
+ return (_jsxs(Dialog, Object.assign({ open: open, onClose: onClose, TransitionComponent: Transition, "aria-labelledby": 'alert-dialog-slide-title', "aria-describedby": 'alert-dialog-slide-description', onKeyDown: handleKeyDown, keepMounted: keepMounted }, { children: [_jsx(Box, Object.assign({ sx: { position: 'absolute', right: 8, top: 8 } }, { children: _jsx(IconButton, Object.assign({ onClick: onClose }, { children: _jsx(CloseRoundedIcon, {}) })) })), icon && _jsx("img", { src: icon, className: 'modal-icon', alt: 'dialog icon' }), _jsx(DialogTitle, Object.assign({ id: 'alert-dialog-slide-title' }, { children: title })), _jsxs(StyledDialogContent, { children: [description && (_jsx(DialogContentText, Object.assign({ id: 'alert-dialog-slide-description' }, { children: description }))), _jsx(StyledDialogContentBody, Object.assign({ sx: sx }, { children: children }))] }), buttons && (_jsx(StyledDialogActions, Object.assign({ style: { padding: 0 } }, { children: buttons === null || buttons === void 0 ? void 0 : buttons.map(renderButton) })))] })));
22
+ }
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ import { SxProps, Theme } from '@mui/material';
3
+ declare type StyledDialogContentBodyProps = {
4
+ sx?: SxProps<Theme>;
5
+ };
6
+ export declare const StyledDialogContentBody: import("@mui/styles").StyledComponent<Omit<import("@mui/system").SystemProps<Theme> & {
7
+ children?: import("react").ReactNode;
8
+ component?: import("react").ElementType<any> | undefined;
9
+ ref?: import("react").Ref<unknown> | undefined;
10
+ sx?: SxProps<Theme> | undefined;
11
+ } & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").HTMLAttributes<HTMLDivElement> | "key"> & {
12
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
13
+ }, "children" | "ref" | "sx" | "component" | ("color" | "p" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxShadow" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint")>, "classes" | "className"> & import("@mui/styles").StyledComponentProps<"root"> & Omit<Pick<import("@mui/system").SystemProps<Theme> & {
14
+ children?: import("react").ReactNode;
15
+ component?: import("react").ElementType<any> | undefined;
16
+ ref?: import("react").Ref<unknown> | undefined;
17
+ sx?: SxProps<Theme> | undefined;
18
+ } & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").HTMLAttributes<HTMLDivElement> | "key"> & {
19
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
20
+ }, "children" | "ref" | "sx" | "component" | ("color" | "p" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxShadow" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint")>, "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "component" | ("color" | "p" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxShadow" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint")>, "className" | "theme"> & {
21
+ className?: string | undefined;
22
+ theme?: StyledDialogContentBodyProps | undefined;
23
+ }>;
24
+ export declare const StyledDialogContent: import("@mui/styles").StyledComponent<Omit<import("@mui/material").DialogContentProps, "classes" | "className"> & import("@mui/styles").StyledComponentProps<"root"> & Omit<Pick<import("@mui/material").DialogContentProps, "classes" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "dividers">, "className" | "theme"> & {
25
+ className?: string | undefined;
26
+ theme?: import("@mui/styles").DefaultTheme | undefined;
27
+ }>;
28
+ export declare const StyledDialogActions: import("@mui/styles").StyledComponent<Omit<import("@mui/material").DialogActionsProps, "classes" | "className"> & import("@mui/styles").StyledComponentProps<"root"> & Omit<Pick<import("@mui/material").DialogActionsProps, "classes" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "disableSpacing">, "className" | "theme"> & {
29
+ className?: string | undefined;
30
+ theme?: import("@mui/styles").DefaultTheme | undefined;
31
+ }>;
32
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Box, DialogContent, DialogActions, } from '@mui/material';
2
+ import { styled } from '@mui/styles';
3
+ export const StyledDialogContentBody = styled(Box)(({ sx }) => {
4
+ const resolvedStyles = Object.assign({ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 'var(--spacing-md)' }, sx);
5
+ return resolvedStyles;
6
+ });
7
+ export const StyledDialogContent = styled(DialogContent)(() => {
8
+ return {
9
+ minWidth: '350px',
10
+ };
11
+ });
12
+ export const StyledDialogActions = styled(DialogActions)(() => {
13
+ return {
14
+ padding: 0,
15
+ marginTop: '10px',
16
+ };
17
+ });
@@ -1,6 +1,7 @@
1
1
  import EntityService from '../../services/entity/EntityService';
2
2
  import { CancelToken } from 'axios';
3
3
  import { EntityList } from 'router/parseRoutes';
4
+ import { SelectOptionsType } from 'entities/EntityInterface';
4
5
  declare type AutoSelectOptionsArgs = {
5
6
  cancelToken?: CancelToken;
6
7
  entities?: EntityList;
@@ -9,4 +10,9 @@ declare type AutoSelectOptionsArgs = {
9
10
  response: Record<string, Array<unknown>> | any;
10
11
  };
11
12
  export declare const autoSelectOptions: (props: AutoSelectOptionsArgs) => Array<Promise<unknown>>;
13
+ declare type AutoSelectOptionHandlersArgs = {
14
+ entityService: EntityService;
15
+ skip?: string[];
16
+ };
17
+ export declare const autoSelectOptionHandlers: (props: AutoSelectOptionHandlersArgs) => Promise<Record<string, SelectOptionsType>>;
12
18
  export default autoSelectOptions;
@@ -1,3 +1,12 @@
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
+ };
1
10
  import { StoreContainer } from '../../store';
2
11
  export const autoSelectOptions = (props) => {
3
12
  const { cancelToken, response, entityService } = props;
@@ -51,4 +60,46 @@ export const autoSelectOptions = (props) => {
51
60
  }
52
61
  return promises;
53
62
  };
63
+ export const autoSelectOptionHandlers = (props) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const { entityService } = props;
65
+ const entities = StoreContainer.store.getState().entities.entities;
66
+ const handlers = {};
67
+ if (!entities) {
68
+ return handlers;
69
+ }
70
+ const skip = props.skip || [];
71
+ const fkProperties = entityService === null || entityService === void 0 ? void 0 : entityService.getFkProperties();
72
+ const promises = [];
73
+ for (const idx in fkProperties) {
74
+ if (skip.includes(idx)) {
75
+ continue;
76
+ }
77
+ const cleanRef = fkProperties[idx].$ref.replace('#/definitions/', '');
78
+ const entity = entities[cleanRef];
79
+ if (!entity) {
80
+ if (cleanRef && cleanRef.indexOf('_') < 0) {
81
+ console.log('autoSelectOptionsHandlers', `${cleanRef} not found`);
82
+ }
83
+ continue;
84
+ }
85
+ if (!entity.selectOptions) {
86
+ if (cleanRef && cleanRef.indexOf('_') < 0) {
87
+ console.log('autoSelectOptionsHandlers', `${cleanRef} selectOption is not defined`);
88
+ }
89
+ continue;
90
+ }
91
+ if (!entity.dynamicSelectOptions) {
92
+ continue;
93
+ }
94
+ const selectOptionsLoader = entity.selectOptions;
95
+ if (!selectOptionsLoader) {
96
+ continue;
97
+ }
98
+ promises.push(selectOptionsLoader().then((handler) => {
99
+ handlers[cleanRef] = handler;
100
+ }));
101
+ }
102
+ yield Promise.all(promises);
103
+ return handlers;
104
+ });
54
105
  export default autoSelectOptions;
@@ -0,0 +1,3 @@
1
+ import { DynamicAutocompleteGetterType } from '../EntityInterface';
2
+ declare const dynamicAutocompleteGetters: DynamicAutocompleteGetterType;
3
+ export default dynamicAutocompleteGetters;
@@ -0,0 +1,19 @@
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 { autoSelectOptionHandlers } from './AutoSelectOptions';
11
+ const dynamicAutocompleteGetters = (props) => __awaiter(void 0, void 0, void 0, function* () {
12
+ const { entityService } = props;
13
+ const getters = yield autoSelectOptionHandlers({
14
+ entityService,
15
+ skip: [],
16
+ });
17
+ return getters;
18
+ });
19
+ export default dynamicAutocompleteGetters;
@@ -1,9 +1,9 @@
1
1
  import { CancelToken } from 'axios';
2
2
  import * as React from 'react';
3
3
  import { EntityValues } from '../services/entity/EntityService';
4
- import { ChildDecoratorProps, ChildDecoratorType, EntityAclType, FetchFksCallback, OrderDirection, calculateAclType } from './EntityInterface';
4
+ import { ChildDecoratorProps, ChildDecoratorType, DynamicAutocompleteGetterTypeArgs, EntityAclType, FetchFksCallback, OrderDirection, calculateAclType } from './EntityInterface';
5
5
  import autoForeignKeyResolver from './DefaultEntityBehavior/AutoForeignKeyResolver';
6
- import autoSelectOptions from './DefaultEntityBehavior/AutoSelectOptions';
6
+ import autoSelectOptions, { autoSelectOptionHandlers } from './DefaultEntityBehavior/AutoSelectOptions';
7
7
  import filterFieldsetGroups, { FieldsetGroups } from './DefaultEntityBehavior/FilterFieldsetGroups';
8
8
  import foreignKeyGetter from './DefaultEntityBehavior/ForeignKeyGetter';
9
9
  import foreignKeyResolver from './DefaultEntityBehavior/ForeignKeyResolver';
@@ -34,6 +34,7 @@ declare const DefaultEntityBehavior: {
34
34
  unmarshaller: (row: MarshallerValues, properties: import("..").PartialPropertyList) => MarshallerValues;
35
35
  foreignKeyResolver: () => Promise<import("./EntityInterface").foreignKeyResolverType>;
36
36
  foreignKeyGetter: () => Promise<import("./EntityInterface").ForeignKeyGetterType>;
37
+ dynamicAutocompleteGetters: (props: DynamicAutocompleteGetterTypeArgs) => Promise<Record<string, import("./EntityInterface").SelectOptionsType<any>>>;
37
38
  columns: never[];
38
39
  properties: {};
39
40
  acl: EntityAclType;
@@ -51,5 +52,5 @@ declare const DefaultEntityBehavior: {
51
52
  defaultOrderDirection: OrderDirection;
52
53
  };
53
54
  export default DefaultEntityBehavior;
54
- export { Form, ListDecorator, View, autoForeignKeyResolver, autoSelectOptions, filterFieldsetGroups, foreignKeyGetter, foreignKeyResolver, marshaller, unmarshaller, validator, };
55
+ export { Form, ListDecorator, View, autoForeignKeyResolver, autoSelectOptions, autoSelectOptionHandlers, filterFieldsetGroups, foreignKeyGetter, foreignKeyResolver, marshaller, unmarshaller, validator, };
55
56
  export type { EntityFormProps, EntityFormType, FieldsetGroups, FkChoices, MarshallerValues, NullablePropertyFkChoices, PropertyFkChoices, };
@@ -12,7 +12,7 @@ import { OrderDirection, } from './EntityInterface';
12
12
  import { fetchAllPages } from '../helpers/fechAllPages';
13
13
  import { isEntityItem } from '../router';
14
14
  import autoForeignKeyResolver from './DefaultEntityBehavior/AutoForeignKeyResolver';
15
- import autoSelectOptions from './DefaultEntityBehavior/AutoSelectOptions';
15
+ import autoSelectOptions, { autoSelectOptionHandlers, } from './DefaultEntityBehavior/AutoSelectOptions';
16
16
  import filterFieldsetGroups from './DefaultEntityBehavior/FilterFieldsetGroups';
17
17
  import foreignKeyGetter from './DefaultEntityBehavior/ForeignKeyGetter';
18
18
  import foreignKeyResolver from './DefaultEntityBehavior/ForeignKeyResolver';
@@ -74,6 +74,10 @@ const DefaultEntityBehavior = {
74
74
  const module = yield import('./DefaultEntityBehavior/ForeignKeyGetter');
75
75
  return module.default;
76
76
  }),
77
+ dynamicAutocompleteGetters: (props) => __awaiter(void 0, void 0, void 0, function* () {
78
+ const module = yield import('./DefaultEntityBehavior/DynamicAutocompleteGetter');
79
+ return module.default(props);
80
+ }),
77
81
  columns,
78
82
  properties,
79
83
  acl,
@@ -99,4 +103,4 @@ const DefaultEntityBehavior = {
99
103
  defaultOrderDirection: OrderDirection.asc,
100
104
  };
101
105
  export default DefaultEntityBehavior;
102
- export { Form, ListDecorator, View, autoForeignKeyResolver, autoSelectOptions, filterFieldsetGroups, foreignKeyGetter, foreignKeyResolver, marshaller, unmarshaller, validator, };
106
+ export { Form, ListDecorator, View, autoForeignKeyResolver, autoSelectOptions, autoSelectOptionHandlers, filterFieldsetGroups, foreignKeyGetter, foreignKeyResolver, marshaller, unmarshaller, validator, };
@@ -47,10 +47,15 @@ export declare type SelectOptionsArgs = {
47
47
  callback: FetchFksCallback;
48
48
  cancelToken?: CancelToken;
49
49
  };
50
+ export declare type DynamicAutocompleteGetterTypeArgs = {
51
+ entityService: EntityService;
52
+ skip?: Array<string>;
53
+ };
50
54
  export declare type DynamicSelectOptionsArgs = {
51
55
  searchTerm?: string;
52
56
  id?: string;
53
57
  };
58
+ export declare type DynamicAutocompleteGetterType = (props: DynamicAutocompleteGetterTypeArgs) => Promise<Record<string, SelectOptionsType>>;
54
59
  export declare type SelectOptionsType<T = any> = (props: SelectOptionsArgs, customProps?: T) => Promise<unknown>;
55
60
  export declare type EntityAclType = {
56
61
  iden?: string;
@@ -94,6 +99,7 @@ export default interface EntityInterface {
94
99
  foreignKeyResolver: () => Promise<foreignKeyResolverType>;
95
100
  foreignKeyGetter: () => Promise<ForeignKeyGetterType>;
96
101
  selectOptions?: () => Promise<SelectOptionsType>;
102
+ dynamicAutocompleteGetters: DynamicAutocompleteGetterType;
97
103
  dynamicSelectOptions?: boolean;
98
104
  Form: () => Promise<React.FunctionComponent<EntityFormProps>>;
99
105
  View: () => Promise<ViewType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.7.13",
3
+ "version": "1.7.16",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { IvozStoreState } from 'store';
3
3
  import { SearchFilterType } from '../../components/List/Filter/icons/FilterIconFactory';
4
- import EntityInterface, { EntityAclType, ForeignKeyGetterType, OrderDirection } from '../../entities/EntityInterface';
4
+ import EntityInterface, { DynamicAutocompleteGetterTypeArgs, EntityAclType, ForeignKeyGetterType, OrderDirection, SelectOptionsType } from '../../entities/EntityInterface';
5
5
  import { ActionModelSpec, ActionsSpec, PropertyList, fkPropertyList, visualToggleList } from '../../services/api/ParsedApiSpecInterface';
6
6
  export declare type VisualToggleStates = {
7
7
  [key: string]: boolean;
@@ -42,6 +42,7 @@ export default class EntityService<T extends IvozStoreState = IvozStoreState> {
42
42
  getOrderDirection(): OrderDirection;
43
43
  getAcls(parentRow?: EntityValues): EntityAclType;
44
44
  getForeignKeyGetter(): ForeignKeyGetterType;
45
+ getDynamicAutocompleteGetters(props: DynamicAutocompleteGetterTypeArgs): Promise<Record<string, SelectOptionsType>>;
45
46
  getListDecorator(): import("../../entities/EntityInterface").ListDecoratorType;
46
47
  getPropertyFilters(propertyName: string, path?: string): Array<SearchFilterType>;
47
48
  private getIden;
@@ -347,6 +347,9 @@ export default class EntityService {
347
347
  getForeignKeyGetter() {
348
348
  return this.entityDefinition.foreignKeyGetter;
349
349
  }
350
+ getDynamicAutocompleteGetters(props) {
351
+ return this.entityDefinition.dynamicAutocompleteGetters(props);
352
+ }
350
353
  getListDecorator() {
351
354
  return this.entityDefinition.ListDecorator;
352
355
  }
@@ -1,9 +1,11 @@
1
1
  import { InputProps } from '@mui/material';
2
2
  import React, { JSXElementConstructor, ReactElement } from 'react';
3
+ import { DropdownChoices } from '../Dropdown';
3
4
  import { SelectOptionsType } from 'entities/EntityInterface';
4
5
  import { FormOnChangeEvent } from 'entities/DefaultEntityBehavior/Form/Form';
5
6
  export interface DynamicAutocompleteProps {
6
- selectOptions: (() => Promise<SelectOptionsType>) | undefined;
7
+ choices: DropdownChoices;
8
+ selectOptions?: SelectOptionsType;
7
9
  nullOption?: string | React.ReactElement<any>;
8
10
  className?: string;
9
11
  name: string;
@@ -7,7 +7,7 @@ import { StyledAutocompleteTextField } from '../TextField';
7
7
  import SearchIcon from '@mui/icons-material/Search';
8
8
  const DynamicAutocomplete = (props) => {
9
9
  var _a;
10
- const { nullOption, name, label, required, multiple, disabled, onBlur, error, errorMsg, helperText, hasChanged, value, selectOptions, onChange, } = props;
10
+ const { nullOption, name, label, required, multiple, disabled, onBlur, error, errorMsg, helperText, hasChanged, value, choices, selectOptions, onChange, } = props;
11
11
  const { t } = useTranslation();
12
12
  let className = props.className;
13
13
  if (hasChanged) {
@@ -16,15 +16,56 @@ const DynamicAutocomplete = (props) => {
16
16
  if (multiple) {
17
17
  className += ' multiselect';
18
18
  }
19
- const nullOptionObject = nullOption
20
- ? { id: '__null__', label: nullOption }
21
- : null;
22
- const [arrayChoices, setArrayChoices] = useState(nullOptionObject ? [nullOptionObject] : []);
19
+ const nullOptionObject = {
20
+ id: '__null__',
21
+ label: nullOption !== null && nullOption !== void 0 ? nullOption : '',
22
+ };
23
+ const [arrayChoices, setArrayChoices] = useState([]);
23
24
  const [searchTerm, setSearchTerm] = useState('');
24
25
  const [loading, setLoading] = useState(false);
25
- const [open, setOpen] = useState(false);
26
26
  const [currentOption, setCurrentOption] = useState(nullOptionObject);
27
27
  const debounceTimeoutRef = useRef();
28
+ const loadedValuesRef = useRef(new Set());
29
+ useEffect(() => {
30
+ if (selectOptions && Object.keys(choices).length === 0) {
31
+ return;
32
+ }
33
+ if (Array.isArray(choices)) {
34
+ setArrayChoices(choices);
35
+ return;
36
+ }
37
+ const arrayValue = [];
38
+ for (const idx in choices) {
39
+ arrayValue.push({ id: idx, label: choices[idx] });
40
+ }
41
+ setArrayChoices(arrayValue);
42
+ }, [choices]);
43
+ useEffect(() => {
44
+ const nullValue = !value || value === '__null__';
45
+ if (nullValue) {
46
+ return;
47
+ }
48
+ if (!selectOptions) {
49
+ return;
50
+ }
51
+ if (loadedValuesRef.current.has(value)) {
52
+ return;
53
+ }
54
+ loadedValuesRef.current.add(value);
55
+ selectOptions({
56
+ callback: (options) => {
57
+ const option = options[0];
58
+ if (option) {
59
+ setArrayChoices((prev) => {
60
+ const exists = prev.some((item) => item.id == option.id);
61
+ return exists ? prev : [...prev, option];
62
+ });
63
+ }
64
+ },
65
+ }, {
66
+ id: value,
67
+ });
68
+ }, [value, selectOptions]);
28
69
  const setOptions = useCallback((options) => {
29
70
  const isCurrentOptionIncluded = options.some((option) => option.id == (currentOption === null || currentOption === void 0 ? void 0 : currentOption.id));
30
71
  if (!isCurrentOptionIncluded &&
@@ -35,59 +76,45 @@ const DynamicAutocomplete = (props) => {
35
76
  if (nullOptionObject) {
36
77
  options.unshift(nullOptionObject);
37
78
  }
38
- console.log('setOptions', options);
39
79
  setArrayChoices(options);
40
80
  }, [nullOptionObject, currentOption]);
41
- useEffect(() => {
42
- const hasOptions = arrayChoices.some((option) => option.id !== '__null__');
43
- if (hasOptions) {
44
- return;
81
+ const clearSearch = useCallback(() => {
82
+ if (debounceTimeoutRef.current) {
83
+ clearTimeout(debounceTimeoutRef.current);
45
84
  }
46
- const searchParams = {};
47
- if (value) {
48
- searchParams.id = value;
85
+ setLoading(false);
86
+ }, []);
87
+ const loadOptions = useCallback((searchValue) => {
88
+ if (!selectOptions) {
89
+ console.error('selectOptions is not defined');
90
+ return;
49
91
  }
50
- selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions().then((selectOptions) => {
92
+ setLoading(true);
93
+ debounceTimeoutRef.current = setTimeout(() => {
51
94
  selectOptions({
52
95
  callback: (options) => {
53
- if (options.length > 0) {
54
- setOptions(options);
55
- }
96
+ setLoading(false);
97
+ setOptions(options);
56
98
  },
57
- }, searchParams);
58
- });
59
- }, []);
99
+ }, {
100
+ searchTerm: searchValue,
101
+ });
102
+ }, 500);
103
+ }, [searchTerm, selectOptions]);
60
104
  useEffect(() => {
61
- if (!selectOptions) {
62
- return;
63
- }
64
- if (debounceTimeoutRef.current) {
65
- clearTimeout(debounceTimeoutRef.current);
66
- }
105
+ clearSearch();
67
106
  const searchTermMatchNullOption = getOptionLabel(nullOptionObject) === searchTerm;
68
107
  if (searchTermMatchNullOption) {
69
108
  return;
70
109
  }
71
- const isSearchTermIncluded = arrayChoices === null || arrayChoices === void 0 ? void 0 : arrayChoices.some((option) => getOptionLabel(option).includes(searchTerm));
110
+ const isSearchTermIncluded = searchTerm !== '' &&
111
+ (arrayChoices === null || arrayChoices === void 0 ? void 0 : arrayChoices.some((option) => getOptionLabel(option).includes(searchTerm)));
72
112
  if (isSearchTermIncluded) {
73
113
  return;
74
114
  }
75
- setLoading(true);
76
- debounceTimeoutRef.current = setTimeout(() => {
77
- selectOptions().then((selectOptions) => {
78
- selectOptions({
79
- callback: (options) => {
80
- setLoading(false);
81
- setOptions(options);
82
- },
83
- }, {
84
- searchTerm: searchTerm,
85
- });
86
- });
87
- }, 500);
115
+ loadOptions(searchTerm);
88
116
  }, [searchTerm, selectOptions]);
89
117
  const handleInputChange = useCallback((e, value, reason) => {
90
- console.log('inputChange', arrayChoices);
91
118
  if (reason === 'clear') {
92
119
  setSearchTerm('');
93
120
  return;
@@ -188,7 +215,9 @@ const DynamicAutocomplete = (props) => {
188
215
  const disableClearable = arrayChoices.find((item) => item.id === '__null__')
189
216
  ? false
190
217
  : true;
191
- const safeValue = value.length !== '' ? value : null;
192
- return (_jsx(MuiAutocomplete, { className: 'dynamic-autocomplete' + className, value: safeValue, multiple: multiple, disabled: disabled, disableClearable: disableClearable, onChange: onChangeWrapper, onBlur: onBlur, onInputChange: handleInputChange, onClose: () => setOpen(false), onOpen: () => setOpen(true), options: arrayChoices !== null && arrayChoices !== void 0 ? arrayChoices : [], getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, loading: loading, placeholder: props.placeholder, renderInput: renderInput, PaperComponent: CustomOption, renderOption: (props, option) => (_jsx(Box, Object.assign({ component: 'li', className: 'autocomplete-option', "data-value": option.id }, props, { children: option.label }))) }));
218
+ const safeValue = arrayChoices.find((item) => item.id == value)
219
+ ? value
220
+ : null;
221
+ return (_jsx(MuiAutocomplete, { className: 'dynamic-autocomplete' + className, value: safeValue, multiple: multiple, disabled: disabled, disableClearable: disableClearable, onChange: onChangeWrapper, onBlur: onBlur, onInputChange: handleInputChange, options: arrayChoices !== null && arrayChoices !== void 0 ? arrayChoices : [], getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, loading: loading, placeholder: props.placeholder, renderInput: renderInput, PaperComponent: CustomOption, renderOption: (props, option) => (_jsx(Box, Object.assign({ component: 'li', className: 'autocomplete-option', "data-value": option.id }, props, { children: option.label }))) }));
193
222
  };
194
223
  export default DynamicAutocomplete;
@@ -103,6 +103,7 @@ export const StyledAutocompleteTextField = styled(StyledTextField)(() => {
103
103
  return {
104
104
  '& .input-field': {
105
105
  paddingLeft: '9px',
106
+ maxHeight: '25px',
106
107
  },
107
108
  };
108
109
  });
@@ -1,22 +1,22 @@
1
1
  /// <reference types="react" />
2
2
  import { PropertySpec } from '../../../api';
3
3
  import { ScalarEntityValue } from '../../../entity';
4
- import { NullableFormFieldFactoryChoices } from '../FormFieldFactory';
5
- import { SelectOptionsType } from 'entities/EntityInterface';
6
4
  import { FormOnChangeEvent } from 'entities/DefaultEntityBehavior/Form/Form';
5
+ import EntityService from 'services/entity/EntityService';
6
+ import { NullableFormFieldFactoryChoices } from 'services/form';
7
7
  declare type DynamicAutocompleteFactoryPropsType = {
8
8
  fld: string;
9
9
  property: PropertySpec;
10
10
  disabled: boolean;
11
11
  multiSelect: boolean;
12
12
  value: ScalarEntityValue | Array<ScalarEntityValue>;
13
+ choices: NullableFormFieldFactoryChoices;
13
14
  hasChanged: boolean;
14
15
  error: React.ReactNode;
15
16
  touched: boolean | undefined;
16
17
  changeHandler: (event: FormOnChangeEvent) => void;
17
- choices: NullableFormFieldFactoryChoices;
18
18
  handleBlur: (event: React.FocusEvent) => void;
19
- selectOptions: (() => Promise<SelectOptionsType>) | undefined;
19
+ entityService: EntityService;
20
20
  };
21
21
  export declare const DynamicAutocompleteFactory: (props: DynamicAutocompleteFactoryPropsType) => JSX.Element;
22
22
  export {};
@@ -1,6 +1,43 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isPropertyFk } from '../../../api';
2
3
  import { DynamicAutocomplete } from '../../Field/DynamicAutocomplete';
4
+ import { Skeleton } from '@mui/material';
5
+ import { useEffect, useState } from 'react';
3
6
  export const DynamicAutocompleteFactory = (props) => {
4
- const { selectOptions, fld, disabled, multiSelect, value, hasChanged, error, touched, property, changeHandler, handleBlur, } = props;
5
- return (_jsx(DynamicAutocomplete, { name: fld, label: property.label, value: value, multiple: multiSelect, nullOption: property.null, required: property.required, disabled: disabled, onBlur: handleBlur, error: touched && Boolean(error), errorMsg: touched && error, helperText: property.helpText, hasChanged: hasChanged, onChange: changeHandler, selectOptions: selectOptions }));
7
+ const { entityService, fld, disabled, multiSelect, value, hasChanged, error, touched, property, changeHandler, handleBlur, } = props;
8
+ let { choices } = props;
9
+ const [selectOptionsLoader, setSelectOptionsLoader] = useState(undefined);
10
+ const cleanRef = isPropertyFk(property)
11
+ ? property.$ref.replace('#/definitions/', '')
12
+ : '';
13
+ useEffect(() => {
14
+ if (!cleanRef) {
15
+ return;
16
+ }
17
+ const selectOptionsGetter = entityService.getDynamicAutocompleteGetters({
18
+ entityService,
19
+ skip: [],
20
+ });
21
+ selectOptionsGetter.then((getters) => {
22
+ const selectOptions = getters[cleanRef];
23
+ if (selectOptions) {
24
+ setSelectOptionsLoader({ selectOptions: selectOptions });
25
+ }
26
+ });
27
+ }, [cleanRef, entityService]);
28
+ if (!selectOptionsLoader || !choices) {
29
+ return (_jsxs(_Fragment, { children: [_jsx(Skeleton, { width: '50%' }), _jsx(Skeleton, { variant: 'rectangular', height: 42 })] }));
30
+ }
31
+ if (property.null) {
32
+ if (Array.isArray(choices)) {
33
+ const nullAlreadyAssigned = choices.find((item) => item.id == '__null__');
34
+ if (!nullAlreadyAssigned) {
35
+ choices = [{ label: property.null, id: '__null__' }, ...choices];
36
+ }
37
+ }
38
+ else {
39
+ choices = Object.assign({ __null__: property.null }, choices);
40
+ }
41
+ }
42
+ return (_jsx(DynamicAutocomplete, { name: fld, label: property.label, value: value, choices: choices, multiple: multiSelect, nullOption: property.null, required: property.required, disabled: disabled, onBlur: handleBlur, error: touched && Boolean(error), errorMsg: touched && error, helperText: property.helpText, hasChanged: hasChanged, onChange: changeHandler, selectOptions: selectOptionsLoader.selectOptions }));
6
43
  };
@@ -13,6 +13,7 @@ export default class FormFieldFactory {
13
13
  private divRef?;
14
14
  constructor(entityService: EntityService, formik: useFormikType, changeHandler: (event: FormOnChangeEvent) => void, handleBlur: (event: React.FocusEvent) => void, divRef?: React.RefObject<HTMLDivElement> | undefined);
15
15
  private getDynamicSelectOptions;
16
+ private isDynamicAutocomplete;
16
17
  getFormField(fld: string, choices: NullableFormFieldFactoryChoices, readOnly?: boolean): JSX.Element | null;
17
18
  createByPropertySpec(fld: string, property: PropertySpec, choices: NullableFormFieldFactoryChoices, readOnly?: boolean): JSX.Element | null;
18
19
  getProperty(fld: string): PropertySpec | null;
@@ -25,6 +25,18 @@ export default class FormFieldFactory {
25
25
  }
26
26
  return entities[entityName].selectOptions;
27
27
  }
28
+ isDynamicAutocomplete(property) {
29
+ var _a;
30
+ if (!isPropertyFk(property)) {
31
+ return false;
32
+ }
33
+ const entities = StoreContainer.store.getState().entities.entities;
34
+ const cleanRef = property.$ref.replace('#/definitions/', '');
35
+ if (!((_a = entities[cleanRef]) === null || _a === void 0 ? void 0 : _a.dynamicSelectOptions)) {
36
+ return false;
37
+ }
38
+ return true;
39
+ }
28
40
  getFormField(fld, choices, readOnly = false) {
29
41
  const property = this.getProperty(fld);
30
42
  if (!property) {
@@ -47,9 +59,8 @@ export default class FormFieldFactory {
47
59
  .component;
48
60
  return (_jsx(PropertyComponent, { _context: CustomFunctionComponentContext.write, _columnName: fld, readOnly: readOnly, formik: this.formik, values: this.formik.values, choices: choices, property: property, disabled: disabled, changeHandler: this.changeHandler, onBlur: this.handleBlur, formFieldFactory: this }));
49
61
  }
50
- const dynamicSelectOptions = this.getDynamicSelectOptions(property);
51
- if (dynamicSelectOptions) {
52
- return (_jsx(DynamicAutocompleteFactory, { fld: fld, property: property, disabled: disabled, multiSelect: multiSelect, value: value, hasChanged: hasChanged, error: error, touched: touched, selectOptions: dynamicSelectOptions, choices: choices, changeHandler: this.changeHandler, handleBlur: this.handleBlur }));
62
+ if (this.isDynamicAutocomplete(property)) {
63
+ return (_jsx(DynamicAutocompleteFactory, { fld: fld, property: property, disabled: disabled, multiSelect: multiSelect, value: value, hasChanged: hasChanged, error: error, touched: touched, choices: choices, changeHandler: this.changeHandler, handleBlur: this.handleBlur, entityService: this.entityService }));
53
64
  }
54
65
  if (isPropertyFk(property) || multiSelect) {
55
66
  return (_jsx(AutocompleteFactory, { fld: fld, property: property, disabled: disabled, multiSelect: multiSelect, value: value, hasChanged: hasChanged, error: error, touched: touched, choices: choices, changeHandler: this.changeHandler, handleBlur: this.handleBlur }));