mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:38:13 +00:00
fix(plugin-workflow): fix loop scope variable (#2989)
This commit is contained in:
parent
3802ca38f8
commit
30de7865c5
@ -8,7 +8,14 @@ import { Branch } from '../Branch';
|
||||
import { useFlowContext } from '../FlowContext';
|
||||
import { NAMESPACE, lang } from '../locale';
|
||||
import useStyles from '../style';
|
||||
import { VariableOption, WorkflowVariableInput, defaultFieldNames, nodesOptions, triggerOptions } from '../variable';
|
||||
import {
|
||||
VariableOption,
|
||||
WorkflowVariableInput,
|
||||
defaultFieldNames,
|
||||
nodesOptions,
|
||||
scopeOptions,
|
||||
triggerOptions,
|
||||
} from '../variable';
|
||||
|
||||
function findOption(options: VariableOption[], paths: string[]) {
|
||||
let opts = options;
|
||||
@ -121,8 +128,8 @@ export default {
|
||||
.split('.')
|
||||
.map((path) => path.trim());
|
||||
|
||||
const targetOptions = [nodesOptions, triggerOptions].map((item: any) => {
|
||||
const opts = item.useOptions(options).filter(Boolean);
|
||||
const targetOptions = [scopeOptions, nodesOptions, triggerOptions].map((item: any) => {
|
||||
const opts = item.useOptions({ ...options, current: node }).filter(Boolean);
|
||||
return {
|
||||
[fieldNames.label]: compile(item.label),
|
||||
[fieldNames.value]: item.value,
|
||||
|
@ -34,6 +34,7 @@ export type OptionsOfUseVariableOptions = {
|
||||
};
|
||||
appends?: string[] | null;
|
||||
depth?: number;
|
||||
current?: any;
|
||||
};
|
||||
|
||||
export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const;
|
||||
@ -70,9 +71,10 @@ export const scopeOptions = {
|
||||
label: `{{t("Scope variables", { ns: "${NAMESPACE}" })}}`,
|
||||
value: '$scopes',
|
||||
useOptions(options: OptionsOfUseVariableOptions) {
|
||||
const { fieldNames = defaultFieldNames } = options;
|
||||
const current = useNodeContext();
|
||||
const scopes = useUpstreamScopes(current);
|
||||
const { fieldNames = defaultFieldNames, current } = options;
|
||||
const source = useNodeContext();
|
||||
const from = current ?? source;
|
||||
const scopes = useUpstreamScopes(from);
|
||||
const result: VariableOption[] = [];
|
||||
scopes.forEach((node) => {
|
||||
const instruction = instructions.get(node.type);
|
||||
|
Loading…
Reference in New Issue
Block a user