fix: aggreator

pull/21369/head
Joel 11 months ago
parent 726b1d6b3e
commit 4cd26171ff

@ -110,6 +110,7 @@ const useLastRun = <T>({
const isStartNode = blockType === BlockEnum.Start
const isIterationNode = blockType === BlockEnum.Iteration
const isLoopNode = blockType === BlockEnum.Loop
const isAggregatorNode = blockType === BlockEnum.VariableAggregator
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
const {
getData: getDataForCheckMore,
@ -256,6 +257,15 @@ const useLastRun = <T>({
})
}
const isSomeVarsHasValue = (vars?: ValueSelector[]) => {
if(!vars || vars.length === 0)
return true
return vars.some((varItem) => {
const [nodeId, varName] = varItem.slice(0, 2)
const inspectVarValue = hasSetInspectVar(nodeId, varName, systemVars, conversationVars) // also detect system var , env and conversation var
return inspectVarValue
})
}
const getFilteredExistVarForms = (forms: FormProps[]) => {
if (!forms || forms.length === 0)
return []
@ -274,12 +284,22 @@ const useLastRun = <T>({
return res
}
const checkAggregatorVarsSet = (vars: ValueSelector[][]) => {
if(!vars || vars.length === 0)
return true
// in each group, at last one set is ok
return vars.every((varItem) => {
return isSomeVarsHasValue(varItem)
})
}
const handleSingleRun = () => {
const { isValid } = checkValid()
if(!isValid)
return
const vars = singleRunParams?.getDependentVars?.()
// no need to input params
if (isAllVarsHasValue(singleRunParams?.getDependentVars?.())) {
if (isAggregatorNode ? checkAggregatorVarsSet(vars) : isAllVarsHasValue(vars)) {
callRunApi({}, async () => {
setIsRunAfterSingleRun(true)
setNodeRunning()

@ -56,7 +56,10 @@ const useSingleRunFormParams = ({
return
if (!existVarsKey[input.variable]) {
existVarsKey[input.variable] = true
uniqueVarInputs.push(input)
uniqueVarInputs.push({
...input,
required: false, // just one of the inputs is required
})
}
})
return [
@ -70,14 +73,14 @@ const useSingleRunFormParams = ({
const getDependentVars = () => {
if(payload.advanced_settings?.group_enabled) {
const vars: ValueSelector[] = []
const vars: ValueSelector[][] = []
payload.advanced_settings.groups.forEach((group) => {
if(group.variables)
vars.push(...group.variables)
vars.push([...group.variables])
})
return vars
}
return payload.variables
return [payload.variables]
}
return {

Loading…
Cancel
Save