refactor: view collection support filterTargetKey config (#3767)

* refactor: view collection support filterTargetkey config

* refactor: locale improve

* refactor: locale improve
This commit is contained in:
katherinehhh 2024-03-23 12:17:13 +08:00 committed by GitHub
parent b879d11235
commit 00dc004601
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import {
useResourceContext, useResourceContext,
useCancelAction, useCancelAction,
} from '@nocobase/client'; } from '@nocobase/client';
import { NAMESPACE } from '../../locale';
const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => {
if (!schema) { if (!schema) {
@ -56,6 +57,14 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
title: '{{ t("Edit collection") }}', title: '{{ t("Edit collection") }}',
properties: { properties: {
...omit(properties, 'category', 'inherits', 'moreOptions'), ...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: { footer: {
type: 'void', type: 'void',
'x-component': 'Action.Drawer.Footer', 'x-component': 'Action.Drawer.Footer',
@ -147,6 +156,12 @@ const EditCollectionAction = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const compile = useCompile(); 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 ( return (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContextProvider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
@ -177,6 +192,8 @@ const EditCollectionAction = (props) => {
useUpdateCollectionActionAndRefreshCM, useUpdateCollectionActionAndRefreshCM,
useCancelAction, useCancelAction,
createOnly: false, createOnly: false,
filterTargetKeyOptions,
isView: record.view,
...scope, ...scope,
}} }}
/> />

View File

@ -29,5 +29,6 @@
"Loaded": "已加载", "Loaded": "已加载",
"Reloading": "加载中", "Reloading": "加载中",
"Data source synchronization in progress": "数据源同步中", "Data source synchronization in progress": "数据源同步中",
"Data source synchronization successful": "数据源同步成功" "Data source synchronization successful": "数据源同步成功",
"Filter target key":"筛选目标键"
} }