From 00dc004601cf57f670fc5fd198f1ad5953048d1f Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sat, 23 Mar 2024 12:17:13 +0800 Subject: [PATCH] refactor: view collection support filterTargetKey config (#3767) * refactor: view collection support filterTargetkey config * refactor: locale improve * refactor: locale improve --- .../CollectionsManager/EditCollectionAction.tsx | 17 +++++++++++++++++ .../src/locale/zh-CN.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx index ce86022e2..92e1c9745 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditCollectionAction.tsx @@ -21,6 +21,7 @@ import { useResourceContext, useCancelAction, } from '@nocobase/client'; +import { NAMESPACE } from '../../locale'; const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { if (!schema) { @@ -56,6 +57,14 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema title: '{{ t("Edit collection") }}', properties: { ...omit(properties, 'category', 'inherits', 'moreOptions'), + filterTargetKey: { + title: `{{ t("Filter target key",{ ns: "${NAMESPACE}" }) }}`, + type: 'single', + 'x-decorator': 'FormItem', + 'x-component': 'Select', + enum: '{{filterTargetKeyOptions}}', + 'x-visible': '{{isView}}', + }, footer: { type: 'void', 'x-component': 'Action.Drawer.Footer', @@ -147,6 +156,12 @@ const EditCollectionAction = (props) => { const { t } = useTranslation(); const compile = useCompile(); + const filterTargetKeyOptions = record.fields?.map((item: any) => { + return { + label: item.uiSchema?.title ? compile(item.uiSchema.title) : item.name, + value: item.name, + }; + }); return ( @@ -177,6 +192,8 @@ const EditCollectionAction = (props) => { useUpdateCollectionActionAndRefreshCM, useCancelAction, createOnly: false, + filterTargetKeyOptions, + isView: record.view, ...scope, }} /> diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-data-source-manager/src/locale/zh-CN.json index e0629b75d..f94de0ba6 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/locale/zh-CN.json @@ -29,5 +29,6 @@ "Loaded": "已加载", "Reloading": "加载中", "Data source synchronization in progress": "数据源同步中", - "Data source synchronization successful": "数据源同步成功" + "Data source synchronization successful": "数据源同步成功", + "Filter target key":"筛选目标键" }