fix: templateBlockProvider support association field append

This commit is contained in:
katherinehhh 2024-03-29 10:32:47 +08:00 committed by sealday
parent 98e18a1a3a
commit 9acb908981
2 changed files with 9 additions and 4 deletions

View File

@ -30,6 +30,7 @@ import { DataBlockCollector } from '../filter-provider/FilterProvider';
import { RecordProvider, useRecordIndex } from '../record-provider'; import { RecordProvider, useRecordIndex } from '../record-provider';
import { useAssociationNames } from './hooks'; import { useAssociationNames } from './hooks';
import { useDataBlockSourceId } from './hooks/useDataBlockSourceId'; import { useDataBlockSourceId } from './hooks/useDataBlockSourceId';
import { useTemplateBlockContext } from './TemplateBlockProvider';
/** /**
* @deprecated * @deprecated
@ -228,6 +229,7 @@ export const BlockProvider = (props: {
}) => { }) => {
const { name, dataSource, association, useParams, parentRecord } = props; const { name, dataSource, association, useParams, parentRecord } = props;
const sourceId = useCompatDataBlockSourceId(props); const sourceId = useCompatDataBlockSourceId(props);
const { templateFinshed } = useTemplateBlockContext();
// 新版1.0)已弃用 useParams这里之所以继续保留是为了兼容旧版的 UISchema // 新版1.0)已弃用 useParams这里之所以继续保留是为了兼容旧版的 UISchema
const paramsFromHook = useParams?.(); const paramsFromHook = useParams?.();
@ -239,7 +241,7 @@ export const BlockProvider = (props: {
return { ...props.params, appends, ...paramsFromHook }; return { ...props.params, appends, ...paramsFromHook };
} }
return { ...props.params, ...paramsFromHook }; return { ...props.params, ...paramsFromHook };
}, [appends, paramsFromHook, props.params]); }, [appends, paramsFromHook, props.params, templateFinshed]);
const blockValue = useMemo(() => ({ name }), [name]); const blockValue = useMemo(() => ({ name }), [name]);
return ( return (

View File

@ -8,6 +8,7 @@ import { RecordProvider } from '../record-provider';
import { BlockProvider, useBlockRequestContext } from './BlockProvider'; import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useParsedFilter } from './hooks'; import { useParsedFilter } from './hooks';
import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps'; import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps';
import { TemplateBlockProvider } from './TemplateBlockProvider';
export const DetailsBlockContext = createContext<any>({}); export const DetailsBlockContext = createContext<any>({});
DetailsBlockContext.displayName = 'DetailsBlockContext'; DetailsBlockContext.displayName = 'DetailsBlockContext';
@ -64,9 +65,11 @@ const InternalDetailsBlockProvider = (props) => {
export const DetailsBlockProvider = withDynamicSchemaProps((props) => { export const DetailsBlockProvider = withDynamicSchemaProps((props) => {
return ( return (
<TemplateBlockProvider>
<BlockProvider name="details" {...props}> <BlockProvider name="details" {...props}>
<InternalDetailsBlockProvider {...props} /> <InternalDetailsBlockProvider {...props} />
</BlockProvider> </BlockProvider>
</TemplateBlockProvider>
); );
}); });