Merge branch 'feat/dataSource-manager' of github.com:nocobase/nocobase into feat/dataSource-manager

This commit is contained in:
katherinehhh 2024-02-07 08:24:06 +08:00
commit cb4a6ed29d
5 changed files with 25 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { RecordV2 } from '../../../data-source/record';
import { RecordV2 } from '../../../../data-source/record/Record';
describe('Record', () => {
test('should works', () => {

View File

@ -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', () => {

View File

@ -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',
},
};
}),
);

View File

@ -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',
},

View File

@ -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,