CollectionFieldInterfaceManager

主要是用来管理 CollectionFieldInterfaceCollectionFieldInterfaceGroups,其被 DataSourceManager 管理。

1. CollectionFieldInterfaceGroups

CollectionFieldInterfaceGroups 是用来对数据表字段进行分组的。

2. 实例方法

field interface

addFieldInterfaces()

添加 field interface。

  • 类型
1class CollectionFieldInterfaceManager {
2  addFieldInterfaces(fieldInterfaces: CollectionFieldInterface[]): void
3}
  • 示例
1class CheckboxFieldInterface extends CollectionFieldInterface {
2  name = 'checkbox';
3  type = 'object';
4  group = 'choices';
5  title = '{{t("Checkbox")}}';
6  // ...
7}
8
9class MyPlugin extends Plugin {
10  async load() {
11    this.app.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaces([CheckboxFieldInterface]);
12    // or
13    this.app.dataSourceManager.addFieldInterfaces([CheckboxFieldInterface]);
14  }
15}

getFieldInterface(name)

获取 field interface。

  • 类型
1class CollectionFieldInterfaceManager {
2  getFieldInterface<T extends CollectionFieldInterface>(name: string): T;
3}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    const fieldInterface = this.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface('checkbox'); // checkboxFieldInterface
4  }
5}

getFieldInterfaces()

获取所有的 field interface。

  • 类型
1class CollectionFieldInterfaceManager {
2  getFieldInterfaces(): CollectionFieldInterface[];
3}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    const fieldInterfaces = this.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterfaces();
4  }
5}

添加 Field interface 组件选项。

  • 类型
1interface CollectionFieldInterfaceComponentOption {
2  label: string;
3  value: string;
4  useVisible?: () => boolean;
5  useProps?: () => any;
6}
7
8class CollectionFieldInterfaceManager {
9  addFieldInterfaceComponentOption(interfaceName: string, componentOption: CollectionFieldInterfaceComponentOption): void
10}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    this.app.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceComponentOption('url', {
4      label: 'Preview',
5      value: 'Input.Preview',
6    });
7  }
8}

field interface group

addFieldInterfaceGroups(fieldGroups)

添加 field interface group。

  • 类型
1class CollectionFieldInterfaceManager {
2  addFieldInterfaceGroups(fieldGroups: Record<string, { label: string; order?: number }>): void;
3}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    this.app.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceGroups({
4      'test': {
5        label: 'Test',
6        order: 1,
7      }
8    });
9
10    // or
11    this.app.dataSourceManager.addFieldInterfaceGroups({
12      'test': {
13        label: 'Test',
14        order: 1,
15      }
16    });
17  }
18}

getFieldInterfaceGroups()

获取所有的 field interface group。

  • 类型
1class CollectionFieldInterfaceManager {
2  getFieldInterfaceGroups(): Record<string, { label: string; order?: number }>;
3}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    const fieldInterfaceGroups = this.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterfaceGroups(); // { 'test': { label: 'Test', order: 1 } }
4  }
5}

getFieldInterfaceGroup(name)

获取 field interface group。

  • 类型
1class CollectionFieldInterfaceManager {
2  getFieldInterfaceGroup(name: string): { label: string; order?: number };
3}
  • 示例
1class MyPlugin extends Plugin {
2  async load() {
3    const fieldInterfaceGroup = this.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterfaceGroup('test'); // { label: 'Test', order: 1 }
4  }
5}