From 880737c5c87249c9002b32daa6c8db4b8c89836f Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 11 Dec 2020 10:31:00 +0800 Subject: [PATCH] feat: add internal parameter to collection options --- .../plugin-collections/src/collections/actions.ts | 1 + .../src/collections/collections.ts | 12 ++++++++++++ .../plugin-collections/src/collections/fields.ts | 1 + packages/plugin-collections/src/collections/tabs.ts | 1 + packages/plugin-collections/src/collections/views.ts | 1 + packages/plugin-collections/src/interfaces/types.ts | 2 -- .../src/collections/attachments.ts | 1 + packages/plugin-pages/src/collections/pages.ts | 1 + packages/plugin-pages/src/server.ts | 6 +++--- packages/plugin-users/src/collections/users.ts | 5 +++-- 10 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/plugin-collections/src/collections/actions.ts b/packages/plugin-collections/src/collections/actions.ts index 537cb4f8c..cf25982fa 100644 --- a/packages/plugin-collections/src/collections/actions.ts +++ b/packages/plugin-collections/src/collections/actions.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'actions', title: '操作配置', + internal: true, draggable: true, model: 'ActionModel', developerMode: true, diff --git a/packages/plugin-collections/src/collections/collections.ts b/packages/plugin-collections/src/collections/collections.ts index a2dc69289..07ffb72a6 100644 --- a/packages/plugin-collections/src/collections/collections.ts +++ b/packages/plugin-collections/src/collections/collections.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'collections', title: '数据表配置', + internal: true, sortable: true, draggable: true, model: 'CollectionModel', @@ -160,6 +161,17 @@ export default { type: 'hidden', }, }, + { + interface: 'boolean', + type: 'boolean', + name: 'internal', + title: '系统内置', + defaultValue: false, + developerMode: true, + component: { + type: 'boolean', + }, + }, { interface: 'linkTo', type: 'hasMany', diff --git a/packages/plugin-collections/src/collections/fields.ts b/packages/plugin-collections/src/collections/fields.ts index 3612d7ee7..1956aed39 100644 --- a/packages/plugin-collections/src/collections/fields.ts +++ b/packages/plugin-collections/src/collections/fields.ts @@ -4,6 +4,7 @@ import { options } from '../interfaces'; export default { name: 'fields', title: '字段配置', + internal: true, draggable: true, model: 'FieldModel', developerMode: true, diff --git a/packages/plugin-collections/src/collections/tabs.ts b/packages/plugin-collections/src/collections/tabs.ts index 62b13e5c9..d57daaa44 100644 --- a/packages/plugin-collections/src/collections/tabs.ts +++ b/packages/plugin-collections/src/collections/tabs.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'tabs', title: '标签配置', + internal: true, sortable: true, model: 'TabModel', developerMode: true, diff --git a/packages/plugin-collections/src/collections/views.ts b/packages/plugin-collections/src/collections/views.ts index 1843cde7b..8e9854366 100644 --- a/packages/plugin-collections/src/collections/views.ts +++ b/packages/plugin-collections/src/collections/views.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'views', title: '视图配置', + internal: true, sortable: true, model: 'ViewModel', developerMode: true, diff --git a/packages/plugin-collections/src/interfaces/types.ts b/packages/plugin-collections/src/interfaces/types.ts index c34d83304..c3d8b2a4c 100644 --- a/packages/plugin-collections/src/interfaces/types.ts +++ b/packages/plugin-collections/src/interfaces/types.ts @@ -440,7 +440,6 @@ export const sort = { interface: 'sort', type: 'integer', required: true, - developerMode: true, component: { type: 'sort', showInTable: true, @@ -453,7 +452,6 @@ export const password = { options: { interface: 'password', type: 'password', - developerMode: true, hidden: true, // hidden 用来控制 api 不输出这个字段,但是可能这个字段显示在表单里 showInForm component: { type: 'password', diff --git a/packages/plugin-file-manager/src/collections/attachments.ts b/packages/plugin-file-manager/src/collections/attachments.ts index 90b44ba36..4ece3afcf 100644 --- a/packages/plugin-file-manager/src/collections/attachments.ts +++ b/packages/plugin-file-manager/src/collections/attachments.ts @@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database'; export default { name: 'attachments', title: '文件管理器', + internal: true, fields: [ { type: 'string', diff --git a/packages/plugin-pages/src/collections/pages.ts b/packages/plugin-pages/src/collections/pages.ts index 01878f0ed..a760c0f74 100644 --- a/packages/plugin-pages/src/collections/pages.ts +++ b/packages/plugin-pages/src/collections/pages.ts @@ -4,6 +4,7 @@ export default { name: 'pages', title: '页面配置', model: 'BaseModel', + internal: true, developerMode: true, fields: [ { diff --git a/packages/plugin-pages/src/server.ts b/packages/plugin-pages/src/server.ts index ccbf8cb85..6d412fe09 100644 --- a/packages/plugin-pages/src/server.ts +++ b/packages/plugin-pages/src/server.ts @@ -22,9 +22,9 @@ export default async function (options = {}) { const [Collection, Page] = database.getModels(['collections', 'pages']); async function createCollectionPage(model) { - // if (!model.get('showInDataMenu')) { - // return; - // } + if (model.get('internal')) { + return; + } const parent = await Page.findOne({ where: { path: '/collections', diff --git a/packages/plugin-users/src/collections/users.ts b/packages/plugin-users/src/collections/users.ts index 18d4bfca9..904bce84c 100644 --- a/packages/plugin-users/src/collections/users.ts +++ b/packages/plugin-users/src/collections/users.ts @@ -4,6 +4,7 @@ export default { name: 'users', title: '用户', developerMode: true, + internal: true, fields: [ { interface: 'string', @@ -55,14 +56,14 @@ export default { }, }, { - interface: 'password', + interface: 'string', type: 'string', name: 'token', title: 'Token', unique: true, hidden: true, component: { - type: 'hidden', + type: 'string', }, }, ],