feat: create system fields by default
This commit is contained in:
parent
e002777b63
commit
28da6a5f82
@ -20,9 +20,9 @@ const getSchema = (schema: IField): ISchema => {
|
|||||||
}
|
}
|
||||||
const properties = cloneDeep(schema.properties) as any;
|
const properties = cloneDeep(schema.properties) as any;
|
||||||
const initialValue = {
|
const initialValue = {
|
||||||
|
name: `f_${uid()}`,
|
||||||
...cloneDeep(schema.default),
|
...cloneDeep(schema.default),
|
||||||
interface: schema.name,
|
interface: schema.name,
|
||||||
name: `f_${uid()}`,
|
|
||||||
};
|
};
|
||||||
initialValue.uiSchema.title = schema.title;
|
initialValue.uiSchema.title = schema.title;
|
||||||
return {
|
return {
|
||||||
|
@ -19,9 +19,9 @@ const getSchema = (schema: IField): ISchema => {
|
|||||||
}
|
}
|
||||||
const properties = cloneDeep(schema.properties) as any;
|
const properties = cloneDeep(schema.properties) as any;
|
||||||
const initialValue = {
|
const initialValue = {
|
||||||
|
name: `f_${uid()}`,
|
||||||
...cloneDeep(schema.default),
|
...cloneDeep(schema.default),
|
||||||
interface: schema.name,
|
interface: schema.name,
|
||||||
name: `f_${uid()}`,
|
|
||||||
};
|
};
|
||||||
initialValue.uiSchema.title = schema.title;
|
initialValue.uiSchema.title = schema.title;
|
||||||
console.log('initialValue', initialValue);
|
console.log('initialValue', initialValue);
|
||||||
|
@ -30,6 +30,81 @@ const useCollectionValues = (options) => {
|
|||||||
createdBy: true,
|
createdBy: true,
|
||||||
updatedBy: true,
|
updatedBy: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
allowNull: false,
|
||||||
|
uiSchema: { type: 'number', title: '{{t("ID")}}', 'x-component': 'InputNumber', 'x-read-pretty': true },
|
||||||
|
interface: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
interface: 'createdAt',
|
||||||
|
type: 'date',
|
||||||
|
field: 'createdAt',
|
||||||
|
name: 'createdAt',
|
||||||
|
uiSchema: {
|
||||||
|
type: 'datetime',
|
||||||
|
title: '{{t("Created at")}}',
|
||||||
|
'x-component': 'DatePicker',
|
||||||
|
'x-component-props': {},
|
||||||
|
'x-read-pretty': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
interface: 'createdBy',
|
||||||
|
type: 'belongsTo',
|
||||||
|
target: 'users',
|
||||||
|
foreignKey: 'createdById',
|
||||||
|
name: 'createdBy',
|
||||||
|
uiSchema: {
|
||||||
|
type: 'object',
|
||||||
|
title: '{{t("Created by")}}',
|
||||||
|
'x-component': 'RecordPicker',
|
||||||
|
'x-component-props': {
|
||||||
|
fieldNames: {
|
||||||
|
value: 'id',
|
||||||
|
label: 'nickname',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-read-pretty': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'date',
|
||||||
|
field: 'updatedAt',
|
||||||
|
name: 'updatedAt',
|
||||||
|
interface: 'updatedAt',
|
||||||
|
uiSchema: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Last updated at")}}',
|
||||||
|
'x-component': 'DatePicker',
|
||||||
|
'x-component-props': {},
|
||||||
|
'x-read-pretty': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'belongsTo',
|
||||||
|
target: 'users',
|
||||||
|
foreignKey: 'updatedById',
|
||||||
|
name: 'updatedBy',
|
||||||
|
interface: 'updatedBy',
|
||||||
|
uiSchema: {
|
||||||
|
type: 'object',
|
||||||
|
title: '{{t("Last updated by")}}',
|
||||||
|
'x-component': 'RecordPicker',
|
||||||
|
'x-component-props': {
|
||||||
|
fieldNames: {
|
||||||
|
value: 'id',
|
||||||
|
label: 'nickname',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-read-pretty': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
47
packages/client/src/collection-manager/interfaces/id.ts
Normal file
47
packages/client/src/collection-manager/interfaces/id.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { operators } from './properties';
|
||||||
|
import { IField } from './types';
|
||||||
|
|
||||||
|
export const id: IField = {
|
||||||
|
name: 'id',
|
||||||
|
type: 'object',
|
||||||
|
group: 'systemInfo',
|
||||||
|
order: 0,
|
||||||
|
title: '{{t("ID")}}',
|
||||||
|
sortable: true,
|
||||||
|
default: {
|
||||||
|
name: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
allowNull: false,
|
||||||
|
uiSchema: {
|
||||||
|
type: 'number',
|
||||||
|
title: '{{t("ID")}}',
|
||||||
|
'x-component': 'InputNumber',
|
||||||
|
'x-read-pretty': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
'uiSchema.title': {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Field display name")}}',
|
||||||
|
required: true,
|
||||||
|
default: 'ID',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input',
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: 'string',
|
||||||
|
title: '{{t("Field name")}}',
|
||||||
|
required: true,
|
||||||
|
'x-disabled': true,
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'Input',
|
||||||
|
description:
|
||||||
|
"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filterable: {
|
||||||
|
operators: operators.number,
|
||||||
|
},
|
||||||
|
};
|
@ -7,6 +7,7 @@ export * from './createdBy';
|
|||||||
export * from './datetime';
|
export * from './datetime';
|
||||||
export * from './email';
|
export * from './email';
|
||||||
export * from './icon';
|
export * from './icon';
|
||||||
|
export * from './id';
|
||||||
export * from './input';
|
export * from './input';
|
||||||
export * from './linkTo';
|
export * from './linkTo';
|
||||||
export * from './markdown';
|
export * from './markdown';
|
||||||
|
Loading…
Reference in New Issue
Block a user