mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:35:20 +00:00
fix: fix the disappearing collections when searching (#3750)
This commit is contained in:
parent
86d2538a43
commit
368036923f
@ -14,6 +14,7 @@ export const DetailsBlockInitializer = ({
|
||||
createBlockSchema,
|
||||
templateWrap,
|
||||
showAssociationFields,
|
||||
hideChildrenIfSingleCollection,
|
||||
}: {
|
||||
filterCollections: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
onlyCurrentDataSource: boolean;
|
||||
@ -33,6 +34,7 @@ export const DetailsBlockInitializer = ({
|
||||
},
|
||||
) => any;
|
||||
showAssociationFields?: boolean;
|
||||
hideChildrenIfSingleCollection?: boolean;
|
||||
}) => {
|
||||
const { insert } = useSchemaInitializer();
|
||||
const { getCollection } = useCollectionManager_deprecated();
|
||||
@ -66,6 +68,7 @@ export const DetailsBlockInitializer = ({
|
||||
filter={filterCollections}
|
||||
templateWrap={templateWrap}
|
||||
showAssociationFields={showAssociationFields}
|
||||
hideChildrenIfSingleCollection={hideChildrenIfSingleCollection}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -13,6 +13,7 @@ export const FormBlockInitializer = ({
|
||||
componentType = 'FormItem',
|
||||
templateWrap,
|
||||
showAssociationFields,
|
||||
hideChildrenIfSingleCollection,
|
||||
}: {
|
||||
filterCollections: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
onlyCurrentDataSource: boolean;
|
||||
@ -31,6 +32,7 @@ export const FormBlockInitializer = ({
|
||||
},
|
||||
) => any;
|
||||
showAssociationFields?: boolean;
|
||||
hideChildrenIfSingleCollection?: boolean;
|
||||
}) => {
|
||||
const { insert } = useSchemaInitializer();
|
||||
const itemConfig = useSchemaInitializerItem();
|
||||
@ -80,6 +82,7 @@ export const FormBlockInitializer = ({
|
||||
onlyCurrentDataSource={onlyCurrentDataSource}
|
||||
hideSearch={hideSearch}
|
||||
showAssociationFields={showAssociationFields}
|
||||
hideChildrenIfSingleCollection={hideChildrenIfSingleCollection}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -9,11 +9,11 @@ import { Collection, CollectionFieldOptions } from '../../../../data-source';
|
||||
export const FilterCollapseBlockInitializer = ({
|
||||
filterCollections,
|
||||
onlyCurrentDataSource,
|
||||
showChildren,
|
||||
hideChildrenIfSingleCollection,
|
||||
}: {
|
||||
filterCollections: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
onlyCurrentDataSource: boolean;
|
||||
showChildren?: boolean;
|
||||
hideChildrenIfSingleCollection?: boolean;
|
||||
}) => {
|
||||
const itemConfig = useSchemaInitializerItem();
|
||||
const { insert } = useSchemaInitializer();
|
||||
@ -34,7 +34,7 @@ export const FilterCollapseBlockInitializer = ({
|
||||
insert(schema);
|
||||
}}
|
||||
filter={filterCollections}
|
||||
showChildren={showChildren}
|
||||
hideChildrenIfSingleCollection={hideChildrenIfSingleCollection}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -8,11 +8,11 @@ import { Collection, CollectionFieldOptions } from '../../../../data-source';
|
||||
export const FilterFormBlockInitializer = ({
|
||||
filterCollections,
|
||||
onlyCurrentDataSource,
|
||||
showChildren,
|
||||
hideChildrenIfSingleCollection,
|
||||
}: {
|
||||
filterCollections: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
onlyCurrentDataSource: boolean;
|
||||
showChildren?: boolean;
|
||||
hideChildrenIfSingleCollection?: boolean;
|
||||
}) => {
|
||||
const itemConfig = useSchemaInitializerItem();
|
||||
const { insert } = useSchemaInitializer();
|
||||
@ -45,7 +45,7 @@ export const FilterFormBlockInitializer = ({
|
||||
);
|
||||
}}
|
||||
filter={filterCollections}
|
||||
showChildren={showChildren}
|
||||
hideChildrenIfSingleCollection={hideChildrenIfSingleCollection}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -92,6 +92,7 @@ function useRecordBlocks() {
|
||||
[templateWrap, templateWrapOfAssociationDetailsWithoutPagination],
|
||||
),
|
||||
showAssociationFields: true,
|
||||
hideChildrenIfSingleCollection: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
@ -119,6 +120,7 @@ function useRecordBlocks() {
|
||||
createBlockSchema: createEditFormBlock,
|
||||
templateWrap: templateWrap,
|
||||
showAssociationFields: true,
|
||||
hideChildrenIfSingleCollection: true,
|
||||
};
|
||||
},
|
||||
useVisible() {
|
||||
@ -305,7 +307,6 @@ export const recordBlockInitializers_deprecated = new CompatibleSchemaInitialize
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
showChildren: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
@ -327,7 +328,6 @@ export const recordBlockInitializers_deprecated = new CompatibleSchemaInitialize
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
showChildren: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
@ -404,7 +404,6 @@ export const recordBlockInitializers = new CompatibleSchemaInitializer(
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
showChildren: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
@ -426,7 +425,6 @@ export const recordBlockInitializers = new CompatibleSchemaInitializer(
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
showChildren: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
@ -275,8 +275,8 @@ export interface DataBlockInitializerProps {
|
||||
onlyCurrentDataSource?: boolean;
|
||||
hideSearch?: boolean;
|
||||
showAssociationFields?: boolean;
|
||||
/** 即使 children 只有一个时,也显示出来 */
|
||||
showChildren?: boolean;
|
||||
/** 如果只有一项数据表时,不显示 children 列表 */
|
||||
hideChildrenIfSingleCollection?: boolean;
|
||||
}
|
||||
|
||||
export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
||||
@ -291,7 +291,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
||||
onlyCurrentDataSource,
|
||||
hideSearch,
|
||||
showAssociationFields,
|
||||
showChildren,
|
||||
hideChildrenIfSingleCollection,
|
||||
filterDataSource,
|
||||
} = props;
|
||||
const { insert, setVisible } = useSchemaInitializer();
|
||||
@ -327,7 +327,7 @@ export const DataBlockInitializer = (props: DataBlockInitializerProps) => {
|
||||
const compiledMenuItems = useMemo(() => {
|
||||
let children = searchedChildren.filter((item) => item.key !== 'search' && item.key !== 'empty');
|
||||
const hasAssociationField = children.some((item) => item.associationField);
|
||||
if (!showChildren && !hasAssociationField && children.length === 1) {
|
||||
if (hideChildrenIfSingleCollection && !hasAssociationField && children.length === 1) {
|
||||
// 只有一项可选时,直接展开
|
||||
children = children[0].children;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user