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

View File

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

View File

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