mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-01 11:47:51 +08:00
fix: add createdAt/updatedAt/createdBy/updatedBy options to the collections table for developer mode
This commit is contained in:
parent
afce1142d9
commit
7e9b4a8f45
@ -3,8 +3,8 @@ import { TableOptions } from '@nocobase/database';
|
||||
export default {
|
||||
title: '示例',
|
||||
showInDataMenu: true,
|
||||
createdBy: true,
|
||||
updatedBy: true,
|
||||
// createdBy: true,
|
||||
// updatedBy: true,
|
||||
fields: [
|
||||
{
|
||||
interface: 'string',
|
||||
|
@ -8,6 +8,8 @@ export default {
|
||||
draggable: true,
|
||||
model: 'CollectionModel',
|
||||
developerMode: true,
|
||||
createdAt: 'createdTime',
|
||||
updatedAt: 'updatedTime',
|
||||
fields: [
|
||||
{
|
||||
interface: 'sort',
|
||||
@ -143,11 +145,62 @@ export default {
|
||||
showInDetail: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'virtual',
|
||||
name: 'createdAt',
|
||||
title: '记录创建时间',
|
||||
developerMode: true,
|
||||
defaultValue: true,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
default: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'virtual',
|
||||
name: 'updatedAt',
|
||||
title: '记录修改时间',
|
||||
developerMode: true,
|
||||
defaultValue: true,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
default: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'virtual',
|
||||
name: 'createdBy',
|
||||
title: '记录创建人信息',
|
||||
developerMode: true,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
default: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'virtual',
|
||||
name: 'updatedBy',
|
||||
title: '记录修改人信息',
|
||||
developerMode: true,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
default: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'boolean',
|
||||
name: 'developerMode',
|
||||
title: '开发者模式',
|
||||
developerMode: true,
|
||||
defaultValue: false,
|
||||
component: {
|
||||
type: 'boolean',
|
||||
|
@ -10,6 +10,7 @@ export default {
|
||||
collections: {
|
||||
beforeValidate: collectionsBeforeValidate,
|
||||
afterCreate: collectionsAfterCreate,
|
||||
afterUpdate: collectionsAfterCreate,
|
||||
},
|
||||
fields: {
|
||||
beforeValidate: fieldsBeforeValidate,
|
||||
|
@ -22,7 +22,16 @@ export default async function (options = {}) {
|
||||
});
|
||||
|
||||
database.addHook('afterTableInit', (table) => {
|
||||
const { createdBy, updatedBy } = table.getOptions();
|
||||
let { createdBy, updatedBy, internal } = table.getOptions();
|
||||
// 非内置表,默认创建 createdBy 和 updatedBy
|
||||
if (!internal) {
|
||||
if (typeof createdBy === 'undefined') {
|
||||
createdBy = true;
|
||||
}
|
||||
if (typeof updatedBy === 'undefined') {
|
||||
updatedBy = true;
|
||||
}
|
||||
}
|
||||
const fieldsToMake = { createdBy, updatedBy };
|
||||
Object.keys(fieldsToMake)
|
||||
.filter(type => Boolean(fieldsToMake[type]))
|
||||
|
Loading…
Reference in New Issue
Block a user