From 5d2724583ce551e8f74d0920f9c5af8eea648ce3 Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 21 Apr 2023 09:52:13 +0700 Subject: [PATCH] fix(plugin-workflow): fix foreignkey in variable (#1740) --- packages/plugins/workflow/src/client/variable.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/plugins/workflow/src/client/variable.tsx b/packages/plugins/workflow/src/client/variable.tsx index fe4601dbb..12ba6c04e 100644 --- a/packages/plugins/workflow/src/client/variable.tsx +++ b/packages/plugins/workflow/src/client/variable.tsx @@ -108,7 +108,7 @@ export function filterTypedFields(fields, types, depth = 1) { return fields; } return fields.filter((field) => { - if (isAssociationField(field) && depth && filterTypedFields(useNormallizedFields(field.target), types, depth - 1).length) { + if (isAssociationField(field) && depth && filterTypedFields(useNormalizedFields(field.target), types, depth - 1).length) { return true; } return types.some((type) => matchFieldType(field, type)); @@ -130,7 +130,7 @@ export function useWorkflowVariableOptions(types?) { return options; } -function useNormallizedFields(collectionName) { +function useNormalizedFields(collectionName) { const compile = useCompile(); const { getCollection } = useCollectionManager(); const collection = getCollection(collectionName); @@ -153,6 +153,7 @@ function useNormallizedFields(collectionName) { const foreignKeyField = foreignKeyFields.find(f => f.name === field.foreignKey); if (foreignKeyField) { otherFields.splice(i, 0, { + ...field, ...foreignKeyField, uiSchema: { ...field.uiSchema, @@ -192,7 +193,7 @@ function useNormallizedFields(collectionName) { export function useCollectionFieldOptions(options): VariableOption[] { const { fields, collection, types, depth = 1 } = options; const compile = useCompile(); - const normalizedFields = fields ?? useNormallizedFields(collection); + const normalizedFields = fields ?? useNormalizedFields(collection); const result: VariableOption[] = filterTypedFields(normalizedFields, types, depth) .filter(field => !isAssociationField(field) || depth) .map(field => {