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) => {
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<ISchema>();
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';

View File

@ -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,

View File

@ -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 (
<SchemaSettings.ModalItem