mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix(data-templates): should also show data-templates option when add new subrecord
This commit is contained in:
parent
221c90d835
commit
11fb951b55
@ -1,12 +1,11 @@
|
||||
import { ArrayItems } from '@formily/antd';
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useFormBlockContext } from '../../../block-provider';
|
||||
import { useDetailsBlockContext } from '../../../block-provider/DetailsBlockProvider';
|
||||
import { useCollection } from '../../../collection-manager';
|
||||
import { useCollectionFilterOptions, useSortFields } from '../../../collection-manager/action-hooks';
|
||||
import { useRecord } from '../../../record-provider';
|
||||
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
||||
import { useSchemaTemplate } from '../../../schema-templates';
|
||||
import { useDesignable } from '../../hooks';
|
||||
@ -18,14 +17,15 @@ export const FormDesigner = () => {
|
||||
const template = useSchemaTemplate();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const defaultResource = fieldSchema?.['x-decorator-props']?.resource;
|
||||
const record = useRecord();
|
||||
const { action } = useFormBlockContext();
|
||||
|
||||
return (
|
||||
<GeneralSchemaDesigner template={template} title={title || name}>
|
||||
{/* <SchemaSettings.Template componentName={'FormItem'} collectionName={name} /> */}
|
||||
<SchemaSettings.BlockTitleItem />
|
||||
<SchemaSettings.LinkageRules collectionName={name} />
|
||||
{_.isEmpty(record) ? <SchemaSettings.DataTemplates collectionName={name} /> : null}
|
||||
{/* 当 action 没有值的时候,说明是在用表单创建新数据,此时需要显示数据模板 */}
|
||||
{!action ? <SchemaSettings.DataTemplates collectionName={name} /> : null}
|
||||
<SchemaSettings.Divider />
|
||||
<SchemaSettings.FormItemTemplate
|
||||
componentName={'FormItem'}
|
||||
|
@ -989,7 +989,6 @@ export const createFormBlockSchema = (options) => {
|
||||
},
|
||||
},
|
||||
};
|
||||
console.log(JSON.stringify(schema, null, 2));
|
||||
return schema;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user