mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
feat: loop termin support bool
This commit is contained in:
parent
b72d977871
commit
79bdb22f79
@ -36,6 +36,7 @@ import cn from '@/utils/classnames'
|
|||||||
import { SimpleSelect as Select } from '@/app/components/base/select'
|
import { SimpleSelect as Select } from '@/app/components/base/select'
|
||||||
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
||||||
import ConditionVarSelector from './condition-var-selector'
|
import ConditionVarSelector from './condition-var-selector'
|
||||||
|
import BoolValue from '@/app/components/workflow/panel/chat-variable-panel/components/bool-value'
|
||||||
|
|
||||||
const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName'
|
const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName'
|
||||||
|
|
||||||
@ -129,12 +130,12 @@ const ConditionItem = ({
|
|||||||
|
|
||||||
const isArrayValue = fileAttr?.key === 'transfer_method' || fileAttr?.key === 'type'
|
const isArrayValue = fileAttr?.key === 'transfer_method' || fileAttr?.key === 'type'
|
||||||
|
|
||||||
const handleUpdateConditionValue = useCallback((value: string) => {
|
const handleUpdateConditionValue = useCallback((value: string | boolean) => {
|
||||||
if (value === condition.value || (isArrayValue && value === condition.value?.[0]))
|
if (value === condition.value || (isArrayValue && value === (condition.value as string[])?.[0]))
|
||||||
return
|
return
|
||||||
const newCondition = {
|
const newCondition = {
|
||||||
...condition,
|
...condition,
|
||||||
value: isArrayValue ? [value] : value,
|
value: isArrayValue ? [value as string] : value,
|
||||||
}
|
}
|
||||||
doUpdateCondition(newCondition)
|
doUpdateCondition(newCondition)
|
||||||
}, [condition, doUpdateCondition, isArrayValue])
|
}, [condition, doUpdateCondition, isArrayValue])
|
||||||
@ -253,7 +254,7 @@ const ConditionItem = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
!comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType !== VarType.number && (
|
!comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType !== VarType.number && condition.varType !== VarType.boolean && (
|
||||||
<div className='max-h-[100px] overflow-y-auto border-t border-t-divider-subtle px-2 py-1'>
|
<div className='max-h-[100px] overflow-y-auto border-t border-t-divider-subtle px-2 py-1'>
|
||||||
<ConditionInput
|
<ConditionInput
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
@ -264,6 +265,14 @@ const ConditionItem = ({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{!comparisonOperatorNotRequireValue(condition.comparison_operator) && condition.varType === VarType.boolean
|
||||||
|
&& <div className='p-1'>
|
||||||
|
<BoolValue
|
||||||
|
value={condition.value as boolean}
|
||||||
|
onChange={handleUpdateConditionValue}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
{
|
{
|
||||||
!comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType === VarType.number && (
|
!comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType === VarType.number && (
|
||||||
<div className='border-t border-t-divider-subtle px-2 py-1 pt-[3px]'>
|
<div className='border-t border-t-divider-subtle px-2 py-1 pt-[3px]'>
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export type Condition = {
|
|||||||
variable_selector?: ValueSelector
|
variable_selector?: ValueSelector
|
||||||
key?: string // sub variable key
|
key?: string // sub variable key
|
||||||
comparison_operator?: ComparisonOperator
|
comparison_operator?: ComparisonOperator
|
||||||
value: string | string[]
|
value: string | string[] | boolean
|
||||||
numberVarType?: NumberVarType
|
numberVarType?: NumberVarType
|
||||||
sub_variable_condition?: CaseItem
|
sub_variable_condition?: CaseItem
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,6 +107,13 @@ export const getOperators = (type?: VarType, file?: { key: string }) => {
|
|||||||
ComparisonOperator.empty,
|
ComparisonOperator.empty,
|
||||||
ComparisonOperator.notEmpty,
|
ComparisonOperator.notEmpty,
|
||||||
]
|
]
|
||||||
|
case VarType.boolean:
|
||||||
|
return [
|
||||||
|
ComparisonOperator.is,
|
||||||
|
ComparisonOperator.isNot,
|
||||||
|
ComparisonOperator.empty,
|
||||||
|
ComparisonOperator.notEmpty,
|
||||||
|
]
|
||||||
case VarType.object:
|
case VarType.object:
|
||||||
return [
|
return [
|
||||||
ComparisonOperator.empty,
|
ComparisonOperator.empty,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user