diff --git a/packages/core/client/src/application/__tests__/data-source/record/Record.test.tsx b/packages/core/client/src/application/__tests__/data-source/record/Record.test.tsx index 47457923c9..60df75b149 100644 --- a/packages/core/client/src/application/__tests__/data-source/record/Record.test.tsx +++ b/packages/core/client/src/application/__tests__/data-source/record/Record.test.tsx @@ -1,4 +1,4 @@ -import { RecordV2 } from '../../../data-source/record'; +import { RecordV2 } from '../../../../data-source/record/Record'; describe('Record', () => { test('should works', () => { diff --git a/packages/core/client/src/application/__tests__/data-source/record/RecordProvider.test.tsx b/packages/core/client/src/application/__tests__/data-source/record/RecordProvider.test.tsx index b6988a936f..da746a77c6 100644 --- a/packages/core/client/src/application/__tests__/data-source/record/RecordProvider.test.tsx +++ b/packages/core/client/src/application/__tests__/data-source/record/RecordProvider.test.tsx @@ -1,13 +1,13 @@ -import React from 'react'; import { render, screen } from '@nocobase/test/client'; +import React from 'react'; +import { RecordV2 } from '../../../../data-source/record/Record'; import { RecordProviderV2, - RecordV2, useParentRecordDataV2, useParentRecordV2, useRecordDataV2, useRecordV2, -} from '../../../data-source/record'; +} from '../../../../data-source/record/RecordProvider'; describe('RecordProvider', () => { describe('record and parentRecord', () => { diff --git a/packages/core/client/src/schema-component/antd/association-field/index.ts b/packages/core/client/src/schema-component/antd/association-field/index.ts index 813c3d3d41..155a84a989 100644 --- a/packages/core/client/src/schema-component/antd/association-field/index.ts +++ b/packages/core/client/src/schema-component/antd/association-field/index.ts @@ -18,7 +18,10 @@ export const AssociationField: any = connect( const targetCollection = getCollection(collectionField?.target); return { ...props, - fieldNames: { ...props.fieldNames, value: collectionField?.targetKey || targetCollection.getPrimaryKey() }, + fieldNames: { + ...props.fieldNames, + value: collectionField?.targetKey || targetCollection?.getPrimaryKey() || 'id', + }, }; }), ); diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index 0f481f4385..9ef89afb94 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -67,8 +67,6 @@ import { useSchemaSettingsItem, useSortFields, } from '..'; -import { useDataSourceManagerV2 } from '../data-source/data-source/DataSourceManagerProvider'; -import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider'; import { BlockRequestContext, useFormBlockContext, useFormBlockType, useTableBlockContext } from '../block-provider'; import { FormActiveFieldsProvider, @@ -78,6 +76,8 @@ import { } from '../block-provider/hooks'; import { useCollectionFilterOptionsV2 } from '../collection-manager/action-hooks'; import { SelectWithTitle, SelectWithTitleProps } from '../common/SelectWithTitle'; +import { useDataSourceManagerV2 } from '../data-source/data-source/DataSourceManagerProvider'; +import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider'; import { FilterBlockType, getSupportFieldsByAssociation, @@ -402,8 +402,10 @@ export const SchemaSettingsFormItemTemplate = function FormItemTemplate(props) { title: t('Template name'), required: true, default: collection - ? `${compile(collection?.title || collection?.name)}_${t(componentName)}` - : t(componentName), + ? `${compile(collection?.title || collection?.name)}_${t( + componentTitle[componentName] || componentName, + )}` + : t(componentTitle[componentName] || componentName), 'x-decorator': 'FormItem', 'x-component': 'Input', }, diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/resourcers/data-sources-collections.ts b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/resourcers/data-sources-collections.ts index 76315c2c5b..47b8e7230e 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/resourcers/data-sources-collections.ts +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/resourcers/data-sources-collections.ts @@ -27,15 +27,24 @@ export default { 'name', ); + const mapCollection = (collections) => { + return collections.map((collection) => { + return { + ...collection.options, + fields: collection.getFields().map((field) => field.options), + }; + }); + }; + if (paginate === false || paginate === 'false') { - ctx.body = collections.map((collection) => collection.options); + ctx.body = mapCollection(collections); } else { const { page = 1, pageSize = 20 } = ctx.action.params; ctx.withoutDataWrapping = true; ctx.body = { - data: collections.slice((page - 1) * pageSize, page * pageSize).map((collection) => collection.options), + data: mapCollection(collections.slice((page - 1) * pageSize, page * pageSize)), meta: { count: collections.length, page,