mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:37:37 +00:00
fix: the details of the associated data in the subtable are not displayed (#454)
This commit is contained in:
parent
a494376f31
commit
b8fac535f2
@ -4,7 +4,7 @@ import { useRequest } from 'ahooks';
|
|||||||
import template from 'lodash/template';
|
import template from 'lodash/template';
|
||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { ACLCollectionProvider, TableFieldResource, useAPIClient, useRecord } from '../';
|
import { ACLCollectionProvider, TableFieldResource, useAPIClient, useRecord, WithoutTableFieldResource } from '../';
|
||||||
import { CollectionProvider, useCollection, useCollectionManager } from '../collection-manager';
|
import { CollectionProvider, useCollection, useCollectionManager } from '../collection-manager';
|
||||||
import { useRecordIndex } from '../record-provider';
|
import { useRecordIndex } from '../record-provider';
|
||||||
|
|
||||||
@ -49,8 +49,9 @@ const useReousrce = (props: UseReousrceProps) => {
|
|||||||
};
|
};
|
||||||
return new TableFieldResource(options);
|
return new TableFieldResource(options);
|
||||||
}
|
}
|
||||||
|
const withoutTableFieldResource = useContext(WithoutTableFieldResource);
|
||||||
const __parent = useContext(BlockRequestContext);
|
const __parent = useContext(BlockRequestContext);
|
||||||
if (__parent?.block === 'TableField' && __parent?.resource instanceof TableFieldResource) {
|
if (!withoutTableFieldResource && __parent?.block === 'TableField' && __parent?.resource instanceof TableFieldResource) {
|
||||||
return __parent.resource;
|
return __parent.resource;
|
||||||
}
|
}
|
||||||
if (!association) {
|
if (!association) {
|
||||||
@ -143,8 +144,11 @@ export const useFilterByTk = () => {
|
|||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const { getCollectionField } = useCollectionManager();
|
const { getCollectionField } = useCollectionManager();
|
||||||
const assoc = useContext(BlockAssociationContext);
|
const assoc = useContext(BlockAssociationContext);
|
||||||
if (resource instanceof TableFieldResource || __parent?.block === 'TableField') {
|
const withoutTableFieldResource = useContext(WithoutTableFieldResource);
|
||||||
return recordIndex;
|
if (!withoutTableFieldResource) {
|
||||||
|
if (resource instanceof TableFieldResource || __parent?.block === 'TableField') {
|
||||||
|
return recordIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (assoc) {
|
if (assoc) {
|
||||||
const association = getCollectionField(assoc);
|
const association = getCollectionField(assoc);
|
||||||
|
@ -108,11 +108,15 @@ export class TableFieldResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const WithoutTableFieldResource = createContext(null);
|
||||||
|
|
||||||
export const TableFieldProvider = (props) => {
|
export const TableFieldProvider = (props) => {
|
||||||
return (
|
return (
|
||||||
<BlockProvider block={'TableField'} {...props}>
|
<WithoutTableFieldResource.Provider value={false}>
|
||||||
<InternalTableFieldProvider {...props} />
|
<BlockProvider block={'TableField'} {...props}>
|
||||||
</BlockProvider>
|
<InternalTableFieldProvider {...props} />
|
||||||
|
</BlockProvider>
|
||||||
|
</WithoutTableFieldResource.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { observer, RecursionField, useField, useFieldSchema } from '@formily/rea
|
|||||||
import { toArr } from '@formily/shared';
|
import { toArr } from '@formily/shared';
|
||||||
import { Space } from 'antd';
|
import { Space } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { BlockAssociationContext } from '../../../block-provider';
|
import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
|
||||||
import { CollectionProvider, useCollection } from '../../../collection-manager';
|
import { CollectionProvider, useCollection } from '../../../collection-manager';
|
||||||
import { RecordProvider } from '../../../record-provider';
|
import { RecordProvider } from '../../../record-provider';
|
||||||
import { FormProvider } from '../../core';
|
import { FormProvider } from '../../core';
|
||||||
@ -44,9 +44,11 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
|
|||||||
</Space>
|
</Space>
|
||||||
<ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}>
|
<ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}>
|
||||||
<RecordProvider record={record}>
|
<RecordProvider record={record}>
|
||||||
<FormProvider>
|
<WithoutTableFieldResource.Provider value={true}>
|
||||||
<RecursionField schema={fieldSchema} onlyRenderProperties />
|
<FormProvider>
|
||||||
</FormProvider>
|
<RecursionField schema={fieldSchema} onlyRenderProperties />
|
||||||
|
</FormProvider>
|
||||||
|
</WithoutTableFieldResource.Provider>
|
||||||
</RecordProvider>
|
</RecordProvider>
|
||||||
</ActionContext.Provider>
|
</ActionContext.Provider>
|
||||||
</CollectionProvider>
|
</CollectionProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user