mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:29:16 +00:00
refactor: formBlockProvider & detailBlockProvider (#3898)
* refactor: formBlockProvider * refactor: detailBlockProvider * fix: bug * fix: bug * fix: bug * fix: bug * refactor: code improve
This commit is contained in:
parent
b111f827ed
commit
fcd2b766cf
@ -9,6 +9,9 @@ import { RecordProvider } from '../record-provider';
|
|||||||
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
||||||
import { TemplateBlockProvider } from './TemplateBlockProvider';
|
import { TemplateBlockProvider } from './TemplateBlockProvider';
|
||||||
import { useParsedFilter } from './hooks';
|
import { useParsedFilter } from './hooks';
|
||||||
|
import { useCollectionManager_deprecated } from '../collection-manager';
|
||||||
|
import { useCollectionRecordData } from '../data-source';
|
||||||
|
import { useDesignable } from '../schema-component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -67,6 +70,21 @@ const InternalDetailsBlockProvider = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DetailsBlockProvider = withDynamicSchemaProps((props) => {
|
export const DetailsBlockProvider = withDynamicSchemaProps((props) => {
|
||||||
|
const record = useCollectionRecordData();
|
||||||
|
const { association, dataSource } = props;
|
||||||
|
const { getCollection } = useCollectionManager_deprecated(dataSource);
|
||||||
|
const { __collection } = record || {};
|
||||||
|
const { designable } = useDesignable();
|
||||||
|
const collection = props.collection || getCollection(association, dataSource).name;
|
||||||
|
let detailFlag = true;
|
||||||
|
if (!designable && __collection) {
|
||||||
|
detailFlag = __collection === collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!detailFlag) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TemplateBlockProvider>
|
<TemplateBlockProvider>
|
||||||
<BlockProvider name="details" {...props}>
|
<BlockProvider name="details" {...props}>
|
||||||
|
Loading…
Reference in New Issue
Block a user