@evoke-platform/ui-components 1.11.0-dev.1 → 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.
@@ -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
- return LocalDate.parse(date).format(formatter);
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 && !!defaultValue ? (React.createElement(PropertyProtection, { parameter: property, protection: protection, mask: mask, 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
+ 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 submission = await formatSubmission(formDataRef.current, apiServices, objectId, instanceId, form, setSnackbarError);
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);
@@ -11,7 +11,7 @@ import { getDefaultPages, getPrefixedUrl, transformToWhere } from '../../utils';
11
11
  import RelatedObjectInstance from './RelatedObjectInstance';
12
12
  const ObjectPropertyInput = (props) => {
13
13
  const { id, fieldDefinition, readOnly, error, mode, displayOption, filter, defaultValueCriteria, sortBy, orderBy, isModal, initialValue, viewLayout, hasDescription, createActionId, formId, relatedObjectId, } = props;
14
- const { fetchedOptions, setFetchedOptions, parameters, fieldHeight, handleChange: handleChangeObjectField, onAutosave: onAutosave, instance, } = useFormContext();
14
+ const { fetchedOptions, setFetchedOptions, fieldHeight, handleChange: handleChangeObjectField, onAutosave: onAutosave, instance, } = useFormContext();
15
15
  const { defaultPages, findDefaultPageSlugFor } = useApp();
16
16
  const [selectedInstance, setSelectedInstance] = useState(initialValue || undefined);
17
17
  const [openCreateDialog, setOpenCreateDialog] = useState(false);
@@ -205,8 +205,8 @@ const ObjectPropertyInput = (props) => {
205
205
  }, [relatedObjectId, fetchedOptions, id]);
206
206
  useEffect(() => {
207
207
  (async () => {
208
- if (parameters && fetchedOptions[`${id}NavigationSlug`] === undefined) {
209
- const pages = await getDefaultPages(parameters, defaultPages, findDefaultPageSlugFor);
208
+ if (fetchedOptions[`${id}NavigationSlug`] === undefined) {
209
+ const pages = await getDefaultPages([{ ...fieldDefinition, objectId: relatedObjectId }], defaultPages, findDefaultPageSlugFor);
210
210
  if (relatedObjectId && pages[relatedObjectId]) {
211
211
  setNavigationSlug(pages[relatedObjectId]);
212
212
  setFetchedOptions({
@@ -221,7 +221,7 @@ const ObjectPropertyInput = (props) => {
221
221
  }
222
222
  }
223
223
  })();
224
- }, [parameters, defaultPages, findDefaultPageSlugFor, relatedObjectId, fetchedOptions]);
224
+ }, [id, fieldDefinition, defaultPages, findDefaultPageSlugFor, relatedObjectId, fetchedOptions]);
225
225
  const handleClose = () => {
226
226
  setOpenCreateDialog(false);
227
227
  };
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.11.0-dev.1",
3
+ "version": "1.11.0-dev.3",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",