diff --git a/packages/plugins/workflow/src/client/nodes/manual/AssigneesSelect.tsx b/packages/plugins/workflow/src/client/nodes/manual/AssigneesSelect.tsx index bffda283a..59c9b2437 100644 --- a/packages/plugins/workflow/src/client/nodes/manual/AssigneesSelect.tsx +++ b/packages/plugins/workflow/src/client/nodes/manual/AssigneesSelect.tsx @@ -2,8 +2,15 @@ import { RemoteSelect, Variable } from '@nocobase/client'; import React from 'react'; import { useWorkflowVariableOptions } from '../../variable'; +function isUserKeyField(field) { + if (field.isForeignKey) { + return field.target === 'users'; + } + return field.collectionName === 'users' && field.name === 'id'; +} + export function AssigneesSelect({ multiple = false, value = [], onChange }) { - const scope = useWorkflowVariableOptions({ types: [{ type: 'reference', options: { collection: 'users' } }] }); + const scope = useWorkflowVariableOptions({ types: [isUserKeyField] }); return ( boolean); + | string + | { + type: string; + options?: { entity?: boolean; collection?: string }; + } + | ((field: any, appends?: string[]) => boolean); export type OptionsOfUseVariableOptions = { types?: VariableDataType[]; @@ -29,7 +29,7 @@ export type OptionsOfUseVariableOptions = { value?: string; children?: string; }; -} +}; export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const; @@ -283,7 +283,15 @@ async function loadChildren(option) { } export function getCollectionFieldOptions(options): VariableOption[] { - const { fields, collection, types, appends = [], compile, getCollectionFields, fieldNames = defaultFieldNames } = options; + const { + fields, + collection, + types, + appends = [], + compile, + getCollectionFields, + fieldNames = defaultFieldNames, + } = options; const normalizedFields = getNormalizedFields(collection, { compile, getCollectionFields }); const computedFields = fields ?? normalizedFields; const boundLoadChildren = loadChildren.bind({ compile, getCollectionFields, fieldNames });