mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 10:09:21 +00:00
Merge branch 'feat/dataSource-manager' of github.com:nocobase/nocobase into feat/dataSource-manager
This commit is contained in:
commit
cb4a6ed29d
@ -1,4 +1,4 @@
|
||||
import { RecordV2 } from '../../../data-source/record';
|
||||
import { RecordV2 } from '../../../../data-source/record/Record';
|
||||
|
||||
describe('Record', () => {
|
||||
test('should works', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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',
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
@ -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',
|
||||
},
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user