mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:26:22 +00:00
feat: remove table field details actions (#638)
This commit is contained in:
parent
ffff6436ac
commit
a60759b2eb
@ -1,11 +1,11 @@
|
|||||||
import { FormOutlined, TableOutlined } from '@ant-design/icons';
|
import { FormOutlined, TableOutlined } from '@ant-design/icons';
|
||||||
import { FormDialog, FormLayout } from '@formily/antd';
|
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 { merge } from '@formily/shared';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient } from '../../api-client';
|
import { useAPIClient } from '../../api-client';
|
||||||
import { useBlockAssociationContext } from '../../block-provider';
|
import { useBlockAssociationContext, useBlockRequestContext } from '../../block-provider';
|
||||||
import { useCollection, useCollectionManager } from '../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../collection-manager';
|
||||||
import { SchemaComponent, SchemaComponentOptions } from '../../schema-component';
|
import { SchemaComponent, SchemaComponentOptions } from '../../schema-component';
|
||||||
import { useSchemaTemplateManager } from '../../schema-templates';
|
import { useSchemaTemplateManager } from '../../schema-templates';
|
||||||
@ -643,6 +643,7 @@ export const RecordFormBlockInitializer = (props) => {
|
|||||||
const { getTemplateSchemaByMode } = useSchemaTemplateManager();
|
const { getTemplateSchemaByMode } = useSchemaTemplateManager();
|
||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const association = useBlockAssociationContext();
|
const association = useBlockAssociationContext();
|
||||||
|
console.log('RecordFormBlockInitializer', collection, association);
|
||||||
return (
|
return (
|
||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
icon={<FormOutlined />}
|
icon={<FormOutlined />}
|
||||||
@ -687,9 +688,13 @@ export const RecordFormBlockInitializer = (props) => {
|
|||||||
|
|
||||||
export const RecordReadPrettyFormBlockInitializer = (props) => {
|
export const RecordReadPrettyFormBlockInitializer = (props) => {
|
||||||
const { onCreateBlockSchema, componentType, createBlockSchema, insert, ...others } = props;
|
const { onCreateBlockSchema, componentType, createBlockSchema, insert, ...others } = props;
|
||||||
|
|
||||||
const { getTemplateSchemaByMode } = useSchemaTemplateManager();
|
const { getTemplateSchemaByMode } = useSchemaTemplateManager();
|
||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const association = useBlockAssociationContext();
|
const association = useBlockAssociationContext();
|
||||||
|
const { block } = useBlockRequestContext();
|
||||||
|
const actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
icon={<FormOutlined />}
|
icon={<FormOutlined />}
|
||||||
@ -700,6 +705,7 @@ export const RecordReadPrettyFormBlockInitializer = (props) => {
|
|||||||
const s = await getTemplateSchemaByMode(item);
|
const s = await getTemplateSchemaByMode(item);
|
||||||
if (item.template.componentName === 'ReadPrettyFormItem') {
|
if (item.template.componentName === 'ReadPrettyFormItem') {
|
||||||
const blockSchema = createReadPrettyFormBlockSchema({
|
const blockSchema = createReadPrettyFormBlockSchema({
|
||||||
|
actionInitializers,
|
||||||
association,
|
association,
|
||||||
collection: collection.name,
|
collection: collection.name,
|
||||||
action: 'get',
|
action: 'get',
|
||||||
@ -717,6 +723,7 @@ export const RecordReadPrettyFormBlockInitializer = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
insert(
|
insert(
|
||||||
createReadPrettyFormBlockSchema({
|
createReadPrettyFormBlockSchema({
|
||||||
|
actionInitializers,
|
||||||
association,
|
association,
|
||||||
collection: collection.name,
|
collection: collection.name,
|
||||||
action: 'get',
|
action: 'get',
|
||||||
@ -792,6 +799,9 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => {
|
|||||||
const field = item.field;
|
const field = item.field;
|
||||||
const collection = field.target;
|
const collection = field.target;
|
||||||
const resource = `${field.collectionName}.${field.name}`;
|
const resource = `${field.collectionName}.${field.name}`;
|
||||||
|
const { block } = useBlockRequestContext();
|
||||||
|
const actionInitializers = block !== 'TableField' ? 'ReadPrettyFormActionInitializers' : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
icon={<FormOutlined />}
|
icon={<FormOutlined />}
|
||||||
@ -801,6 +811,7 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => {
|
|||||||
const s = await getTemplateSchemaByMode(item);
|
const s = await getTemplateSchemaByMode(item);
|
||||||
if (item.template.componentName === 'ReadPrettyFormItem') {
|
if (item.template.componentName === 'ReadPrettyFormItem') {
|
||||||
const blockSchema = createReadPrettyFormBlockSchema({
|
const blockSchema = createReadPrettyFormBlockSchema({
|
||||||
|
actionInitializers,
|
||||||
collection,
|
collection,
|
||||||
resource,
|
resource,
|
||||||
association: resource,
|
association: resource,
|
||||||
@ -819,6 +830,7 @@ export const RecordReadPrettyAssociationFormBlockInitializer = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
insert(
|
insert(
|
||||||
createReadPrettyFormBlockSchema({
|
createReadPrettyFormBlockSchema({
|
||||||
|
actionInitializers,
|
||||||
collection,
|
collection,
|
||||||
resource,
|
resource,
|
||||||
association: resource,
|
association: resource,
|
||||||
|
Loading…
Reference in New Issue
Block a user