chore: list filter field

This commit is contained in:
Joel 2024-08-27 10:43:03 +08:00
parent c2b8beffac
commit 2122cfb152
4 changed files with 15 additions and 9 deletions

View File

@ -7,7 +7,7 @@ const i18nPrefix = 'workflow.errorMsg'
const nodeDefault: NodeDefault<ListFilterNodeType> = {
defaultValue: {
variable: [],
orderBy: {
order_by: {
enabled: false,
key: '',
value: OrderBy.ASC,

View File

@ -60,14 +60,14 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
title={t(`${i18nPrefix}.orderBy`)}
operations={
<Switch
defaultValue={inputs.orderBy?.enabled}
defaultValue={inputs.order_by?.enabled}
onChange={handleOrderByEnabledChange}
size='md'
disabled={readOnly}
/>
}
>
{inputs.orderBy?.enabled
{inputs.order_by?.enabled
? (
<div className='flex items-center justify-between'>
{hasSubVariable && (
@ -77,12 +77,12 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
<OptionCard
title={t(`${i18nPrefix}.asc`)}
onSelect={handleOrderByTypeChange(OrderBy.ASC)}
selected={inputs.orderBy.value === OrderBy.ASC}
selected={inputs.order_by.value === OrderBy.ASC}
/>
<OptionCard
title={t(`${i18nPrefix}.desc`)}
onSelect={handleOrderByTypeChange(OrderBy.DESC)}
selected={inputs.orderBy.value === OrderBy.DESC}
selected={inputs.order_by.value === OrderBy.DESC}
/>
</div>
</div>

View File

@ -10,10 +10,16 @@ export type Limit = {
size?: number
}
export type Condition = {
key: string
comparison_operator: string
value: string
}
export type ListFilterNodeType = CommonNodeType & {
variable: ValueSelector
filterBy: []
orderBy: {
filter_by: Condition[]
order_by: {
enabled: boolean
key: ValueSelector | string
value: OrderBy

View File

@ -62,7 +62,7 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
const handleOrderByEnabledChange = useCallback((enabled: boolean) => {
const newInputs = produce(inputs, (draft) => {
draft.orderBy.enabled = enabled
draft.order_by.enabled = enabled
})
setInputs(newInputs)
}, [inputs, setInputs])
@ -70,7 +70,7 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
const handleOrderByTypeChange = useCallback((type: OrderBy) => {
return () => {
const newInputs = produce(inputs, (draft) => {
draft.orderBy.value = type
draft.order_by.value = type
})
setInputs(newInputs)
}