katherinehhh d668aa0d92
feat: configurable the scope of target collections (#1165)
* feat: collection template support availableTargetCollections

* feat: add targetScope

* feat: code opmization

* feat: custom-collection-template improve

* feat: useAsyncDataSource fix

* feat: useAsyncDataSource fix
2022-12-01 14:24:35 +08:00

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}</>;
});