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