mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 03:35:57 +08:00
chore: list filter transfer value to array
This commit is contained in:
parent
0281eb796d
commit
195ac19774
@ -30,6 +30,7 @@ const FilterCondition: FC<Props> = ({
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const isSelect = [ComparisonOperator.in, ComparisonOperator.notIn, ComparisonOperator.allOf].includes(condition.comparison_operator)
|
||||
const isTransferMethod = condition.key === 'transfer_method'
|
||||
const selectOptions = useMemo(() => {
|
||||
if (isSelect) {
|
||||
if (condition.key === 'type' || condition.comparison_operator === ComparisonOperator.allOf) {
|
||||
@ -38,7 +39,7 @@ const FilterCondition: FC<Props> = ({
|
||||
value: item.value,
|
||||
}))
|
||||
}
|
||||
if (condition.key === 'transfer_method') {
|
||||
if (isTransferMethod) {
|
||||
return TRANSFER_METHOD.map(item => ({
|
||||
name: t(`${optionNameI18NPrefix}.${item.i18nKey}`),
|
||||
value: item.value,
|
||||
@ -47,15 +48,15 @@ const FilterCondition: FC<Props> = ({
|
||||
return []
|
||||
}
|
||||
return []
|
||||
}, [condition.comparison_operator, condition.key, isSelect, t])
|
||||
}, [condition.comparison_operator, condition.key, isSelect, t, isTransferMethod])
|
||||
const handleChange = useCallback((key: string) => {
|
||||
return (value: any) => {
|
||||
onChange({
|
||||
...condition,
|
||||
[key]: value,
|
||||
[key]: isTransferMethod ? [value] : value,
|
||||
})
|
||||
}
|
||||
}, [condition, onChange])
|
||||
}, [condition, onChange, isTransferMethod])
|
||||
|
||||
const handleSubVariableChange = useCallback((value: string) => {
|
||||
onChange({
|
||||
@ -88,7 +89,7 @@ const FilterCondition: FC<Props> = ({
|
||||
{isSelect && (
|
||||
<Select
|
||||
items={selectOptions}
|
||||
defaultValue={condition.value}
|
||||
defaultValue={isTransferMethod ? (condition.value as string[])[0] : condition.value as string}
|
||||
onSelect={item => handleChange('value')(item.value)}
|
||||
className='!text-[13px]'
|
||||
wrapperClassName='grow h-8'
|
||||
|
@ -14,7 +14,7 @@ export type Limit = {
|
||||
export type Condition = {
|
||||
key: string
|
||||
comparison_operator: ComparisonOperator
|
||||
value: string | number
|
||||
value: string | number | string[]
|
||||
}
|
||||
|
||||
export type ListFilterNodeType = CommonNodeType & {
|
||||
|
Loading…
x
Reference in New Issue
Block a user