mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 07:29:24 +08:00
feat: expand and collapse are only displayed in the tree table
This commit is contained in:
parent
b28b8ba536
commit
42aba5e50b
@ -47,59 +47,63 @@ SchemaInitializer.Button = observer((props: SchemaInitializerButtonProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const renderItems = (items: any) => {
|
const renderItems = (items: any) => {
|
||||||
return items?.map((item, indexA) => {
|
return items
|
||||||
if (item.type === 'divider') {
|
.filter((v) => {
|
||||||
return <Menu.Divider key={item.key || `item-${indexA}`} />;
|
return v?.visible ? v.visible() : true;
|
||||||
}
|
})
|
||||||
if (item.type === 'item' && item.component) {
|
?.map((item, indexA) => {
|
||||||
const Component = findComponent(item.component);
|
if (item.type === 'divider') {
|
||||||
item.key = `${item.key || item.title}-${indexA}`;
|
return <Menu.Divider key={item.key || `item-${indexA}`} />;
|
||||||
return (
|
}
|
||||||
Component && (
|
if (item.type === 'item' && item.component) {
|
||||||
<SchemaInitializerItemContext.Provider
|
const Component = findComponent(item.component);
|
||||||
key={item.key}
|
item.key = `${item.key || item.title}-${indexA}`;
|
||||||
value={{
|
return (
|
||||||
index: indexA,
|
Component && (
|
||||||
item,
|
<SchemaInitializerItemContext.Provider
|
||||||
info: item,
|
key={item.key}
|
||||||
insert: insertSchema,
|
value={{
|
||||||
}}
|
index: indexA,
|
||||||
>
|
item,
|
||||||
<Component
|
info: item,
|
||||||
{...item}
|
insert: insertSchema,
|
||||||
item={{
|
|
||||||
...item,
|
|
||||||
title: compile(item.title),
|
|
||||||
}}
|
}}
|
||||||
insert={insertSchema}
|
>
|
||||||
/>
|
<Component
|
||||||
</SchemaInitializerItemContext.Provider>
|
{...item}
|
||||||
)
|
item={{
|
||||||
);
|
...item,
|
||||||
}
|
title: compile(item.title),
|
||||||
if (item.type === 'itemGroup') {
|
}}
|
||||||
return (
|
insert={insertSchema}
|
||||||
!!item.children?.length && (
|
/>
|
||||||
<Menu.ItemGroup key={item.key || `item-group-${indexA}`} title={compile(item.title)}>
|
</SchemaInitializerItemContext.Provider>
|
||||||
{renderItems(item.children)}
|
)
|
||||||
</Menu.ItemGroup>
|
);
|
||||||
)
|
}
|
||||||
);
|
if (item.type === 'itemGroup') {
|
||||||
}
|
return (
|
||||||
if (item.type === 'subMenu') {
|
!!item.children?.length && (
|
||||||
return (
|
<Menu.ItemGroup key={item.key || `item-group-${indexA}`} title={compile(item.title)}>
|
||||||
!!item.children?.length && (
|
{renderItems(item.children)}
|
||||||
<Menu.SubMenu
|
</Menu.ItemGroup>
|
||||||
key={item.key || `item-group-${indexA}`}
|
)
|
||||||
title={compile(item.title)}
|
);
|
||||||
popupClassName={menuItemGroupCss}
|
}
|
||||||
>
|
if (item.type === 'subMenu') {
|
||||||
{renderItems(item.children)}
|
return (
|
||||||
</Menu.SubMenu>
|
!!item.children?.length && (
|
||||||
)
|
<Menu.SubMenu
|
||||||
);
|
key={item.key || `item-group-${indexA}`}
|
||||||
}
|
title={compile(item.title)}
|
||||||
});
|
popupClassName={menuItemGroupCss}
|
||||||
|
>
|
||||||
|
{renderItems(item.children)}
|
||||||
|
</Menu.SubMenu>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
const menu = <Menu style={{ maxHeight: '60vh', overflowY: 'auto' }}>{renderItems(items)}</Menu>;
|
const menu = <Menu style={{ maxHeight: '60vh', overflowY: 'auto' }}>{renderItems(items)}</Menu>;
|
||||||
if (!designable && props.designable !== true) {
|
if (!designable && props.designable !== true) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Schema } from '@formily/react';
|
import { Schema, useFieldSchema } from '@formily/react';
|
||||||
|
import { useCollection } from '../../';
|
||||||
|
|
||||||
// 表格操作配置
|
// 表格操作配置
|
||||||
export const TableActionInitializers = {
|
export const TableActionInitializers = {
|
||||||
@ -56,6 +57,12 @@ export const TableActionInitializers = {
|
|||||||
schema: {
|
schema: {
|
||||||
'x-align': 'right',
|
'x-align': 'right',
|
||||||
},
|
},
|
||||||
|
visible: () => {
|
||||||
|
const schema = useFieldSchema();
|
||||||
|
const collection = useCollection();
|
||||||
|
const { treeTable } = schema?.parent?.['x-decorator-props'];
|
||||||
|
return (collection as any).template === 'tree' && treeTable !== false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user