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 { import {
CollectionFieldProvider,
CollectionManagerProvider,
CollectionProvider,
DEFAULT_DATA_SOURCE_KEY,
SchemaComponent, SchemaComponent,
VariableInput, VariableInput,
VariableScopeProvider, VariableScopeProvider,
@ -40,7 +44,14 @@ export const ChartFilterVariableInput: React.FC<any> = (props) => {
} }
}, [fieldSchema.default, handleChange]); }, [fieldSchema.default, handleChange]);
const dataSource = schema?.['x-data-source'] || DEFAULT_DATA_SOURCE_KEY;
const collectionField = schema?.['x-collection-field'] || '';
const [collection] = collectionField.split('.');
return ( return (
<CollectionManagerProvider dataSource={dataSource}>
<CollectionProvider name={collection} allowNull={!collection}>
<CollectionFieldProvider name={schema['x-collection-field']} allowNull={!schema['x-collection-field']}>
<VariableScopeProvider scope={options}> <VariableScopeProvider scope={options}>
<VariableInput <VariableInput
{...componentProps} {...componentProps}
@ -54,5 +65,8 @@ export const ChartFilterVariableInput: React.FC<any> = (props) => {
shouldChange={getShouldChange({} as any)} shouldChange={getShouldChange({} as any)}
/> />
</VariableScopeProvider> </VariableScopeProvider>
</CollectionFieldProvider>
</CollectionProvider>
</CollectionManagerProvider>
); );
}; };