From 2d84cc34eac4de3971a5483c415c8356df4ab11a Mon Sep 17 00:00:00 2001 From: Dunqing Date: Mon, 3 Apr 2023 13:54:12 +0800 Subject: [PATCH] feat(Table): column action support linkage rules (#1638) --- .../src/schema-component/antd/action/Action.Designer.tsx | 3 ++- .../buttons/TableActionColumnInitializers.tsx | 2 ++ packages/core/client/src/schema-settings/SchemaSettings.tsx | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) 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 f10970cd3..0b4c2f2cf 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 @@ -38,7 +38,7 @@ const MenuGroup = (props) => { }; export const ActionDesigner = (props) => { - const { modalTip, ...restProps } = props; + const { modalTip, linkageAction, ...restProps } = props; const field = useField(); const fieldSchema = useFieldSchema(); const { name } = useCollection(); @@ -50,6 +50,7 @@ export const ActionDesigner = (props) => { const [initialSchema, setInitialSchema] = useState(); const actionType = fieldSchema['x-action'] ?? ''; const isLinkageAction = + linkageAction || (Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0) || fieldSchema?.parent?.['x-initializer'] === 'DetailsActionInitializers'; const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create'; diff --git a/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx index ba97bf8b3..78c121f53 100644 --- a/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/TableActionColumnInitializers.tsx @@ -6,6 +6,7 @@ import { SchemaInitializer, SchemaSettings } from '../..'; import { useAPIClient } from '../../api-client'; import { useCollection } from '../../collection-manager'; import { createDesignable, useDesignable } from '../../schema-component'; +import _ from 'lodash'; export const Resizable = (props) => { const { t } = useTranslation(); @@ -66,6 +67,7 @@ export const TableActionColumnInitializers = (props: any) => { if (!spaceSchema) { return; } + _.set(schema, 'x-designer-props.linkageAction', true); const dn = createDesignable({ t, api, diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index 123f5b4c1..2c1dfe158 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -944,7 +944,7 @@ SchemaSettings.LinkageRules = (props) => { const { dn } = useDesignable(); const { t } = useTranslation(); const { getTemplateById } = useSchemaTemplateManager(); - const type = fieldSchema['x-component'] === 'Action' ? 'button' : 'field'; + const type = ['Action', 'Action.Link'].includes(fieldSchema['x-component']) ? 'button' : 'field'; const gridSchema = findGridSchema(fieldSchema) || fieldSchema; return (