feat(Table): column action support linkage rules (#1638)

This commit is contained in:
Dunqing 2023-04-03 13:54:12 +08:00 committed by GitHub
parent c38dbd1675
commit 2d84cc34ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -38,7 +38,7 @@ const MenuGroup = (props) => {
}; };
export const ActionDesigner = (props) => { export const ActionDesigner = (props) => {
const { modalTip, ...restProps } = props; const { modalTip, linkageAction, ...restProps } = props;
const field = useField(); const field = useField();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const { name } = useCollection(); const { name } = useCollection();
@ -50,6 +50,7 @@ export const ActionDesigner = (props) => {
const [initialSchema, setInitialSchema] = useState<ISchema>(); const [initialSchema, setInitialSchema] = useState<ISchema>();
const actionType = fieldSchema['x-action'] ?? ''; const actionType = fieldSchema['x-action'] ?? '';
const isLinkageAction = const isLinkageAction =
linkageAction ||
(Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0) || (Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0) ||
fieldSchema?.parent?.['x-initializer'] === 'DetailsActionInitializers'; fieldSchema?.parent?.['x-initializer'] === 'DetailsActionInitializers';
const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create'; const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create';

View File

@ -6,6 +6,7 @@ import { SchemaInitializer, SchemaSettings } from '../..';
import { useAPIClient } from '../../api-client'; import { useAPIClient } from '../../api-client';
import { useCollection } from '../../collection-manager'; import { useCollection } from '../../collection-manager';
import { createDesignable, useDesignable } from '../../schema-component'; import { createDesignable, useDesignable } from '../../schema-component';
import _ from 'lodash';
export const Resizable = (props) => { export const Resizable = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -66,6 +67,7 @@ export const TableActionColumnInitializers = (props: any) => {
if (!spaceSchema) { if (!spaceSchema) {
return; return;
} }
_.set(schema, 'x-designer-props.linkageAction', true);
const dn = createDesignable({ const dn = createDesignable({
t, t,
api, api,

View File

@ -944,7 +944,7 @@ SchemaSettings.LinkageRules = (props) => {
const { dn } = useDesignable(); const { dn } = useDesignable();
const { t } = useTranslation(); const { t } = useTranslation();
const { getTemplateById } = useSchemaTemplateManager(); 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; const gridSchema = findGridSchema(fieldSchema) || fieldSchema;
return ( return (
<SchemaSettings.ModalItem <SchemaSettings.ModalItem