From 05d315115fd559fd45149af59e31f5629a1dae56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=98=B6?= Date: Sat, 11 Jun 2022 23:47:40 +0800 Subject: [PATCH] fix: create or delete collection error (#501) --- .../Configuration/schemas/collections.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts b/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts index dd1824389..cd742f978 100644 --- a/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts +++ b/packages/core/client/src/collection-manager/Configuration/schemas/collections.ts @@ -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,