From c38dbd16756da866d35f3fd1178506e86f909ef9 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Mon, 3 Apr 2023 12:08:26 +0800 Subject: [PATCH] fix(view-collection): field name cannot be edited when there with field source (#1642) * fix: field name cannot be edited when there with field source * fix: did not bring the uiSchema when selecting interface --- .../templates/components/PreviewFields.tsx | 15 +++++++++------ .../templates/components/PreviewTable.tsx | 2 +- 2 files changed, 10 insertions(+), 7 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 0f27b521d..47b6bf09b 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewFields.tsx @@ -30,7 +30,7 @@ const PreviewCom = (props) => { const [sourceFields, setSourceFields] = useState([]); const field: any = useField(); const form = useForm(); - const { getCollection } = useCollectionManager(); + const { getCollection, getInterface } = useCollectionManager(); const compile = useCompile(); const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key)); useEffect(() => { @@ -148,7 +148,10 @@ const PreviewCom = (props) => { handleFieldChange({ ...item, uiSchema: { title: e.target.value } }, index)} + onChange={(e) => + handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index) + } /> ); }, diff --git a/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx b/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx index e9de3b70e..9d8d7d5f2 100644 --- a/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx +++ b/packages/core/client/src/collection-manager/templates/components/PreviewTable.tsx @@ -47,7 +47,7 @@ export const PreviewTable = (props) => { const fieldSource = typeof item?.source === 'string' ? item?.source?.split('.') : item?.source; const sourceField = getCollection(fieldSource?.[0])?.fields.find((v) => v.name === fieldSource?.[1])?.uiSchema ?.title; - const target = sourceField || item?.uiSchema?.title || item.name; + const target = item?.uiSchema?.title || sourceField || item.name; const schema: any = item.source ? getCollectionField(typeof item.source === 'string' ? item.source : item.source.join('.'))?.uiSchema : getInterface(item.interface)?.default?.uiSchema;