feat: output item var type and filter condition triger

This commit is contained in:
Joel 2024-08-30 15:06:57 +08:00
parent e7a6a0ab01
commit dc919c2a6c
3 changed files with 28 additions and 4 deletions

View File

@ -51,6 +51,21 @@ const SubVariablePicker: FC<Props> = ({
placeholder={t('workflow.nodes.listFilter.selectVariableKeyPlaceholder')!} placeholder={t('workflow.nodes.listFilter.selectVariableKeyPlaceholder')!}
optionClassName='pl-4 pr-5 py-0' optionClassName='pl-4 pr-5 py-0'
renderOption={renderOption} renderOption={renderOption}
renderTrigger={item => (
<div className='group/sub-variable-picker flex items-center h-8 pl-1 rounded-lg bg-components-input-bg-normal hover:bg-state-base-hover-alt'>
{item
? <div className='flex justify-start cursor-pointer'>
<div className='inline-flex max-w-full px-1.5 items-center h-6 rounded-md border-[0.5px] border-components-panel-border-subtle bg-components-badge-white-to-dark shadow-xs text-text-accent'>
<Variable02 className='shrink-0 w-3.5 h-3.5 text-text-accent' />
<div className='ml-0.5 truncate system-xs-medium'>{item?.name}</div>
</div>
</div>
: <div className='pl-1 flex text-components-input-text-placeholder system-sm-regular group-hover/sub-variable-picker:text-text-tertiary'>
<Variable02 className='mr-1 shrink-0 w-4 h-4' />
<span>{t('common.placeholder.select')}</span>
</div>}
</div>
)}
/> />
</div> </div>
) )

View File

@ -26,6 +26,7 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
readOnly, readOnly,
inputs, inputs,
itemVarType, itemVarType,
itemVarTypeShowName,
hasSubVariable, hasSubVariable,
handleVarChanges, handleVarChanges,
filterVar, filterVar,
@ -103,29 +104,30 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
) )
: null} : null}
</Field> </Field>
<Split />
<LimitConfig <LimitConfig
config={inputs.limit} config={inputs.limit}
onChange={handleLimitChange} onChange={handleLimitChange}
readonly={readOnly} readonly={readOnly}
/> />
</div> </div>
<Split />
<div className='px-4 pt-4 pb-2'> <div className='px-4 pt-4 pb-2'>
<OutputVars> <OutputVars>
<> <>
<VarItem <VarItem
name='result' name='result'
type='Array[x]' type={`Array[${itemVarTypeShowName}]`}
description={t(`${i18nPrefix}.outputVars.result`)} description={t(`${i18nPrefix}.outputVars.result`)}
/> />
<VarItem <VarItem
name='first_record' name='first_record'
type='x' type={itemVarTypeShowName}
description={t(`${i18nPrefix}.outputVars.first_record`)} description={t(`${i18nPrefix}.outputVars.first_record`)}
/> />
<VarItem <VarItem
name='last_record' name='last_record'
type='x' type={itemVarTypeShowName}
description={t(`${i18nPrefix}.outputVars.last_record`)} description={t(`${i18nPrefix}.outputVars.last_record`)}
/> />
</> </>

View File

@ -63,6 +63,12 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
const { varType, itemVarType } = getType() const { varType, itemVarType } = getType()
const itemVarTypeShowName = useMemo(() => {
if (!inputs.variable)
return '?'
return [itemVarType.substring(0, 1).toUpperCase(), itemVarType.substring(1)].join('')
}, [inputs.variable, itemVarType])
const hasSubVariable = [VarType.arrayFile].includes(varType) const hasSubVariable = [VarType.arrayFile].includes(varType)
const handleVarChanges = useCallback((variable: ValueSelector | string) => { const handleVarChanges = useCallback((variable: ValueSelector | string) => {
@ -128,6 +134,7 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
filterVar, filterVar,
varType, varType,
itemVarType, itemVarType,
itemVarTypeShowName,
hasSubVariable, hasSubVariable,
handleVarChanges, handleVarChanges,
handleFilterChange, handleFilterChange,