fix: create or delete collection error (#501)

This commit is contained in:
金昶 2022-06-11 23:47:40 +08:00 committed by GitHub
parent 3496126102
commit 05d315115f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,15 @@
import { ISchema } from '@formily/react';
import { ISchema, Schema } from '@formily/react';
import { useTranslation } from 'react-i18next';
import { i18n } from '../../../i18n';
import { useRecord } from '../../../record-provider';
import { useCompile } from '../../../schema-component';
import { CollectionOptions } from '../../types';
import { collectionFieldSchema } from './collectionFields';
const compile = (source) => {
return Schema.compile(source, { t: i18n.t });
}
const collection: CollectionOptions = {
name: 'collections',
filterTargetKey: 'name',
@ -200,11 +205,12 @@ export const collectionSchema: ISchema = {
drawer: {
type: 'void',
'x-component': 'Action.Drawer',
'x-reactions': (field) => {
'x-reactions': (field) => {
const i = field.path.segments[1];
const table = field.form.getValuesIn(`table.${i}`);
const compile = useCompile();
field.title = `${compile(table.title)} - ${compile('{{ t("Configure fields") }}')}`;
if (table) {
field.title = `${compile(table.title)} - ${compile('{{ t("Configure fields") }}')}`;
}
},
properties: {
collectionFieldSchema,