diff --git a/packages/core/client/src/modules/blocks/data-blocks/details-multi/DetailsBlockInitializer.tsx b/packages/core/client/src/modules/blocks/data-blocks/details-multi/DetailsBlockInitializer.tsx index 361f73521..4c5bb13ca 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/details-multi/DetailsBlockInitializer.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/details-multi/DetailsBlockInitializer.tsx @@ -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} /> ); }; diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/FormBlockInitializer.tsx b/packages/core/client/src/modules/blocks/data-blocks/form/FormBlockInitializer.tsx index 1e195fe5c..5ea124e2e 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/FormBlockInitializer.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/form/FormBlockInitializer.tsx @@ -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} /> ); }; diff --git a/packages/core/client/src/modules/blocks/filter-blocks/collapse/FilterCollapseBlockInitializer.tsx b/packages/core/client/src/modules/blocks/filter-blocks/collapse/FilterCollapseBlockInitializer.tsx index d5879ddd5..075f59343 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/collapse/FilterCollapseBlockInitializer.tsx +++ b/packages/core/client/src/modules/blocks/filter-blocks/collapse/FilterCollapseBlockInitializer.tsx @@ -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} /> ); }; diff --git a/packages/core/client/src/modules/blocks/filter-blocks/form/FilterFormBlockInitializer.tsx b/packages/core/client/src/modules/blocks/filter-blocks/form/FilterFormBlockInitializer.tsx index 60a966017..1842396f5 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/form/FilterFormBlockInitializer.tsx +++ b/packages/core/client/src/modules/blocks/filter-blocks/form/FilterFormBlockInitializer.tsx @@ -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} /> ); }; diff --git a/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx index e9fce3aad..16f5197b1 100644 --- a/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx @@ -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, }; }, }, diff --git a/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx index e7baad433..8bdf7e41f 100644 --- a/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx +++ b/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx @@ -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 {