fix: view inherited collection field reported error (#2249)
This commit is contained in:
parent
1d942d9910
commit
aececf1952
@ -3,7 +3,7 @@ import { ISchema } from '@formily/react';
|
|||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import set from 'lodash/set';
|
import set from 'lodash/set';
|
||||||
import React, { useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient, useRequest } from '../../api-client';
|
import { useAPIClient, useRequest } from '../../api-client';
|
||||||
import { RecordProvider, useRecord } from '../../record-provider';
|
import { RecordProvider, useRecord } from '../../record-provider';
|
||||||
@ -65,14 +65,21 @@ export const ViewCollectionField = (props) => {
|
|||||||
|
|
||||||
export const ViewFieldAction = (props) => {
|
export const ViewFieldAction = (props) => {
|
||||||
const { scope, getContainer, item: record, children } = props;
|
const { scope, getContainer, item: record, children } = props;
|
||||||
const { getInterface } = useCollectionManager();
|
const { getInterface, collections } = useCollectionManager();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [schema, setSchema] = useState({});
|
const [schema, setSchema] = useState({});
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const [data, setData] = useState<any>({});
|
const [data, setData] = useState<any>({});
|
||||||
|
const currentCollections = useMemo(() => {
|
||||||
|
return collections.map((v) => {
|
||||||
|
return {
|
||||||
|
label: compile(v.title),
|
||||||
|
value: v.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<RecordProvider record={record}>
|
<RecordProvider record={record}>
|
||||||
<ActionContextProvider value={{ visible, setVisible }}>
|
<ActionContextProvider value={{ visible, setVisible }}>
|
||||||
@ -113,6 +120,7 @@ export const ViewFieldAction = (props) => {
|
|||||||
getContainer,
|
getContainer,
|
||||||
showReverseFieldConfig: !data?.reverseField,
|
showReverseFieldConfig: !data?.reverseField,
|
||||||
createOnly: !true,
|
createOnly: !true,
|
||||||
|
collections: currentCollections,
|
||||||
...scope,
|
...scope,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user