mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
feat: add filterOtherRecordsCollection for DataBlockInitializer (#4117)
This commit is contained in:
parent
5f8e442a15
commit
9fe1ecdf1e
@ -271,8 +271,15 @@ export interface DataBlockInitializerProps {
|
||||
icon?: string | React.ReactNode;
|
||||
name: string;
|
||||
title: string;
|
||||
/**
|
||||
* 用来筛选弹窗中的 “Current record” 和 “Associated records” 选项中的数据表
|
||||
*/
|
||||
filter?: (options: { collection: Collection; associationField: CollectionFieldOptions }) => boolean;
|
||||
filterDataSource?: (dataSource: DataSource) => boolean;
|
||||
/**
|
||||
* 用来筛选弹窗中的 “Other records” 选项中的数据表
|
||||
*/
|
||||
filterOtherRecordsCollection?: (collection: Collection) => boolean;
|
||||
componentType: string;
|
||||
onlyCurrentDataSource?: boolean;
|
||||
hideSearch?: boolean;
|
||||
@ -304,6 +311,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
||||
items: itemsFromProps,
|
||||
hideOtherRecordsInPopup,
|
||||
onClick: propsOnClick,
|
||||
filterOtherRecordsCollection,
|
||||
} = props;
|
||||
const { insert, setVisible } = useSchemaInitializer();
|
||||
const compile = useCompile();
|
||||
@ -335,6 +343,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
||||
componentName: componentType,
|
||||
filter,
|
||||
filterDataSource,
|
||||
filterOtherRecordsCollection,
|
||||
onlyCurrentDataSource,
|
||||
showAssociationFields,
|
||||
dataBlockInitializerProps: props,
|
||||
|
@ -843,6 +843,7 @@ export const useCollectionDataSourceItems = ({
|
||||
dataBlockInitializerProps,
|
||||
hideOtherRecordsInPopup,
|
||||
onClick,
|
||||
filterOtherRecordsCollection,
|
||||
}: {
|
||||
componentName;
|
||||
filter?: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
@ -855,6 +856,10 @@ export const useCollectionDataSourceItems = ({
|
||||
*/
|
||||
hideOtherRecordsInPopup?: boolean;
|
||||
onClick?: (options: any) => void;
|
||||
/**
|
||||
* 用来筛选弹窗中的 “Other records” 选项中的数据表
|
||||
*/
|
||||
filterOtherRecordsCollection?: (collection: Collection) => boolean;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const dm = useDataSourceManager();
|
||||
@ -959,7 +964,10 @@ export const useCollectionDataSourceItems = ({
|
||||
hideChildrenIfSingleCollection: false,
|
||||
onCreateBlockSchema: dataBlockInitializerProps.onCreateBlockSchema,
|
||||
componentType: componentTypeMap[componentName] || componentName,
|
||||
filter({ collection: c, associationField }) {
|
||||
filter({ collection, associationField }) {
|
||||
if (filterOtherRecordsCollection) {
|
||||
return filterOtherRecordsCollection(collection);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onClick(options) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user