From 344b8a07be5f8d566fc9d1e6cd90f9df03c9cf8d Mon Sep 17 00:00:00 2001 From: Alexey Nikipelau Date: Fri, 12 Apr 2024 17:20:04 +0300 Subject: [PATCH 1/3] fix filter post processing for data objects --- src/process/filter/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/process/filter/index.ts b/src/process/filter/index.ts index 02af1c62..7dd4ebbb 100644 --- a/src/process/filter/index.ts +++ b/src/process/filter/index.ts @@ -40,7 +40,11 @@ export const filterPostProcess: ProcessorFnSync = (context: FilterC if (scope.filter[path]) { let value = get(submission?.data, path); if (isObject(value) && isObject(scope.filter[path])) { - value = {...value, ...scope.filter[path]} + if (Utils.getModelType(context.component) === 'dataObject') { + value = {...value, ...scope.filter[path], data: (value as any)?.data} + } else { + value = {...value, ...scope.filter[path]} + } } set(filtered, path, value); } From c50c544a5fb34af7d095dcfc63ce986533dc4baf Mon Sep 17 00:00:00 2001 From: Alexey Nikipelau Date: Fri, 12 Apr 2024 17:20:21 +0300 Subject: [PATCH 2/3] make validateProcess and validateProcess consistent --- src/process/validation/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/process/validation/index.ts b/src/process/validation/index.ts index 5cea75ed..2d8387cc 100644 --- a/src/process/validation/index.ts +++ b/src/process/validation/index.ts @@ -8,6 +8,7 @@ import { getComponentAbsolutePath, getComponentPath } from "utils/formUtil"; import { getErrorMessage } from "utils/error"; import { FieldError } from "error"; import { ConditionallyHidden, isConditionallyHidden, isCustomConditionallyHidden, isSimpleConditionallyHidden } from "processes/conditions"; +import { validate } from 'fast-json-patch'; // Cleans up validation errors to remove unnessesary parts // and make them transferable to ivm. @@ -278,7 +279,7 @@ export const validateProcessSync: ValidationProcessorFnSync = (context) => { return; } if (component.truncateMultipleSpaces && value && typeof value === 'string') { - value = value.trim().replace(/\s{2,}/g, ' '); + set(data, path, value.trim().replace(/\s{2,}/g, ' ')); } for (const rule of rulesToExecute) { try { From 179c5ee030ccbd83d89c5631b70ed4cecb842d7c Mon Sep 17 00:00:00 2001 From: Alexey Nikipelau Date: Fri, 12 Apr 2024 17:29:59 +0300 Subject: [PATCH 3/3] use value instead of component which does not exists at post processing As post processing happens on whole submission, not on each component --- src/process/filter/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/process/filter/index.ts b/src/process/filter/index.ts index 7dd4ebbb..e8e489cf 100644 --- a/src/process/filter/index.ts +++ b/src/process/filter/index.ts @@ -40,7 +40,7 @@ export const filterPostProcess: ProcessorFnSync = (context: FilterC if (scope.filter[path]) { let value = get(submission?.data, path); if (isObject(value) && isObject(scope.filter[path])) { - if (Utils.getModelType(context.component) === 'dataObject') { + if ((value as any).data) { value = {...value, ...scope.filter[path], data: (value as any)?.data} } else { value = {...value, ...scope.filter[path]}