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;
|
icon?: string | React.ReactNode;
|
||||||
name: string;
|
name: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
/**
|
||||||
|
* 用来筛选弹窗中的 “Current record” 和 “Associated records” 选项中的数据表
|
||||||
|
*/
|
||||||
filter?: (options: { collection: Collection; associationField: CollectionFieldOptions }) => boolean;
|
filter?: (options: { collection: Collection; associationField: CollectionFieldOptions }) => boolean;
|
||||||
filterDataSource?: (dataSource: DataSource) => boolean;
|
filterDataSource?: (dataSource: DataSource) => boolean;
|
||||||
|
/**
|
||||||
|
* 用来筛选弹窗中的 “Other records” 选项中的数据表
|
||||||
|
*/
|
||||||
|
filterOtherRecordsCollection?: (collection: Collection) => boolean;
|
||||||
componentType: string;
|
componentType: string;
|
||||||
onlyCurrentDataSource?: boolean;
|
onlyCurrentDataSource?: boolean;
|
||||||
hideSearch?: boolean;
|
hideSearch?: boolean;
|
||||||
@ -304,6 +311,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
|||||||
items: itemsFromProps,
|
items: itemsFromProps,
|
||||||
hideOtherRecordsInPopup,
|
hideOtherRecordsInPopup,
|
||||||
onClick: propsOnClick,
|
onClick: propsOnClick,
|
||||||
|
filterOtherRecordsCollection,
|
||||||
} = props;
|
} = props;
|
||||||
const { insert, setVisible } = useSchemaInitializer();
|
const { insert, setVisible } = useSchemaInitializer();
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
@ -335,6 +343,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
|||||||
componentName: componentType,
|
componentName: componentType,
|
||||||
filter,
|
filter,
|
||||||
filterDataSource,
|
filterDataSource,
|
||||||
|
filterOtherRecordsCollection,
|
||||||
onlyCurrentDataSource,
|
onlyCurrentDataSource,
|
||||||
showAssociationFields,
|
showAssociationFields,
|
||||||
dataBlockInitializerProps: props,
|
dataBlockInitializerProps: props,
|
||||||
|
@ -843,6 +843,7 @@ export const useCollectionDataSourceItems = ({
|
|||||||
dataBlockInitializerProps,
|
dataBlockInitializerProps,
|
||||||
hideOtherRecordsInPopup,
|
hideOtherRecordsInPopup,
|
||||||
onClick,
|
onClick,
|
||||||
|
filterOtherRecordsCollection,
|
||||||
}: {
|
}: {
|
||||||
componentName;
|
componentName;
|
||||||
filter?: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
filter?: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||||
@ -855,6 +856,10 @@ export const useCollectionDataSourceItems = ({
|
|||||||
*/
|
*/
|
||||||
hideOtherRecordsInPopup?: boolean;
|
hideOtherRecordsInPopup?: boolean;
|
||||||
onClick?: (options: any) => void;
|
onClick?: (options: any) => void;
|
||||||
|
/**
|
||||||
|
* 用来筛选弹窗中的 “Other records” 选项中的数据表
|
||||||
|
*/
|
||||||
|
filterOtherRecordsCollection?: (collection: Collection) => boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dm = useDataSourceManager();
|
const dm = useDataSourceManager();
|
||||||
@ -959,7 +964,10 @@ export const useCollectionDataSourceItems = ({
|
|||||||
hideChildrenIfSingleCollection: false,
|
hideChildrenIfSingleCollection: false,
|
||||||
onCreateBlockSchema: dataBlockInitializerProps.onCreateBlockSchema,
|
onCreateBlockSchema: dataBlockInitializerProps.onCreateBlockSchema,
|
||||||
componentType: componentTypeMap[componentName] || componentName,
|
componentType: componentTypeMap[componentName] || componentName,
|
||||||
filter({ collection: c, associationField }) {
|
filter({ collection, associationField }) {
|
||||||
|
if (filterOtherRecordsCollection) {
|
||||||
|
return filterOtherRecordsCollection(collection);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onClick(options) {
|
onClick(options) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user