fix: sub-table without record context

This commit is contained in:
chenos 2022-11-19 22:44:31 +08:00
parent ef81032dbe
commit 903fbfacce
3 changed files with 24 additions and 18 deletions

View File

@ -2,7 +2,7 @@ import { ArrayField } from '@formily/core';
import { Schema, useField, useFieldSchema } from '@formily/react'; import { Schema, useField, useFieldSchema } from '@formily/react';
import React, { createContext, useContext, useEffect } from 'react'; import React, { createContext, useContext, useEffect } from 'react';
import { useCollectionManager } from '../collection-manager'; import { useCollectionManager } from '../collection-manager';
import { useRecord } from '../record-provider'; import { RecordProvider, useRecord } from '../record-provider';
import { BlockProvider, useBlockRequestContext } from './BlockProvider'; import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useFormBlockContext } from './FormBlockProvider'; import { useFormBlockContext } from './FormBlockProvider';
@ -16,18 +16,20 @@ const InternalTableSelectorProvider = (props) => {
// return <Spin />; // return <Spin />;
// } // }
return ( return (
<TableSelectorContext.Provider <RecordProvider record={{}}>
value={{ <TableSelectorContext.Provider
field, value={{
service, field,
resource, service,
params, resource,
extraFilter, params,
rowKey, extraFilter,
}} rowKey,
> }}
{props.children} >
</TableSelectorContext.Provider> {props.children}
</TableSelectorContext.Provider>
</RecordProvider>
); );
}; };

View File

@ -120,10 +120,10 @@ export const TabPaneInitializers = (props?: any) => {
); );
}; };
export const TabPaneInitializersForCreateFormBlock = () => { export const TabPaneInitializersForCreateFormBlock = (props) => {
return <TabPaneInitializers isCreate />; return <TabPaneInitializers {...props} isCreate />;
}; };
export const TabPaneInitializersForBulkEditFormBlock = () => { export const TabPaneInitializersForBulkEditFormBlock = (props) => {
return <TabPaneInitializers isBulkEdit />; return <TabPaneInitializers {...props} isBulkEdit />;
}; };

View File

@ -5,11 +5,15 @@ import { gridRowColWrap } from '../utils';
export const TableSelectorInitializers = (props: any) => { export const TableSelectorInitializers = (props: any) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { insertPosition, component } = props;
return ( return (
<SchemaInitializer.Button <SchemaInitializer.Button
wrap={gridRowColWrap} wrap={gridRowColWrap}
title={t('Add block')} title={component ? null : t('Add block')}
icon={'PlusOutlined'} icon={'PlusOutlined'}
insertPosition={insertPosition}
component={component}
items={[ items={[
{ {
type: 'itemGroup', type: 'itemGroup',