diff --git a/packages/core/client/src/modules/actions/add-child/CreateChildInitializer.tsx b/packages/core/client/src/modules/actions/add-child/CreateChildInitializer.tsx index 58a237a6f..9c82a52b5 100644 --- a/packages/core/client/src/modules/actions/add-child/CreateChildInitializer.tsx +++ b/packages/core/client/src/modules/actions/add-child/CreateChildInitializer.tsx @@ -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: { diff --git a/packages/core/client/src/modules/actions/add-child/addChildActionSettings.tsx b/packages/core/client/src/modules/actions/add-child/addChildActionSettings.tsx index 6bd6ce06c..0298db713 100644 --- a/packages/core/client/src/modules/actions/add-child/addChildActionSettings.tsx +++ b/packages/core/client/src/modules/actions/add-child/addChildActionSettings.tsx @@ -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', diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index cdd890d9f..ce184b1ec 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -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'], diff --git a/packages/core/client/src/schema-initializer/components/CreateRecordAction.tsx b/packages/core/client/src/schema-initializer/components/CreateRecordAction.tsx index e072b4dd0..70387ce7c 100644 --- a/packages/core/client/src/schema-initializer/components/CreateRecordAction.tsx +++ b/packages/core/client/src/schema-initializer/components/CreateRecordAction.tsx @@ -292,8 +292,13 @@ function FinallyButton({ type={componentType} icon={} buttonsRender={([leftButton, rightButton]) => [ - leftButton, - React.cloneElement(rightButton as React.ReactElement, { loading: false }), + React.cloneElement(leftButton as React.ReactElement, { + style: props?.style, + }), + React.cloneElement(rightButton as React.ReactElement, { + loading: false, + style: props?.style, + }), ]} menu={menu} onClick={(info) => { @@ -306,7 +311,13 @@ function FinallyButton({ ) : ( { - } @@ -337,9 +348,9 @@ function FinallyButton({ ); } - return (