fix(plugin-workflow): fix manual assignee select variable type filter (#2396)
* fix(plugin-workflow): fix manual assignee select variable type filter * chore(plugin-workflow): fix lint issues
This commit is contained in:
parent
5ef8fe7848
commit
53a6a6c621
@ -2,8 +2,15 @@ import { RemoteSelect, Variable } from '@nocobase/client';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useWorkflowVariableOptions } from '../../variable';
|
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 }) {
|
export function AssigneesSelect({ multiple = false, value = [], onChange }) {
|
||||||
const scope = useWorkflowVariableOptions({ types: [{ type: 'reference', options: { collection: 'users' } }] });
|
const scope = useWorkflowVariableOptions({ types: [isUserKeyField] });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Variable.Input
|
<Variable.Input
|
||||||
|
@ -15,12 +15,12 @@ export type VariableOption = {
|
|||||||
export type VariableOptions = VariableOption[] | null;
|
export type VariableOptions = VariableOption[] | null;
|
||||||
|
|
||||||
export type VariableDataType =
|
export type VariableDataType =
|
||||||
string |
|
| string
|
||||||
{
|
| {
|
||||||
type: string;
|
type: string;
|
||||||
options?: { entity?: boolean; collection?: string }
|
options?: { entity?: boolean; collection?: string };
|
||||||
} |
|
}
|
||||||
((field: any, appends?: string[]) => boolean);
|
| ((field: any, appends?: string[]) => boolean);
|
||||||
|
|
||||||
export type OptionsOfUseVariableOptions = {
|
export type OptionsOfUseVariableOptions = {
|
||||||
types?: VariableDataType[];
|
types?: VariableDataType[];
|
||||||
@ -29,7 +29,7 @@ export type OptionsOfUseVariableOptions = {
|
|||||||
value?: string;
|
value?: string;
|
||||||
children?: string;
|
children?: string;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const;
|
export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const;
|
||||||
|
|
||||||
@ -283,7 +283,15 @@ async function loadChildren(option) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getCollectionFieldOptions(options): VariableOption[] {
|
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 normalizedFields = getNormalizedFields(collection, { compile, getCollectionFields });
|
||||||
const computedFields = fields ?? normalizedFields;
|
const computedFields = fields ?? normalizedFields;
|
||||||
const boundLoadChildren = loadChildren.bind({ compile, getCollectionFields, fieldNames });
|
const boundLoadChildren = loadChildren.bind({ compile, getCollectionFields, fieldNames });
|
||||||
|
Loading…
Reference in New Issue
Block a user