fix: chart field default value set error

This commit is contained in:
sealday 2024-03-27 20:00:07 +08:00
parent d48ef598f6
commit b563f3727b

View File

@ -1,4 +1,8 @@
import {
CollectionFieldProvider,
CollectionManagerProvider,
CollectionProvider,
DEFAULT_DATA_SOURCE_KEY,
SchemaComponent,
VariableInput,
VariableScopeProvider,
@ -40,19 +44,29 @@ export const ChartFilterVariableInput: React.FC<any> = (props) => {
}
}, [fieldSchema.default, handleChange]);
const dataSource = schema?.['x-data-source'] || DEFAULT_DATA_SOURCE_KEY;
const collectionField = schema?.['x-collection-field'] || '';
const [collection] = collectionField.split('.');
return (
<VariableScopeProvider scope={options}>
<VariableInput
{...componentProps}
renderSchemaComponent={() => <SchemaComponent schema={schema} />}
fieldNames={{}}
value={value?.value}
scope={options}
onChange={(v: any) => {
onChange({ value: v });
}}
shouldChange={getShouldChange({} as any)}
/>
</VariableScopeProvider>
<CollectionManagerProvider dataSource={dataSource}>
<CollectionProvider name={collection} allowNull={!collection}>
<CollectionFieldProvider name={schema['x-collection-field']} allowNull={!schema['x-collection-field']}>
<VariableScopeProvider scope={options}>
<VariableInput
{...componentProps}
renderSchemaComponent={() => <SchemaComponent schema={schema} />}
fieldNames={{}}
value={value?.value}
scope={options}
onChange={(v: any) => {
onChange({ value: v });
}}
shouldChange={getShouldChange({} as any)}
/>
</VariableScopeProvider>
</CollectionFieldProvider>
</CollectionProvider>
</CollectionManagerProvider>
);
};