Feat: Fixed the issue where conditional operators could not select structured variables.
This commit is contained in:
parent
f612a424c5
commit
e424a76f18
1 changed files with 6 additions and 21 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import { FormContainer } from '@/components/form-container';
|
import { FormContainer } from '@/components/form-container';
|
||||||
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
|
||||||
import { BlockButton, Button } from '@/components/ui/button';
|
import { BlockButton, Button } from '@/components/ui/button';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import {
|
import {
|
||||||
|
|
@ -16,16 +15,15 @@ import { useBuildSwitchOperatorOptions } from '@/hooks/logic-hooks/use-build-ope
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { toLower } from 'lodash';
|
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import { memo, useCallback, useMemo } from 'react';
|
import { memo, useCallback, useMemo } from 'react';
|
||||||
import { useFieldArray, useForm, useFormContext } from 'react-hook-form';
|
import { useFieldArray, useForm, useFormContext } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { SwitchLogicOperatorOptions, VariableType } from '../../constant';
|
import { SwitchLogicOperatorOptions } from '../../constant';
|
||||||
import { useBuildQueryVariableOptions } from '../../hooks/use-get-begin-query';
|
|
||||||
import { IOperatorForm } from '../../interface';
|
import { IOperatorForm } from '../../interface';
|
||||||
import { FormWrapper } from '../components/form-wrapper';
|
import { FormWrapper } from '../components/form-wrapper';
|
||||||
|
import { QueryVariable } from '../components/query-variable';
|
||||||
import { useValues } from './use-values';
|
import { useValues } from './use-values';
|
||||||
import { useWatchFormChange } from './use-watch-change';
|
import { useWatchFormChange } from './use-watch-change';
|
||||||
|
|
||||||
|
|
@ -47,19 +45,6 @@ function ConditionCards({
|
||||||
}: ConditionCardsProps) {
|
}: ConditionCardsProps) {
|
||||||
const form = useFormContext();
|
const form = useFormContext();
|
||||||
|
|
||||||
const nextOptions = useBuildQueryVariableOptions();
|
|
||||||
|
|
||||||
const finalOptions = useMemo(() => {
|
|
||||||
return nextOptions.map((x) => {
|
|
||||||
return {
|
|
||||||
...x,
|
|
||||||
options: x.options.filter(
|
|
||||||
(y) => !toLower(y.type).includes(VariableType.Array),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}, [nextOptions]);
|
|
||||||
|
|
||||||
const switchOperatorOptions = useBuildSwitchOperatorOptions();
|
const switchOperatorOptions = useBuildSwitchOperatorOptions();
|
||||||
|
|
||||||
const name = `${parentName}.${ItemKey}`;
|
const name = `${parentName}.${ItemKey}`;
|
||||||
|
|
@ -101,11 +86,11 @@ function ConditionCards({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex-1 min-w-0">
|
<FormItem className="flex-1 min-w-0">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectWithSearch
|
<QueryVariable
|
||||||
|
pureQuery
|
||||||
{...field}
|
{...field}
|
||||||
options={finalOptions}
|
hideLabel
|
||||||
triggerClassName="text-accent-primary bg-transparent border-none truncate"
|
></QueryVariable>
|
||||||
></SelectWithSearch>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue