@evoke-platform/ui-components 1.8.0-testing.4 → 1.8.0-testing.6

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 (23) hide show
  1. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +4 -0
  2. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +4 -0
  3. package/dist/published/components/custom/FormV2/FormRenderer.d.ts +4 -0
  4. package/dist/published/components/custom/FormV2/FormRenderer.js +13 -14
  5. package/dist/published/components/custom/FormV2/FormRendererContainer.d.ts +4 -0
  6. package/dist/published/components/custom/FormV2/FormRendererContainer.js +60 -108
  7. package/dist/published/components/custom/FormV2/components/FormContext.d.ts +4 -0
  8. package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +9 -5
  9. package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.js +12 -24
  10. package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.d.ts +5 -1
  11. package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +80 -30
  12. package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.js +1 -1
  13. package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +51 -27
  14. package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.d.ts +5 -5
  15. package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.js +45 -7
  16. package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.js +7 -4
  17. package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.d.ts +3 -0
  18. package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.js +1 -3
  19. package/dist/published/components/custom/FormV2/components/types.d.ts +7 -1
  20. package/dist/published/components/custom/FormV2/components/utils.d.ts +27 -2
  21. package/dist/published/components/custom/FormV2/components/utils.js +107 -1
  22. package/dist/published/theme/hooks.d.ts +4 -0
  23. package/package.json +2 -2
@@ -230,6 +230,10 @@ export const ObjectPropertyInput = (props) => {
230
230
  ? (options.find((o) => o.id === option)?.name ?? '')
231
231
  : option.label;
232
232
  }, onKeyDownCapture: (e) => {
233
+ // prevents keyboard trap
234
+ if (e.key === 'Tab') {
235
+ return;
236
+ }
233
237
  if (instance?.[property.id]?.id || selectedInstance?.id) {
234
238
  e.preventDefault();
235
239
  }
@@ -89,6 +89,10 @@ export const UserProperty = (props) => {
89
89
  }
90
90
  }
91
91
  }, onKeyDownCapture: (e) => {
92
+ // prevents keyboard trap
93
+ if (e.key === 'Tab') {
94
+ return;
95
+ }
92
96
  if (value) {
93
97
  e.preventDefault();
94
98
  }
@@ -14,6 +14,10 @@ export type FormProps = BaseProps & {
14
14
  instance?: ObjectInstance | Document;
15
15
  onChange: (id: string, value: unknown) => void;
16
16
  onValidationChange?: (errors: FieldErrors) => void;
17
+ associatedObject?: {
18
+ instanceId?: string;
19
+ propertyId?: string;
20
+ };
17
21
  };
18
22
  declare function FormRenderer(props: FormProps): React.JSX.Element;
19
23
  export default FormRenderer;
@@ -1,5 +1,5 @@
1
1
  import { useObject } from '@evoke-platform/context';
2
- import { isEqual } from 'lodash';
2
+ import { isEmpty, isEqual } from 'lodash';
3
3
  import React, { useEffect, useMemo, useState } from 'react';
4
4
  import { useForm } from 'react-hook-form';
5
5
  import { useResponsive } from '../../../theme';
@@ -12,7 +12,7 @@ import { convertDocToParameters, convertPropertiesToParams } from './components/
12
12
  import { handleValidation } from './components/ValidationFiles/Validation';
13
13
  import ValidationErrorDisplay from './components/ValidationFiles/ValidationErrorDisplay';
14
14
  function FormRenderer(props) {
15
- const { onSubmit, value, fieldHeight, richTextEditor, hideButtons, stickyFooter, onCancel, form, instance, onChange, onValidationChange, } = props;
15
+ const { onSubmit, value, fieldHeight, richTextEditor, hideButtons, stickyFooter, onCancel, form, instance, onChange, onValidationChange, associatedObject, } = props;
16
16
  const { entries, name: title, objectId, actionId, display } = form;
17
17
  const { register, unregister, setValue, reset, handleSubmit, formState: { errors, isSubmitted }, getValues, } = useForm({
18
18
  defaultValues: value,
@@ -99,10 +99,9 @@ function FormRenderer(props) {
99
99
  }, []);
100
100
  if (entries && parameters && (!actionId || action)) {
101
101
  return (React.createElement(React.Fragment, null,
102
- React.createElement(Box, { sx: {
102
+ ((isSubmitted && !isEmpty(errors)) || (isSmallerThanMd && hasSections) || title) && (React.createElement(Box, { sx: {
103
103
  paddingX: isSmallerThanMd ? 2 : 3,
104
104
  paddingTop: '0px',
105
- borderBottom: '2px solid #F4F6F8',
106
105
  } },
107
106
  React.createElement(Box, { sx: {
108
107
  display: 'flex',
@@ -111,13 +110,14 @@ function FormRenderer(props) {
111
110
  flexWrap: 'wrap',
112
111
  paddingY: isSm || isXs ? 2 : 3,
113
112
  } },
114
- React.createElement(Typography, { sx: {
113
+ title && (React.createElement(Typography, { sx: {
115
114
  fontSize: '20px',
116
115
  lineHeight: '30px',
117
116
  fontWeight: 700,
118
117
  flexGrow: '1',
119
- } }, title),
118
+ } }, title)),
120
119
  isSmallerThanMd && hasSections && (React.createElement(Box, { sx: {
120
+ color: '#212B36',
121
121
  display: 'flex',
122
122
  alignItems: 'center',
123
123
  maxHeight: '22px',
@@ -140,7 +140,7 @@ function FormRenderer(props) {
140
140
  fontWeight: 400,
141
141
  fontSize: '14px',
142
142
  }, onClick: handleCollapseAll }, "Collapse all")))),
143
- React.createElement(ValidationErrorDisplay, { formId: form.id, title: title })),
143
+ React.createElement(ValidationErrorDisplay, { formId: form.id, title: title, errors: errors, showSubmitError: isSubmitted }))),
144
144
  React.createElement(FormContext.Provider, { value: {
145
145
  fetchedOptions,
146
146
  setFetchedOptions: updateFetchedOptions,
@@ -159,26 +159,25 @@ function FormRenderer(props) {
159
159
  handleChange: onChange,
160
160
  triggerFieldReset,
161
161
  showSubmitError: isSubmitted,
162
+ associatedObject,
162
163
  } },
163
164
  React.createElement(Box, { sx: {
164
- padding: isModal ? '0px' : isSm || isXs ? 2 : 3,
165
- paddingBottom: '0px',
166
- paddingTop: !hasSections ? undefined : '0px',
165
+ paddingX: isSm || isXs ? 2 : 3,
166
+ // when rendering the default delete action, we don't want a border
167
+ borderTop: !form.id || isModal ? undefined : '1px solid #e9ecef',
167
168
  } },
168
169
  entries.map((entry, index) => (React.createElement(RecursiveEntryRenderer, { key: index, entry: entry, isDocument: !!(form.id === 'documentForm') }))),
169
170
  !hideButtons && (actionId || form.id === 'documentForm') && onSubmit && (React.createElement(Box, { sx: {
170
171
  ...(stickyFooter === false ? { position: 'static' } : { position: 'sticky' }),
171
- bottom: isModal ? -5 : isSmallerThanMd ? 0 : 24,
172
+ bottom: isModal || isSmallerThanMd ? 0 : 24,
172
173
  zIndex: 1000,
173
174
  borderTop: action?.type !== 'delete' ? '1px solid #f4f6f8' : 'none',
174
175
  backgroundColor: '#fff',
175
- paddingY: isSmallerThanMd ? '16px' : '20px',
176
- paddingX: isSmallerThanMd ? '16px' : '20px',
176
+ padding: isSmallerThanMd ? '16px' : '20px',
177
177
  display: 'flex',
178
178
  justifyContent: isXs ? 'center' : 'flex-end',
179
179
  alignItems: 'center',
180
180
  marginX: isSmallerThanMd ? -2 : -3,
181
- marginBottom: '1px',
182
181
  borderRadius: '0px 0px 6px 6px',
183
182
  } },
184
183
  React.createElement(ActionButtons, { onSubmit: onSubmit, handleSubmit: handleSubmit, isModal: isModal, actionType: action?.type, submitButtonLabel: display?.submitLabel, onReset: handleReset, unregister: unregister, entries: entries, setValue: setValue, formId: form.id })))))));
@@ -16,6 +16,10 @@ export type FormProps = BaseProps & {
16
16
  richTextEditor?: ComponentType<SimpleEditorProps>;
17
17
  onClose?: () => void;
18
18
  onSubmit?: (submission: Record<string, unknown>) => Promise<void>;
19
+ associatedObject?: {
20
+ instanceId?: string;
21
+ propertyId?: string;
22
+ };
19
23
  };
20
24
  declare function FormRendererContainer(props: FormProps): React.JSX.Element;
21
25
  export default FormRendererContainer;
@@ -1,5 +1,4 @@
1
1
  import { useApiServices, useApp, useAuthenticationContext, useNavigate, useObject, } from '@evoke-platform/context';
2
- import { LocalDateTime } from '@js-joda/core';
3
2
  import axios from 'axios';
4
3
  import { get, isArray, isEmpty, isEqual, merge, omit, pick, set, uniq } from 'lodash';
5
4
  import React, { useEffect, useState } from 'react';
@@ -7,10 +6,10 @@ import { Skeleton, Snackbar } from '../../core';
7
6
  import { Box } from '../../layout';
8
7
  import ErrorComponent from '../ErrorComponent';
9
8
  import { evalDefaultVals, processValueUpdate } from './components/DefaultValues';
10
- import { convertDocToEntries, encodePageSlug, formatDataToDoc, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, normalizeDateTime, } from './components/utils';
9
+ import { convertDocToEntries, deleteDocuments, encodePageSlug, formatDataToDoc, formatSubmission, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, } from './components/utils';
11
10
  import FormRenderer from './FormRenderer';
12
11
  function FormRendererContainer(props) {
13
- const { instanceId, pageNavigation, documentId, dataType, display, formId, stickyFooter, objectId, actionId, richTextEditor, } = props;
12
+ const { instanceId, pageNavigation, documentId, dataType, display, formId, stickyFooter, objectId, actionId, richTextEditor, onClose, onSubmit, associatedObject, } = props;
14
13
  const apiServices = useApiServices();
15
14
  const navigateTo = useNavigate();
16
15
  const { id: appId, defaultPages } = useApp();
@@ -101,7 +100,8 @@ function FormRendererContainer(props) {
101
100
  .get(getPrefixedUrl(`data/forms/${formId || action?.defaultFormId}`))
102
101
  .then((evokeForm) => {
103
102
  if (evokeForm?.actionId === actionId) {
104
- setForm(evokeForm);
103
+ const form = onClose ? { ...evokeForm, name: '' } : evokeForm;
104
+ setForm(form);
105
105
  }
106
106
  else {
107
107
  setError(true);
@@ -111,24 +111,50 @@ function FormRendererContainer(props) {
111
111
  onError(error);
112
112
  });
113
113
  }
114
- else if (action && !action?.defaultFormId) {
114
+ else if (action) {
115
115
  apiServices
116
- .get(getPrefixedUrl(`data/forms?filter[where][actionId]=${action.id}`))
116
+ .get(getPrefixedUrl('data/forms'), {
117
+ params: {
118
+ filter: {
119
+ where: {
120
+ actionId: action.id,
121
+ objectId: objectId,
122
+ },
123
+ },
124
+ },
125
+ })
117
126
  .then((matchingForms) => {
118
127
  if (matchingForms.length === 1) {
119
- if (matchingForms[0]?.actionId === actionId) {
120
- setForm(matchingForms[0]);
121
- }
122
- else {
123
- setError(true);
124
- }
128
+ const form = onClose ? { ...matchingForms[0], name: '' } : matchingForms[0];
129
+ setForm(form);
130
+ // use this default form if no delete form is found
131
+ }
132
+ else if (action.type === 'delete' && instance) {
133
+ setForm({
134
+ id: '',
135
+ name: '',
136
+ entries: [
137
+ {
138
+ type: 'content',
139
+ html: `<p>You are about to delete <strong>${instance.name}</strong>. Deleted records can't be restored. Are you sure you want to continue?</p>`,
140
+ },
141
+ ],
142
+ objectId: objectId,
143
+ actionId: '_delete',
144
+ display: {
145
+ submitLabel: 'Delete',
146
+ },
147
+ });
148
+ }
149
+ else if (instance) {
150
+ setError(true);
125
151
  }
126
152
  })
127
153
  .catch((error) => {
128
154
  onError(error);
129
155
  });
130
156
  }
131
- }, [action]);
157
+ }, [action, objectId, instance]);
132
158
  useEffect(() => {
133
159
  if (form?.id === 'documentForm') {
134
160
  setParameters([
@@ -174,54 +200,6 @@ function FormRendererContainer(props) {
174
200
  };
175
201
  getInitialValues();
176
202
  }, [form, instance, sanitizedObject]);
177
- const uploadDocuments = async (files, metadata) => {
178
- const allDocuments = [];
179
- const formData = new FormData();
180
- for (const [index, file] of files.entries()) {
181
- if ('size' in file) {
182
- formData.append(`files[${index}]`, file);
183
- }
184
- else {
185
- allDocuments.push(file);
186
- }
187
- }
188
- if (metadata) {
189
- for (const [key, value] of Object.entries(metadata)) {
190
- formData.append(key, value);
191
- }
192
- }
193
- const docs = await apiServices?.post(getPrefixedUrl(`/objects/${form?.objectId}/instances/${instanceId}/documents`), formData);
194
- return allDocuments.concat(docs?.map((doc) => ({
195
- id: doc.id,
196
- name: doc.name,
197
- })) ?? []);
198
- };
199
- const deleteDocuments = async (submittedFields, requestSuccess, action) => {
200
- const documentProperties = action?.parameters
201
- ? action.parameters.filter((param) => param.type === 'document')
202
- : sanitizedObject?.properties?.filter((prop) => prop.type === 'document');
203
- for (const docProperty of documentProperties ?? []) {
204
- const savedValue = submittedFields[docProperty.id];
205
- const originalValue = instance?.[docProperty.id];
206
- const documentsToRemove = requestSuccess
207
- ? (originalValue?.filter((file) => !savedValue?.some((f) => f.id === file.id)) ?? [])
208
- : (savedValue?.filter((file) => !originalValue?.some((f) => f.id === file.id)) ?? []);
209
- for (const doc of documentsToRemove) {
210
- try {
211
- await apiServices?.delete(getPrefixedUrl(`/objects/${form?.objectId}/instances/${instanceId}/documents/${doc.id}`));
212
- }
213
- catch (error) {
214
- if (error) {
215
- setSnackbarError({
216
- showAlert: true,
217
- message: `An error occurred while removing document '${doc.name}'`,
218
- isError: true,
219
- });
220
- }
221
- }
222
- }
223
- }
224
- };
225
203
  const onSubmissionSuccess = (updatedInstance) => {
226
204
  setSnackbarError({
227
205
  showAlert: true,
@@ -247,47 +225,7 @@ function FormRendererContainer(props) {
247
225
  const saveHandler = async (submission) => {
248
226
  if (!form)
249
227
  return;
250
- // checks for a file upload and handles getting the new format to upload
251
- for (const [key, value] of Object.entries(submission)) {
252
- if (isArray(value)) {
253
- const fileInArray = value.some((item) => item instanceof File);
254
- if (fileInArray) {
255
- try {
256
- const uploadedDocuments = await uploadDocuments(value, {
257
- type: '',
258
- view_permission: '',
259
- });
260
- submission[key] = uploadedDocuments;
261
- }
262
- catch (err) {
263
- if (err) {
264
- setSnackbarError({
265
- showAlert: true,
266
- message: `An error occurred while uploading associated documents`,
267
- isError: true,
268
- });
269
- }
270
- return;
271
- }
272
- }
273
- // if there are address fields with no value address needs to be set to undefined to be able to submit
274
- }
275
- else if (typeof value === 'object' && value !== null) {
276
- if (Object.values(value).every((v) => v === undefined)) {
277
- submission[key] = undefined;
278
- // only submit the name and id of a related object
279
- }
280
- else if ('id' in value && 'name' in value) {
281
- submission[key] = pick(value, 'id', 'name');
282
- }
283
- }
284
- else if ((value === '' && !document) || value === undefined) {
285
- submission[key] = null;
286
- }
287
- else if (value instanceof LocalDateTime) {
288
- submission[key] = normalizeDateTime(value);
289
- }
290
- }
228
+ submission = await formatSubmission(submission, apiServices, objectId, instanceId, setSnackbarError);
291
229
  if (document) {
292
230
  submission = formatDataToDoc(submission);
293
231
  }
@@ -331,9 +269,9 @@ function FormRendererContainer(props) {
331
269
  ?.filter((property) => !property.formula && property.type !== 'collection')
332
270
  .map((property) => property.id) ?? []),
333
271
  });
334
- if (response) {
272
+ if (response && sanitizedObject && instance) {
335
273
  onSubmissionSuccess(response);
336
- deleteDocuments(submission, !!response, action ?? undefined);
274
+ deleteDocuments(submission, !!response, apiServices, sanitizedObject, instance, action ?? undefined, setSnackbarError);
337
275
  }
338
276
  }
339
277
  }
@@ -393,7 +331,17 @@ function FormRendererContainer(props) {
393
331
  const fieldValue = instanceData?.[fieldId] ??
394
332
  instanceData?.metadata?.[fieldId];
395
333
  const parameter = parameters?.find((param) => param.id === fieldId);
396
- if (entry.type !== 'readonlyField' && isEmptyWithDefault(fieldValue, entry, instanceData)) {
334
+ if (associatedObject?.propertyId === fieldId && associatedObject?.instanceId && parameter) {
335
+ try {
336
+ const instance = await apiServices.get(getPrefixedUrl(`/objects/${parameter.objectId}/instances/${associatedObject.instanceId}`));
337
+ result[associatedObject.propertyId] = instance;
338
+ }
339
+ catch (error) {
340
+ console.error(error);
341
+ }
342
+ }
343
+ else if (entry.type !== 'readonlyField' &&
344
+ isEmptyWithDefault(fieldValue, entry, instanceData)) {
397
345
  if (fieldId && parameters && parameters.length > 0) {
398
346
  const defaultValuesArray = await evalDefaultVals(parameters, entry, fieldValue, fieldId, apiServices, userAccount, instanceData);
399
347
  for (const { fieldId, fieldValue } of defaultValuesArray) {
@@ -463,9 +411,13 @@ function FormRendererContainer(props) {
463
411
  })();
464
412
  }
465
413
  const isLoading = (instanceId && !formData && !document) || !form || !sanitizedObject;
466
- return !error ? (React.createElement(React.Fragment, null,
467
- !isLoading ? (React.createElement(React.Fragment, null,
468
- React.createElement(FormRenderer, { onSubmit: saveHandler, hideButtons: document && !hasDocumentUpdateAccess, richTextEditor: richTextEditor, fieldHeight: display?.fieldHeight ?? 'medium', value: formData, stickyFooter: stickyFooter, form: form, instance: dataType !== 'documents' ? instance : document, onChange: onChange, onCancel: onCancel }))) : (React.createElement(Box, { sx: { padding: '20px' } },
414
+ return !error ? (React.createElement(Box, { sx: {
415
+ backgroundColor: '#ffffff',
416
+ borderRadius: '6px',
417
+ padding: '0px',
418
+ border: !isLoading && !onClose ? '1px solid #dbe0e4' : undefined,
419
+ } },
420
+ !isLoading ? (React.createElement(FormRenderer, { onSubmit: onSubmit ?? saveHandler, hideButtons: document && !hasDocumentUpdateAccess, richTextEditor: richTextEditor, fieldHeight: display?.fieldHeight ?? 'medium', value: formData, stickyFooter: stickyFooter, form: form, instance: dataType !== 'documents' ? instance : document, onChange: onChange, onCancel: onClose ?? onCancel, associatedObject: associatedObject })) : (React.createElement(Box, { sx: { padding: '20px' } },
469
421
  React.createElement(Box, { display: 'flex', width: '100%', justifyContent: 'space-between' },
470
422
  React.createElement(Skeleton, { width: '78%', sx: { borderRadius: '8px', height: '40px' } }),
471
423
  React.createElement(Skeleton, { width: '20%', sx: { borderRadius: '8px', height: '40px' } })),
@@ -20,6 +20,10 @@ type FormContextType = {
20
20
  fieldHeight?: 'small' | 'medium';
21
21
  triggerFieldReset?: boolean;
22
22
  showSubmitError?: boolean;
23
+ associatedObject?: {
24
+ instanceId?: string;
25
+ propertyId?: string;
26
+ };
23
27
  };
24
28
  export declare const FormContext: import("react").Context<FormContextType>;
25
29
  export {};
@@ -1,14 +1,18 @@
1
- import { Action, ActionType, EvokeForm, InputParameter, Obj } from '@evoke-platform/context';
1
+ import { Action, InputParameter, Obj } from '@evoke-platform/context';
2
2
  import React from 'react';
3
+ import { FieldValues } from 'react-hook-form';
3
4
  export type ActionDialogProps = {
4
5
  open: boolean;
5
6
  onClose: () => void;
6
7
  action: Action;
7
- instanceInput: Record<string, unknown>;
8
- handleSubmit: (actionType: ActionType, input: Record<string, unknown> | undefined, instanceId?: string, setSubmitting?: (value: boolean) => void) => void;
8
+ handleSubmit: (action: Action, input: FieldValues, instanceId?: string, setSubmitting?: (value: boolean) => void) => void;
9
9
  object: Obj;
10
10
  instanceId?: string;
11
- relatedParameter?: InputParameter;
12
- relatedForm?: EvokeForm;
11
+ relatedParameter: InputParameter;
12
+ relatedFormId?: string;
13
+ associatedObject?: {
14
+ instanceId?: string;
15
+ propertyId?: string;
16
+ };
13
17
  };
14
18
  export declare const ActionDialog: (props: ActionDialogProps) => React.JSX.Element;
@@ -1,9 +1,11 @@
1
1
  import { useApiServices } from '@evoke-platform/context';
2
2
  import { Close } from '@mui/icons-material';
3
3
  import React, { useEffect, useState } from 'react';
4
+ import { useFormContext } from '../../../../../../theme/hooks';
4
5
  import { Dialog, DialogContent, DialogTitle, IconButton, Skeleton } from '../../../../../core';
5
6
  import { Box } from '../../../../../layout';
6
7
  import ErrorComponent from '../../../../ErrorComponent';
8
+ import FormRendererContainer from '../../../FormRendererContainer';
7
9
  import { getPrefixedUrl } from '../../utils';
8
10
  const styles = {
9
11
  button: {
@@ -36,12 +38,11 @@ const styles = {
36
38
  },
37
39
  };
38
40
  export const ActionDialog = (props) => {
39
- const { open, onClose, action, object, instanceId, relatedForm, instanceInput } = props;
41
+ const { open, onClose, action, object, instanceId, relatedFormId, relatedParameter, handleSubmit, associatedObject, } = props;
40
42
  const [loading, setLoading] = useState(false);
41
43
  const [hasAccess, setHasAccess] = useState();
42
- const [form, setForm] = useState();
44
+ const { stickyFooter, fieldHeight, richTextEditor } = useFormContext();
43
45
  const apiServices = useApiServices();
44
- const isDeleteAction = action.type === 'delete';
45
46
  useEffect(() => {
46
47
  if (instanceId) {
47
48
  setLoading(true);
@@ -57,31 +58,18 @@ export const ActionDialog = (props) => {
57
58
  setLoading(false);
58
59
  }
59
60
  }, [object, instanceId]);
60
- useEffect(() => {
61
- setForm(isDeleteAction && !form
62
- ? {
63
- id: '',
64
- name: '',
65
- entries: [
66
- {
67
- type: 'content',
68
- html: `<p>You are about to delete ${instanceInput?.name}. Deleted records can't be restored. Are you sure you want to continue?</p>`,
69
- },
70
- ],
71
- objectId: object.id,
72
- actionId: '_delete',
73
- display: {
74
- submitLabel: 'Delete',
75
- },
76
- }
77
- : relatedForm);
78
- }, [relatedForm, action, form]);
61
+ const handleFormSave = async (data) => {
62
+ return handleSubmit(action, data, instanceId);
63
+ };
79
64
  return (React.createElement(Dialog, { maxWidth: 'md', fullWidth: true, open: open, onClose: (e, reason) => reason !== 'backdropClick' && onClose() },
80
- React.createElement(DialogTitle, { sx: styles.dialogTitle },
65
+ React.createElement(DialogTitle, { sx: { ...styles.dialogTitle, borderBottom: action.type === 'delete' ? undefined : '1px solid #e9ecef' } },
81
66
  React.createElement(IconButton, { sx: styles.closeIcon, onClick: onClose },
82
67
  React.createElement(Close, { fontSize: "small" })),
83
68
  action && hasAccess && !loading ? action?.name : ''),
84
- React.createElement(DialogContent, { sx: { paddingBottom: loading ? undefined : '0px' } }, hasAccess ? (React.createElement(Box, { sx: { width: '100%', marginTop: '10px' } })) : (React.createElement(React.Fragment, null, loading ? (React.createElement(React.Fragment, null,
69
+ React.createElement(DialogContent, { sx: { paddingBottom: loading ? undefined : '0px' } }, hasAccess ? (React.createElement(Box, { sx: { width: '100%', marginTop: '10px' } },
70
+ React.createElement(FormRendererContainer, { instanceId: instanceId, formId: relatedFormId, display: { fieldHeight: fieldHeight ?? 'medium' }, actionId: action.id, stickyFooter: stickyFooter,
71
+ // relatedParameter will have an objectId here
72
+ objectId: relatedParameter.objectId, onClose: onClose, onSubmit: handleFormSave, richTextEditor: richTextEditor, associatedObject: associatedObject }))) : (React.createElement(React.Fragment, null, loading ? (React.createElement(React.Fragment, null,
85
73
  React.createElement(Skeleton, { height: '30px', animation: 'wave' }),
86
74
  React.createElement(Skeleton, { height: '30px', animation: 'wave' }),
87
75
  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,10 +1,14 @@
1
- import { InputParameter, Property, ViewLayoutEntityReference } from '@evoke-platform/context';
1
+ import { InputField, InputParameter, InputParameterReference, Property, ReadonlyField, ViewLayoutEntityReference } from '@evoke-platform/context';
2
2
  import React from 'react';
3
3
  export type ObjectPropertyInputProps = {
4
4
  fieldDefinition: InputParameter | Property;
5
5
  canUpdateProperty: boolean;
6
6
  criteria?: object;
7
7
  viewLayout?: ViewLayoutEntityReference;
8
+ entry: InputField | InputParameterReference | ReadonlyField;
9
+ createActionId?: string;
10
+ updateActionId?: string;
11
+ deleteActionId?: string;
8
12
  };
9
13
  declare const RepeatableField: (props: ObjectPropertyInputProps) => React.JSX.Element;
10
14
  export default RepeatableField;