From a59ed4ee172845ca1d6549f0453f421355e4009b Mon Sep 17 00:00:00 2001 From: Junyi Date: Sun, 20 Aug 2023 16:45:46 +0700 Subject: [PATCH] fix(plugin-workflow): fix variable type check (#2492) * fix(plugin-workflow): fix variable type check * fix(plugin-workflow): fix node job button style --- .../workflow/src/client/nodes/aggregate.tsx | 5 +-- .../workflow/src/client/nodes/index.tsx | 2 ++ .../plugins/workflow/src/client/variable.tsx | 33 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/plugins/workflow/src/client/nodes/aggregate.tsx b/packages/plugins/workflow/src/client/nodes/aggregate.tsx index 3812fd307..5e19e119c 100644 --- a/packages/plugins/workflow/src/client/nodes/aggregate.tsx +++ b/packages/plugins/workflow/src/client/nodes/aggregate.tsx @@ -20,8 +20,9 @@ import { BaseTypeSets, defaultFieldNames, nodesOptions, triggerOptions } from '. function matchToManyField(field, appends): boolean { const fieldPrefix = `${field.name}.`; return ( - ['hasMany', 'belongsToMany'].includes(field.type) && - (appends ? appends.includes(field.name) || appends.some((item) => item.startsWith(fieldPrefix)) : true) + (['hasOne', 'belongsTo'].includes(field.type) && + (appends ? appends.includes(field.name) || appends.some((item) => item.startsWith(fieldPrefix)) : true)) || + ['hasMany', 'belongsToMany'].includes(field.type) ); } diff --git a/packages/plugins/workflow/src/client/nodes/index.tsx b/packages/plugins/workflow/src/client/nodes/index.tsx index 0a20c1dc7..d210f526f 100644 --- a/packages/plugins/workflow/src/client/nodes/index.tsx +++ b/packages/plugins/workflow/src/client/nodes/index.tsx @@ -265,6 +265,8 @@ export function JobButton() { border: 2px solid #d9d9d9; border-radius: 50%; cursor: not-allowed; + width: 24px; + height: 24px; `, )} /> diff --git a/packages/plugins/workflow/src/client/variable.tsx b/packages/plugins/workflow/src/client/variable.tsx index a3cd3baf9..5ee107ebe 100644 --- a/packages/plugins/workflow/src/client/variable.tsx +++ b/packages/plugins/workflow/src/client/variable.tsx @@ -165,28 +165,25 @@ function getNextAppends(field, appends: string[]) { function filterTypedFields({ fields, types, appends, compile, getCollectionFields }) { return fields.filter((field) => { - const match = types?.length ? types.some((type) => matchFieldType(field, type, appends)) : true; + if (types?.length) { + return types.some((type) => matchFieldType(field, type, appends)); + } if (isAssociationField(field)) { const nextAppends = getNextAppends(field, appends); const included = appends.includes(field.name); - if (match) { - return included; - } else { - return ( - (nextAppends.length || included) && - filterTypedFields({ - fields: getNormalizedFields(field.target, { compile, getCollectionFields }), - types, - // depth: depth - 1, - appends: nextAppends, - compile, - getCollectionFields, - }).length - ); - } - } else { - return match; + return ( + (nextAppends.length || included) && + filterTypedFields({ + fields: getNormalizedFields(field.target, { compile, getCollectionFields }), + types, + // depth: depth - 1, + appends: nextAppends, + compile, + getCollectionFields, + }).length + ); } + return true; }); }