feat(collection-manager): more options

This commit is contained in:
chenos 2022-12-14 16:38:08 +08:00
parent db346688f5
commit 26e27c814b
3 changed files with 95 additions and 82 deletions

View File

@ -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'),
};

View File

@ -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 = {};

View File

@ -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":"日历数据表",