diff --git a/packages/core/client/src/collection-manager/templates/general.tsx b/packages/core/client/src/collection-manager/templates/general.tsx index 805028460..ed60bc7d8 100644 --- a/packages/core/client/src/collection-manager/templates/general.tsx +++ b/packages/core/client/src/collection-manager/templates/general.tsx @@ -9,15 +9,5 @@ export const general: ICollectionTemplate = { default: { fields: [], }, - configurableProperties: getConfigurableProperties( - 'title', - 'name', - 'inherits', - 'autoGenId', - 'createdAt', - 'updatedAt', - 'createdBy', - 'updatedBy', - 'sortable', - ), + configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'moreOptions'), }; diff --git a/packages/core/client/src/collection-manager/templates/properties/index.ts b/packages/core/client/src/collection-manager/templates/properties/index.ts index 81b838a7d..22af1eb5f 100644 --- a/packages/core/client/src/collection-manager/templates/properties/index.ts +++ b/packages/core/client/src/collection-manager/templates/properties/index.ts @@ -1,3 +1,75 @@ +import { css } from '@emotion/css'; + +const moreOptions = { + autoGenId: { + type: 'boolean', + 'x-content': '{{t("Generate ID field automatically")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + 'x-reactions': [ + { + target: 'sortable', + when: '{{createOnly&&!$self.value}}', + fulfill: { + state: { + value: false, + }, + schema: { + 'x-disabled': true, + }, + }, + otherwise: { + schema: { + 'x-disabled': '{{!createOnly}}', + }, + }, + }, + ], + }, + createdBy: { + type: 'boolean', + 'x-content': '{{t("Store the creation user of each record")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + }, + updatedBy: { + type: 'boolean', + 'x-content': '{{t("Store the last update user of each record")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + }, + createdAt: { + type: 'boolean', + 'x-content': '{{t("Store the creation time of each record")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + }, + updatedAt: { + type: 'boolean', + 'x-content': '{{t("Store the last update time of each record")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + }, + sortable: { + type: 'boolean', + 'x-content': '{{t("Records can be sorted")}}', + default: true, + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + 'x-disabled': '{{ !createOnly }}', + }, +}; + export const defaultConfigurableProperties = { title: { type: 'string', @@ -30,72 +102,21 @@ export const defaultConfigurableProperties = { 'x-visible': '{{ enableInherits}}', 'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'], }, - autoGenId: { - type: 'boolean', - 'x-content': '{{t("AutoGenId")}}', - default: true, + ...moreOptions, + moreOptions: { + title: '{{t("More options")}}', + type: 'void', 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', - 'x-reactions': [ - { - target: 'sortable', - when: '{{createOnly&&!$self.value}}', - fulfill: { - state: { - value: false, - }, - schema: { - 'x-disabled': true, - }, - }, - otherwise: { - schema: { - 'x-disabled': '{{!createOnly}}', - }, - }, - }, - ], - }, - createdBy: { - type: 'boolean', - 'x-content': '{{t("CreatedBy")}}', - default: true, - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', - }, - updatedBy: { - type: 'boolean', - 'x-content': '{{t("UpdatedBy")}}', - default: true, - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', - }, - createdAt: { - type: 'boolean', - 'x-content': '{{t("CreatedAt")}}', - default: true, - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', - }, - updatedAt: { - type: 'boolean', - 'x-content': '{{t("UpdatedAt")}}', - default: true, - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', - }, - sortable: { - type: 'boolean', - 'x-content': '{{t("Records can be sorted")}}', - default: true, - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox', - 'x-disabled': '{{ !createOnly }}', + 'x-decorator-props': { + className: css` + .ant-formily-item { + margin-bottom: 0; + } + `, + }, + properties: { + ...moreOptions, + }, }, }; @@ -108,7 +129,8 @@ export type DefaultConfigurableKeys = | 'updatedBy' | 'createdAt' | 'updatedAt' - | 'sortable'; + | 'sortable' + | 'moreOptions'; export const getConfigurableProperties = (...keys: DefaultConfigurableKeys[]) => { const props = {}; diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index 836179f5a..e3c2ede1b 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -118,11 +118,12 @@ export default { "Collection display name": "数据表名称", "Collection name": "数据表标识", "Inherits":"继承", - "AutoGenId":"自动生成 ID 字段", - "CreatedBy":"记录创建人", - "UpdatedBy":"记录最后更新人", - "CreatedAt":"记录创建时间", - "UpdatedAt":"记录最后更新时间", + "Generate ID field automatically":"自动生成 ID 字段", + "Store the creation user of each record":"记录创建人", + "Store the last update user of each record":"记录最后更新人", + "Store the creation time of each record":"记录创建时间", + "Store the last update time of each record":"记录最后更新时间", + "More options": "更多选项", "Records can be sorted":"可以对行记录进行排序", "Collection template":"数据表模板", "Calendar collection":"日历数据表",