From a60759b2ebb7fd03a47e05e99b70f9444389ae91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=98=B6?= Date: Sun, 17 Jul 2022 13:30:42 +0800 Subject: [PATCH] feat: remove table field details actions (#638) --- .../src/schema-initializer/items/index.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/schema-initializer/items/index.tsx b/packages/core/client/src/schema-initializer/items/index.tsx index 7906c6c22..6b2712507 100644 --- a/packages/core/client/src/schema-initializer/items/index.tsx +++ b/packages/core/client/src/schema-initializer/items/index.tsx @@ -1,11 +1,11 @@ import { FormOutlined, TableOutlined } from '@ant-design/icons'; import { FormDialog, FormLayout } from '@formily/antd'; -import { ISchema, SchemaOptionsContext } from '@formily/react'; +import { ISchema, SchemaOptionsContext, useFieldSchema } from '@formily/react'; import { merge } from '@formily/shared'; import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { useAPIClient } from '../../api-client'; -import { useBlockAssociationContext } from '../../block-provider'; +import { useBlockAssociationContext, useBlockRequestContext } from '../../block-provider'; import { useCollection, useCollectionManager } from '../../collection-manager'; import { SchemaComponent, SchemaComponentOptions } from '../../schema-component'; import { useSchemaTemplateManager } from '../../schema-templates'; @@ -643,6 +643,7 @@ export const RecordFormBlockInitializer = (props) => { const { getTemplateSchemaByMode } = useSchemaTemplateManager(); const collection = useCollection(); const association = useBlockAssociationContext(); + console.log('RecordFormBlockInitializer', collection, association); return ( } @@ -687,9 +688,13 @@ export const RecordFormBlockInitializer = (props) => { export const RecordReadPrettyFormBlockInitializer = (props) => { const { onCreateBlockSchema, componentType, createBlockSchema, insert, ...others } = props; + const { getTemplateSchemaByMode } = useSchemaTemplateManager(); const collection = useCollection(); const association = useBlockAssociationContext(); + const { block } = useBlockRequestContext(); + const actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null; + return ( } @@ -700,6 +705,7 @@ export const RecordReadPrettyFormBlockInitializer = (props) => { const s = await getTemplateSchemaByMode(item); if (item.template.componentName === 'ReadPrettyFormItem') { const blockSchema = createReadPrettyFormBlockSchema({ + actionInitializers, association, collection: collection.name, action: 'get', @@ -717,6 +723,7 @@ export const RecordReadPrettyFormBlockInitializer = (props) => { } else { insert( createReadPrettyFormBlockSchema({ + actionInitializers, association, collection: collection.name, action: 'get', @@ -792,6 +799,9 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => { const field = item.field; const collection = field.target; const resource = `${field.collectionName}.${field.name}`; + const { block } = useBlockRequestContext(); + const actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null; + return ( } @@ -801,6 +811,7 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => { const s = await getTemplateSchemaByMode(item); if (item.template.componentName === 'ReadPrettyFormItem') { const blockSchema = createReadPrettyFormBlockSchema({ + actionInitializers, collection, resource, association: resource, @@ -819,6 +830,7 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => { } else { insert( createReadPrettyFormBlockSchema({ + actionInitializers, collection, resource, association: resource,