mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-06 22:19:25 +08:00
* feat: collection template support availableTargetCollections * feat: add targetScope * feat: code opmization * feat: custom-collection-template improve * feat: useAsyncDataSource fix * feat: useAsyncDataSource fix
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { getConfigurableProperties, ICollectionTemplate, registerTemplate } from '@nocobase/client';
|
|
import React from 'react';
|
|
|
|
const myCollectionTemplate: ICollectionTemplate = {
|
|
name: 'myCollection',
|
|
title: '{{t("Custom template")}}',
|
|
order: 6,
|
|
color: 'blue',
|
|
default: {
|
|
fields: [
|
|
{
|
|
name: 'uuid',
|
|
type: 'string',
|
|
primaryKey: true,
|
|
allowNull: false,
|
|
uiSchema: { type: 'number', title: '{{t("UUID")}}', 'x-component': 'Input', 'x-read-pretty': true },
|
|
interface: 'input',
|
|
},
|
|
],
|
|
},
|
|
configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'createdAt', 'updatedAt'),
|
|
availableFieldInterfaces: {
|
|
include: [
|
|
'input',
|
|
{
|
|
interface: 'o2m',
|
|
targetScope: {
|
|
template: ['calendar'],
|
|
},
|
|
},
|
|
{
|
|
interface: 'm2m',
|
|
targetScope: {
|
|
template: ['calendar', 'myCollection'],
|
|
},
|
|
},
|
|
{
|
|
interface: 'linkTo',
|
|
targetScope: {
|
|
template: ['myCollection'],
|
|
},
|
|
},
|
|
],
|
|
// exclude: ['input', 'linkTo'],
|
|
},
|
|
};
|
|
|
|
registerTemplate('myCollection', myCollectionTemplate);
|
|
|
|
export default React.memo((props) => {
|
|
return <>{props.children}</>;
|
|
});
|