nocobase/docs/zh-CN/welcome/release/collection-templates.md

80 lines
1.7 KiB
Markdown
Raw Normal View History

2023-01-11 04:30:13 +00:00
# v0.9.0: Collection 模板
Feat/collection templates (#1124) * feat: add collection templates * feat: collection templates * feat: collection templates * feat: collection templates * feat: collection templates * feat: collection templates * feat: calendar collection template * feat: no id does not support sorting * feat: collection template edit * feat: collectiom templates code improve * feat: collection template supports configurable field interface * feat: collection template supports configurable field interface * feat: establish relation field when there is no id * feat: collection templates * feat: collection templates locale * feat: calendar collection * feat: calendar collection default fields * feat: code optimization * feat: code optimization * feat: code optimization * feat: collectin template fix * feat: add sample-custom-collection-template * feat: code optimization * feat: code optimization * feat: code optimization * feat: code optimization * feat: import code * feat: collection template local * feat: code opimization * feat: code opimization * feat: code opimization * feat: code opimization * feat: code opimization * feat: collection template local * feat: collection template local * fix(collection-manager): exclude reverse parameters when overriding * feat: update docs * feat: disabled * feat: improve code * feat: update submodule * feat: submodules: true * fix: token * fix: with ssh-key * fix: update dockerfile * fix: ci * fix: ci * fix: ci * fix: ci * fix: --no-verify-access * fix: ci * fix: ci * fix: ci * fix: missing env * fix: env Co-authored-by: chenos <chenlinxh@gmail.com> Co-authored-by: chareice <chareice@live.com>
2022-11-29 03:31:30 +00:00
<img src="./v08-1-collection-templates/v08-1-collection-templates.jpg">
## 为什么需要 Collection 模板?
待补充
## 配置参数说明
```ts
interface ICollectionTemplate {
name: string;
title?: string;
/** 排序 */
order?: number;
/** 默认配置 */
default?: CollectionOptions;
/** UI 可配置的 CollectionOptions 参数(添加或编辑的 Collection 表单的字段) */
configurableProperties?: Record<string, ISchema>;
/** 当前模板可用的字段类型 */
availableFieldInterfaces?: AvailableFieldInterfacesInclude | AvailableFieldInterfacesExclude;
}
interface AvailableFieldInterfacesInclude {
include?: any[];
}
interface AvailableFieldInterfacesExclude {
exclude?: any[];
}
interface CollectionOptions {
/**
* 自动生成 id
* @default true
* */
autoGenId?: boolean;
/** 创建人 */
createdBy?: boolean;
/** 最后更新人 */
updatedBy?: boolean;
/** 创建日期 */
createdAt?: boolean;
/** 更新日期 */
updatedAt?: boolean;
/** 可排序 */
sortable?: boolean;
/* 树结构 */
tree?: string;
/* 日志 */
logging?: boolean;
/** 继承 */
inherits: string | string[];
/* 字段列表 */
fields?: FieldOptions[];
}
```
## 示例
创建时都不需要 autoGenId并且只提供 title 和 name 配置项
```ts
import { collectionConfigurableProperties } from '@nocobase/client';
{
default: {
autoGenId: false,
fields: [],
},
configurableProperties: {
...collectionConfigurableProperties('name', 'title'),
},
}
```
完整插件示例参考:[samples/custom-collection-template](https://github.com/nocobase/nocobase/tree/feat/collection-templates/packages/samples/custom-collection-template)