@evoke-platform/ui-components 1.11.1-dev.1 → 1.11.1-dev.2
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useApiServices, useApp, useAuthenticationContext, useNavigate, useObject, } from '@evoke-platform/context';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { cloneDeep, get, isArray, isEmpty, isEqual, omit, pick, set
|
|
3
|
+
import { cloneDeep, get, isArray, isEmpty, isEqual, omit, pick, set } from 'lodash';
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { Skeleton, Snackbar } from '../../core';
|
|
6
6
|
import { Box } from '../../layout';
|
|
7
7
|
import ErrorComponent from '../ErrorComponent';
|
|
8
8
|
import { evalDefaultVals, processValueUpdate } from './components/DefaultValues';
|
|
9
9
|
import Header from './components/Header';
|
|
10
|
-
import { convertDocToEntries, deleteDocuments, encodePageSlug, formatDataToDoc, formatSubmission, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, plainTextToRtf, } from './components/utils';
|
|
10
|
+
import { convertDocToEntries, convertPropertiesToParams, deleteDocuments, encodePageSlug, formatDataToDoc, formatSubmission, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, plainTextToRtf, } from './components/utils';
|
|
11
11
|
import FormRenderer from './FormRenderer';
|
|
12
12
|
function FormRendererContainer(props) {
|
|
13
13
|
const { instanceId, pageNavigation, documentId, dataType, display, formId, objectId, actionId, richTextEditor, onSubmit, onDiscardChanges: onDiscardChangesOverride, associatedObject, renderContainer, onSubmitError, sx, renderHeader, renderBody, renderFooter, } = props;
|
|
@@ -149,29 +149,12 @@ function FormRendererContainer(props) {
|
|
|
149
149
|
}
|
|
150
150
|
}, [action, actionId, objectId, instance]);
|
|
151
151
|
useEffect(() => {
|
|
152
|
-
if (form
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
id: 'view_permission',
|
|
161
|
-
name: 'View Permission',
|
|
162
|
-
type: 'string',
|
|
163
|
-
enum: ['Public', 'Private', 'Portal'],
|
|
164
|
-
},
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
167
|
-
else if (form) {
|
|
168
|
-
const unnestedEntries = getUnnestedEntries(form.entries);
|
|
169
|
-
const inputFieldParams = unnestedEntries
|
|
170
|
-
.filter((entry) => entry.type === 'inputField')
|
|
171
|
-
.map((entry) => entry.input);
|
|
172
|
-
setParameters(uniq([...(action?.parameters ?? []), ...inputFieldParams]));
|
|
173
|
-
}
|
|
174
|
-
}, [form, action]);
|
|
152
|
+
if (!form)
|
|
153
|
+
return;
|
|
154
|
+
// If no parameters are defined, then the action is synced with object properties
|
|
155
|
+
const getParamsFromObject = sanitizedObject && !action?.parameters;
|
|
156
|
+
setParameters(getParamsFromObject ? convertPropertiesToParams(sanitizedObject) : action?.parameters);
|
|
157
|
+
}, [form, action?.parameters, sanitizedObject]);
|
|
175
158
|
useEffect(() => {
|
|
176
159
|
const getInitialValues = async () => {
|
|
177
160
|
if (document && objectId) {
|