mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-19 18:19:15 +08:00
feat: support sub variable operate changes with key and value support
This commit is contained in:
parent
5628b293f8
commit
0c4af3a1d2
@ -40,6 +40,7 @@ export type ISelectProps = {
|
|||||||
overlayClassName?: string
|
overlayClassName?: string
|
||||||
optionWrapClassName?: string
|
optionWrapClassName?: string
|
||||||
optionClassName?: string
|
optionClassName?: string
|
||||||
|
hideChecked?: boolean
|
||||||
renderOption?: ({
|
renderOption?: ({
|
||||||
item,
|
item,
|
||||||
selected,
|
selected,
|
||||||
@ -177,6 +178,7 @@ const SimpleSelect: FC<ISelectProps> = ({
|
|||||||
placeholder,
|
placeholder,
|
||||||
optionWrapClassName,
|
optionWrapClassName,
|
||||||
optionClassName,
|
optionClassName,
|
||||||
|
hideChecked,
|
||||||
renderOption,
|
renderOption,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -257,7 +259,7 @@ const SimpleSelect: FC<ISelectProps> = ({
|
|||||||
? renderOption({ item, selected })
|
? renderOption({ item, selected })
|
||||||
: (<>
|
: (<>
|
||||||
<span className={classNames('block', selected && 'font-normal')}>{item.name}</span>
|
<span className={classNames('block', selected && 'font-normal')}>{item.name}</span>
|
||||||
{selected && (
|
{selected && !hideChecked && (
|
||||||
<span
|
<span
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'absolute inset-y-0 right-0 flex items-center pr-4 text-gray-700',
|
'absolute inset-y-0 right-0 flex items-center pr-4 text-gray-700',
|
||||||
|
@ -19,7 +19,7 @@ import type {
|
|||||||
import {
|
import {
|
||||||
ComparisonOperator,
|
ComparisonOperator,
|
||||||
} from '../../types'
|
} from '../../types'
|
||||||
import { comparisonOperatorNotRequireValue } from '../../utils'
|
import { comparisonOperatorNotRequireValue, getOperators } from '../../utils'
|
||||||
import ConditionNumberInput from '../condition-number-input'
|
import ConditionNumberInput from '../condition-number-input'
|
||||||
import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../default'
|
import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../default'
|
||||||
import ConditionWrap from '../condition-wrap'
|
import ConditionWrap from '../condition-wrap'
|
||||||
@ -141,7 +141,13 @@ const ConditionItem = ({
|
|||||||
const handleSubVarKeyChange = useCallback((key: string) => {
|
const handleSubVarKeyChange = useCallback((key: string) => {
|
||||||
const newCondition = produce(condition, (draft) => {
|
const newCondition = produce(condition, (draft) => {
|
||||||
draft.key = key
|
draft.key = key
|
||||||
|
if (key === 'size')
|
||||||
|
draft.varType = VarType.number
|
||||||
|
else
|
||||||
|
draft.varType = VarType.string
|
||||||
|
draft.comparison_operator = getOperators(undefined, { key })[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
onUpdateSubVariableCondition?.(caseId, conditionId, condition.id, newCondition)
|
onUpdateSubVariableCondition?.(caseId, conditionId, condition.id, newCondition)
|
||||||
}, [caseId, condition, conditionId, onUpdateSubVariableCondition])
|
}, [caseId, condition, conditionId, onUpdateSubVariableCondition])
|
||||||
|
|
||||||
@ -179,6 +185,7 @@ const ConditionItem = ({
|
|||||||
</div>
|
</div>
|
||||||
: <div className='text-gray-300 system-xs-medium'>{t('common.placeholder.select')}</div>
|
: <div className='text-gray-300 system-xs-medium'>{t('common.placeholder.select')}</div>
|
||||||
)}
|
)}
|
||||||
|
hideChecked
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
: (
|
: (
|
||||||
@ -195,7 +202,7 @@ const ConditionItem = ({
|
|||||||
varType={condition.varType}
|
varType={condition.varType}
|
||||||
value={condition.comparison_operator}
|
value={condition.comparison_operator}
|
||||||
onSelect={handleUpdateConditionOperator}
|
onSelect={handleUpdateConditionOperator}
|
||||||
file={file}
|
file={isSubVariableKey ? { key: condition.key! } : file}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user