From 0c4af3a1d2fe61d851d1b7b263d035853cfdd154 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 21 Aug 2024 15:27:08 +0800 Subject: [PATCH] feat: support sub variable operate changes with key and value support --- web/app/components/base/select/index.tsx | 4 +++- .../components/condition-list/condition-item.tsx | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index 5df9c05fe6..2ee5722d48 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -40,6 +40,7 @@ export type ISelectProps = { overlayClassName?: string optionWrapClassName?: string optionClassName?: string + hideChecked?: boolean renderOption?: ({ item, selected, @@ -177,6 +178,7 @@ const SimpleSelect: FC = ({ placeholder, optionWrapClassName, optionClassName, + hideChecked, renderOption, }) => { const { t } = useTranslation() @@ -257,7 +259,7 @@ const SimpleSelect: FC = ({ ? renderOption({ item, selected }) : (<> {item.name} - {selected && ( + {selected && !hideChecked && ( { const newCondition = produce(condition, (draft) => { 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) }, [caseId, condition, conditionId, onUpdateSubVariableCondition]) @@ -179,6 +185,7 @@ const ConditionItem = ({ :
{t('common.placeholder.select')}
)} + hideChecked /> ) : ( @@ -195,7 +202,7 @@ const ConditionItem = ({ varType={condition.varType} value={condition.comparison_operator} onSelect={handleUpdateConditionOperator} - file={file} + file={isSubVariableKey ? { key: condition.key! } : file} /> {