fix: click the edit button to report an error
This commit is contained in:
parent
1dc4142da2
commit
61621a9759
@ -8,16 +8,14 @@ import React, { createContext, useContext } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import {
|
||||
ACLCollectionProvider,
|
||||
TableFieldContext,
|
||||
TableFieldResource,
|
||||
useActionContext,
|
||||
useAPIClient,
|
||||
useDesignable,
|
||||
useRecord,
|
||||
useTableFieldContext,
|
||||
WithoutTableFieldResource,
|
||||
WithoutTableFieldResource
|
||||
} from '../';
|
||||
import { CollectionProvider, useCollection, useCollectionField, useCollectionManager } from '../collection-manager';
|
||||
import { CollectionProvider, useCollection, useCollectionManager } from '../collection-manager';
|
||||
import { useRecordIndex } from '../record-provider';
|
||||
import { SharedFilterProvider } from './SharedFilterProvider';
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { createForm } from '@formily/core';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { useField } from '@formily/react';
|
||||
import { Spin } from 'antd';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
||||
import { RecordProvider, useRecord } from '../record-provider';
|
||||
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
||||
import { useDesignable } from '../schema-component';
|
||||
import { useCollectionManager } from '../collection-manager';
|
||||
import { RecordProvider, useRecord } from '../record-provider';
|
||||
import { useDesignable } from '../schema-component';
|
||||
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
||||
|
||||
export const FormBlockContext = createContext<any>({});
|
||||
|
||||
@ -21,6 +22,7 @@ const InternalFormBlockProvider = (props) => {
|
||||
);
|
||||
const { resource, service } = useBlockRequestContext();
|
||||
const formBlockRef = useRef();
|
||||
const record = useRecord();
|
||||
if (service.loading) {
|
||||
return <Spin />;
|
||||
}
|
||||
@ -37,7 +39,7 @@ const InternalFormBlockProvider = (props) => {
|
||||
}}
|
||||
>
|
||||
{readPretty ? (
|
||||
<RecordProvider record={service?.data?.data}>
|
||||
<RecordProvider parent={isEmpty(record?.__parent) ? record : record?.__parent} record={service?.data?.data}>
|
||||
<div ref={formBlockRef}>{props.children}</div>
|
||||
</RecordProvider>
|
||||
) : (
|
||||
|
@ -4,10 +4,12 @@ import { useCurrentUserContext } from '../user';
|
||||
export const RecordContext = createContext({});
|
||||
export const RecordIndexContext = createContext(null);
|
||||
|
||||
export const RecordProvider: React.FC<{ record: any }> = (props) => {
|
||||
const { record, children } = props;
|
||||
export const RecordProvider: React.FC<{ record: any; parent?: any }> = (props) => {
|
||||
const { record, children, parent = false } = props;
|
||||
const __parent = useContext(RecordContext);
|
||||
return <RecordContext.Provider value={{ ...record, __parent }}>{children}</RecordContext.Provider>;
|
||||
const value = { ...record };
|
||||
value['__parent'] = parent ? parent : __parent;
|
||||
return <RecordContext.Provider value={value}>{children}</RecordContext.Provider>;
|
||||
};
|
||||
|
||||
export const RecordIndexProvider: React.FC<{ index: any }> = (props) => {
|
||||
|
Loading…
Reference in New Issue
Block a user