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:
parent
023096b1a9
commit
559cbca396
@ -10,10 +10,11 @@ export const CreateChildInitializer = (props) => {
|
|||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-visible': '{{treeTable}}',
|
'x-visible': '{{treeTable}}',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
icon: 'PlusOutlined',
|
|
||||||
openMode: 'drawer',
|
openMode: 'drawer',
|
||||||
type: 'primary',
|
type: 'link',
|
||||||
addChild: true,
|
addChild: true,
|
||||||
|
style: { padding: '0px', marginTop: '-5px' },
|
||||||
|
component: 'CreateRecordAction',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
drawer: {
|
drawer: {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
import { useFieldSchema } from '@formily/react';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import { useSchemaToolbar } from '../../../application';
|
import { useSchemaToolbar } from '../../../application';
|
||||||
import { SchemaSettings } from '../../../application/schema-settings/SchemaSettings';
|
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 { ButtonEditor } from '../../../schema-component/antd/action/Action.Designer';
|
||||||
import { SchemaSettingOpenModeSchemaItems } from '../../../schema-items';
|
import { SchemaSettingOpenModeSchemaItems } from '../../../schema-items';
|
||||||
import { SchemaSettingsLinkageRules } from '../../../schema-settings';
|
import { SchemaSettingsLinkageRules, SchemaSettingsEnableChildCollections } from '../../../schema-settings';
|
||||||
|
|
||||||
export const addChildActionSettings = new SchemaSettings({
|
export const addChildActionSettings = new SchemaSettings({
|
||||||
name: 'actionSettings:addChild',
|
name: 'actionSettings:addChild',
|
||||||
@ -36,6 +38,25 @@ export const addChildActionSettings = new SchemaSettings({
|
|||||||
openSize: true,
|
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',
|
name: 'delete',
|
||||||
type: 'remove',
|
type: 'remove',
|
||||||
|
@ -89,11 +89,11 @@ export function ButtonEditor(props) {
|
|||||||
field.title = title;
|
field.title = title;
|
||||||
field.componentProps.icon = icon;
|
field.componentProps.icon = icon;
|
||||||
field.componentProps.danger = type === 'danger';
|
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'] = fieldSchema['x-component-props'] || {};
|
||||||
fieldSchema['x-component-props'].icon = icon;
|
fieldSchema['x-component-props'].icon = icon;
|
||||||
fieldSchema['x-component-props'].danger = type === 'danger';
|
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', {
|
dn.emit('patch', {
|
||||||
schema: {
|
schema: {
|
||||||
['x-uid']: fieldSchema['x-uid'],
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
@ -292,8 +292,13 @@ function FinallyButton({
|
|||||||
type={componentType}
|
type={componentType}
|
||||||
icon={<DownOutlined />}
|
icon={<DownOutlined />}
|
||||||
buttonsRender={([leftButton, rightButton]) => [
|
buttonsRender={([leftButton, rightButton]) => [
|
||||||
leftButton,
|
React.cloneElement(leftButton as React.ReactElement<any, string>, {
|
||||||
React.cloneElement(rightButton as React.ReactElement<any, string>, { loading: false }),
|
style: props?.style,
|
||||||
|
}),
|
||||||
|
React.cloneElement(rightButton as React.ReactElement<any, string>, {
|
||||||
|
loading: false,
|
||||||
|
style: props?.style,
|
||||||
|
}),
|
||||||
]}
|
]}
|
||||||
menu={menu}
|
menu={menu}
|
||||||
onClick={(info) => {
|
onClick={(info) => {
|
||||||
@ -306,7 +311,13 @@ function FinallyButton({
|
|||||||
) : (
|
) : (
|
||||||
<Dropdown menu={menu}>
|
<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 />
|
{props.children} <DownOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
@ -337,9 +348,9 @@ function FinallyButton({
|
|||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
{...props}
|
||||||
aria-label={props['aria-label']}
|
aria-label={props['aria-label']}
|
||||||
type={componentType}
|
type={componentType}
|
||||||
disabled={field.disabled}
|
disabled={field.disabled}
|
||||||
|
Loading…
Reference in New Issue
Block a user