From 6ff60c1b8a6017bda9432891f372f47015b2ca3c Mon Sep 17 00:00:00 2001 From: Katherine Date: Sat, 14 Dec 2024 22:59:36 +0800 Subject: [PATCH] fix:pg view creation issue, resolve error when selecting views across schemas (#5881) * fix: pg view creation issue, resolve error when selecting views across schemas * fix: pg view creation issue, resolve error when selecting views across schemas * refactor: locale * fix: bug --- .../templates/components/PreviewFields.tsx | 6 +++++- .../core/client/src/collection-manager/templates/view.tsx | 6 ++++-- packages/core/client/src/locale/zh-CN.json | 5 +++-- .../Configuration/ConfigurationTable.tsx | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx index e1098151e0..551e01505c 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx @@ -266,7 +266,11 @@ const PreviewCom = (props) => { }; function areEqual(prevProps, nextProps) { - return nextProps.name === prevProps.name && nextProps.sources === prevProps.sources; + return ( + nextProps.viewName === prevProps.viewName && + nextProps.schema === prevProps.schema && + nextProps.source === prevProps.source + ); } export const PreviewFields = React.memo(PreviewCom, areEqual); diff --git a/packages/core/client/src/collection-manager/templates/view.tsx b/packages/core/client/src/collection-manager/templates/view.tsx index 197fbda053..c059fbc2ef 100644 --- a/packages/core/client/src/collection-manager/templates/view.tsx +++ b/packages/core/client/src/collection-manager/templates/view.tsx @@ -73,7 +73,7 @@ export class ViewCollectionTemplate extends CollectionTemplate { when: '{{isPG}}', fulfill: { state: { - value: "{{$deps[0].split('_')?.[0]}}", + value: "{{$deps[0].split('@')?.[0]}}", }, }, otherwise: { @@ -91,7 +91,7 @@ export class ViewCollectionTemplate extends CollectionTemplate { when: '{{isPG}}', fulfill: { state: { - value: '{{$deps[0].match(/^([^_]+)_(.*)$/)?.[2]}}', + value: "{{$deps[0].split('@')?.[1]}}", }, }, otherwise: { @@ -125,6 +125,7 @@ export class ViewCollectionTemplate extends CollectionTemplate { type: 'array', 'x-component': PreviewFields, 'x-hidden': '{{ !createOnly }}', + 'x-decorator': 'FormItem', 'x-reactions': { dependencies: ['name'], fulfill: { @@ -133,6 +134,7 @@ export class ViewCollectionTemplate extends CollectionTemplate { }, }, }, + description: `{{t("Fields can only be used correctly if they are defined with an interface.")}}`, }, preview: { type: 'void', diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index b952466382..e1ad8c7f6f 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -1025,11 +1025,12 @@ "Ellipsis": "省略", "Set block layout": "设置区块布局", "Add & Update": "添加 & 更新", - "Table size":"表格大小", + "Table size": "表格大小", "Hide column": "隐藏列", "In configuration mode, the entire column becomes transparent. In non-configuration mode, the entire column will be hidden. Even if the entire column is hidden, its configured default values and other settings will still take effect.": "在配置模式下,整个列会变为透明色。在非配置模式下,整个列将被隐藏。即使整个列被隐藏了,其配置的默认值和其他设置仍然有效。", "Plugin": "插件", "Bulk enable": "批量激活", "Search plugin...": "搜索插件...", - "Package name": "包名" + "Package name": "包名", + "Fields can only be used correctly if they are defined with an interface.": "只有字段设置了interface字段才能正常使用" } diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx index 816f7c23d6..72946d9186 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/MainDataSourceManager/Configuration/ConfigurationTable.tsx @@ -161,7 +161,7 @@ export const ConfigurationTable = () => { const schema = item.schema; return { label: schema ? `${schema}.${compile(item.name)}` : item.name, - value: schema ? `${schema}_${item.name}` : item.name, + value: schema ? `${schema}@${item.name}` : item.name, }; }); });