refactor: add child in inheritance of tree collection (#3676)

* refactor: add child in inheritance of tree collection

* refactor: add child in inheritance of tree collection

* style: style improve
This commit is contained in:
katherinehhh 2024-03-12 17:27:35 +08:00 committed by GitHub
parent 023096b1a9
commit 559cbca396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 10 deletions

View File

@ -10,10 +10,11 @@ export const CreateChildInitializer = (props) => {
'x-component': 'Action',
'x-visible': '{{treeTable}}',
'x-component-props': {
icon: 'PlusOutlined',
openMode: 'drawer',
type: 'primary',
type: 'link',
addChild: true,
style: { padding: '0px', marginTop: '-5px' },
component: 'CreateRecordAction',
},
properties: {
drawer: {

View File

@ -1,9 +1,11 @@
import { useFieldSchema } from '@formily/react';
import { useMemo } from 'react';
import { useSchemaToolbar } from '../../../application';
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
import { useCollection_deprecated } from '../../../collection-manager';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
import { ButtonEditor } from '../../../schema-component/antd/action/Action.Designer';
import { SchemaSettingOpenModeSchemaItems } from '../../../schema-items';
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
import { SchemaSettingsLinkageRules, SchemaSettingsEnableChildCollections } from '../../../schema-settings';
export const addChildActionSettings = new SchemaSettings({
name: 'actionSettings:addChild',
@ -36,6 +38,25 @@ export const addChildActionSettings = new SchemaSettings({
openSize: true,
},
},
{
name: 'enableChildCollections',
Component: SchemaSettingsEnableChildCollections,
useVisible() {
const { name } = useCollection_deprecated();
const { getChildrenCollections } = useCollectionManager_deprecated();
const isChildCollectionAction = useMemo(
() => getChildrenCollections(name).length > 0,
[getChildrenCollections, name],
);
return isChildCollectionAction;
},
useComponentProps() {
const { name } = useCollection_deprecated();
return {
collectionName: name,
};
},
},
{
name: 'delete',
type: 'remove',

View File

@ -89,11 +89,11 @@ export function ButtonEditor(props) {
field.title = title;
field.componentProps.icon = icon;
field.componentProps.danger = type === 'danger';
field.componentProps.type = type;
field.componentProps.type = type || field.componentProps.type;
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
fieldSchema['x-component-props'].icon = icon;
fieldSchema['x-component-props'].danger = type === 'danger';
fieldSchema['x-component-props'].type = type;
fieldSchema['x-component-props'].type = type || field.componentProps.type;
dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],

View File

@ -292,8 +292,13 @@ function FinallyButton({
type={componentType}
icon={<DownOutlined />}
buttonsRender={([leftButton, rightButton]) => [
leftButton,
React.cloneElement(rightButton as React.ReactElement<any, string>, { loading: false }),
React.cloneElement(leftButton as React.ReactElement<any, string>, {
style: props?.style,
}),
React.cloneElement(rightButton as React.ReactElement<any, string>, {
loading: false,
style: props?.style,
}),
]}
menu={menu}
onClick={(info) => {
@ -306,7 +311,13 @@ function FinallyButton({
) : (
<Dropdown menu={menu}>
{
<Button aria-label={props['aria-label']} icon={icon} type={componentType} danger={props.danger}>
<Button
aria-label={props['aria-label']}
icon={icon}
type={componentType}
danger={props.danger}
style={props?.style}
>
{props.children} <DownOutlined />
</Button>
}
@ -337,9 +348,9 @@ function FinallyButton({
</Button>
);
}
return (
<Button
{...props}
aria-label={props['aria-label']}
type={componentType}
disabled={field.disabled}