@evoke-platform/ui-components 1.11.0-dev.2 → 1.11.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -1
- package/dist/published/components/custom/FormField/FormField.js +2 -1
- package/dist/published/components/custom/FormV2/FormRendererContainer.js +18 -1
- package/dist/published/components/custom/FormV2/components/PropertyProtection.js +1 -1
- package/dist/published/components/custom/ViewDetailsV2/InstanceEntryRenderer.js +2 -2
- package/package.json +1 -1
|
@@ -25,7 +25,8 @@ function asCalendarDate(value) {
|
|
|
25
25
|
const asMonthDayYearFormat = (date) => {
|
|
26
26
|
if (date) {
|
|
27
27
|
const formatter = DateTimeFormatter.ofPattern('MM/dd/yyyy');
|
|
28
|
-
|
|
28
|
+
const localDate = date instanceof LocalDate ? date : LocalDate.parse(date);
|
|
29
|
+
return localDate.format(formatter);
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
const DatePickerSelect = (props) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNil } from 'lodash';
|
|
1
2
|
import React, { useEffect, useState } from 'react';
|
|
2
3
|
import PropertyProtection from '../FormV2/components/PropertyProtection';
|
|
3
4
|
import AddressFieldComponent from './AddressFieldComponent/addressFieldComponent';
|
|
@@ -18,7 +19,7 @@ const FormField = (props) => {
|
|
|
18
19
|
setCurrentDisplayValue(defaultValue);
|
|
19
20
|
}
|
|
20
21
|
}, [defaultValue]);
|
|
21
|
-
const protectionComponent = isProtectedProperty &&
|
|
22
|
+
const protectionComponent = isProtectedProperty && !isNil(defaultValue) ? (React.createElement(PropertyProtection, { parameter: property, protection: protection, mask: mask ?? (readOnly ? property.mask : undefined), canEdit: !readOnly, value: defaultValue, handleChange: (value) => onChange?.(property.id, value, property), setCurrentDisplayValue: setCurrentDisplayValue, mode: protectionMode, setMode: setProtectionMode, instance: props.instance, apiServices: props.apiServices })) : null;
|
|
22
23
|
const commonProps = {
|
|
23
24
|
id: id ?? property.id,
|
|
24
25
|
property,
|
|
@@ -357,6 +357,22 @@ function FormRendererContainer(props) {
|
|
|
357
357
|
}
|
|
358
358
|
return result;
|
|
359
359
|
};
|
|
360
|
+
const removeUneditedProtectedValues = (data) => {
|
|
361
|
+
const protectedProperties = sanitizedObject?.properties?.filter((prop) => prop.protection?.maskChar);
|
|
362
|
+
if (!protectedProperties || protectedProperties.length === 0) {
|
|
363
|
+
return data;
|
|
364
|
+
}
|
|
365
|
+
const filteredData = { ...data };
|
|
366
|
+
protectedProperties.forEach((property) => {
|
|
367
|
+
const fieldId = property.id;
|
|
368
|
+
const originalValue = instance?.[fieldId];
|
|
369
|
+
const currentValue = filteredData[fieldId];
|
|
370
|
+
if (currentValue === originalValue) {
|
|
371
|
+
delete filteredData[fieldId];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
return filteredData;
|
|
375
|
+
};
|
|
360
376
|
const handleAutosave = async (fieldId) => {
|
|
361
377
|
if (!form?.autosaveActionId || !formDataRef.current) {
|
|
362
378
|
return;
|
|
@@ -368,7 +384,8 @@ function FormRendererContainer(props) {
|
|
|
368
384
|
}
|
|
369
385
|
try {
|
|
370
386
|
setIsSaving(true);
|
|
371
|
-
const
|
|
387
|
+
const cleanedData = removeUneditedProtectedValues(formDataRef.current);
|
|
388
|
+
const submission = await formatSubmission(cleanedData, apiServices, objectId, instanceId, form, setSnackbarError);
|
|
372
389
|
// Handle document autosave
|
|
373
390
|
if (dataType === 'documents' && document) {
|
|
374
391
|
await apiServices.patch(getPrefixedUrl(`/objects/${objectId}/instances/${instanceId}/documents/${documentId}`), pick(submission, ['metadata']).metadata ?? submission);
|
|
@@ -36,7 +36,7 @@ const PropertyProtection = (props) => {
|
|
|
36
36
|
const [isLoading, setIsLoading] = useState(hasViewPermission === undefined);
|
|
37
37
|
const [error, setError] = useState(null);
|
|
38
38
|
useEffect(() => {
|
|
39
|
-
if (hasViewPermission === undefined && (instance || instanceFormV1)) {
|
|
39
|
+
if (hasViewPermission === undefined && (instance?.id || instanceFormV1?.id)) {
|
|
40
40
|
apiServices
|
|
41
41
|
.get(getPrefixedUrl(`/objects/${object?.id ?? instanceFormV1?.objectId}/instances/${instance?.id ?? instanceFormV1?.id}/checkAccess?action=readProtected&fieldId=${parameter.id}`))
|
|
42
42
|
.then((viewPermissionCheck) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useApiServices, useApp, } from '@evoke-platform/context';
|
|
2
2
|
import { CancelRounded, CheckCircleRounded } from '@mui/icons-material';
|
|
3
3
|
import DOMPurify from 'dompurify';
|
|
4
|
-
import { isEmpty } from 'lodash';
|
|
4
|
+
import { isEmpty, isNil } from 'lodash';
|
|
5
5
|
import { DateTime } from 'luxon';
|
|
6
6
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { useFormContext } from '../../../theme/hooks';
|
|
@@ -44,7 +44,7 @@ function ViewOnlyEntryRenderer(props) {
|
|
|
44
44
|
return def;
|
|
45
45
|
}, [entry, object]);
|
|
46
46
|
const isProtectedProperty = fieldDefinition?.protection?.maskChar;
|
|
47
|
-
const protectionComponent = isProtectedProperty ? (React.createElement(PropertyProtection, { parameter: fieldDefinition, protection: fieldDefinition?.protection, mask: fieldDefinition?.mask, value: currentDisplayValue, canEdit: false, setCurrentDisplayValue: setCurrentDisplayValue, mode: protectionMode, setMode: setProtectionMode })) : null;
|
|
47
|
+
const protectionComponent = isProtectedProperty && !isNil(currentDisplayValue) ? (React.createElement(PropertyProtection, { parameter: fieldDefinition, protection: fieldDefinition?.protection, mask: fieldDefinition?.mask, value: currentDisplayValue, canEdit: false, setCurrentDisplayValue: setCurrentDisplayValue, mode: protectionMode, setMode: setProtectionMode })) : null;
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
if (fieldDefinition?.type === 'collection' && fieldDefinition?.manyToManyPropertyId && instance) {
|
|
50
50
|
fetchCollectionData(apiServices, fieldDefinition, setFetchedOptions, instance.id, fetchedOptions, initialMiddleObjectInstances);
|