mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix: missing fields (#4083)
* fix: missing fields * fix: typo * chore: add migration --------- Co-authored-by: xilesun <2013xile@gmail.com>
This commit is contained in:
parent
a3795c2ec3
commit
651af7d741
@ -97,5 +97,35 @@ export default defineCollection({
|
||||
name: 'systemSettings',
|
||||
defaultValue: {},
|
||||
},
|
||||
{
|
||||
uiSchema: {
|
||||
'x-component-props': {
|
||||
dateFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
type: 'datetime',
|
||||
title: '{{t("Created at")}}',
|
||||
'x-component': 'DatePicker',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
name: 'createdAt',
|
||||
type: 'date',
|
||||
field: 'createdAt',
|
||||
interface: 'createdAt',
|
||||
},
|
||||
{
|
||||
uiSchema: {
|
||||
'x-component-props': {
|
||||
dateFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
type: 'datetime',
|
||||
title: '{{t("Last updated at")}}',
|
||||
'x-component': 'DatePicker',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
name: 'updatedAt',
|
||||
type: 'date',
|
||||
field: 'updatedAt',
|
||||
interface: 'updatedAt',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -0,0 +1,116 @@
|
||||
import { Migration } from '@nocobase/server';
|
||||
|
||||
export default class extends Migration {
|
||||
on = 'afterLoad'; // 'beforeLoad' or 'afterLoad'
|
||||
appVersion = '<0.21.0-alpha.11';
|
||||
|
||||
async up() {
|
||||
const Field = this.context.db.getRepository('fields');
|
||||
const createdByField = await Field.findOne({
|
||||
filter: {
|
||||
name: 'createdBy',
|
||||
collectionName: 'users',
|
||||
interface: null,
|
||||
},
|
||||
});
|
||||
if (createdByField) {
|
||||
await createdByField.update({
|
||||
interface: 'createdBy',
|
||||
options: {
|
||||
...createdByField.options,
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("Created by")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
value: 'id',
|
||||
label: 'nickname',
|
||||
},
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
const updatedByField = await Field.findOne({
|
||||
filter: {
|
||||
name: 'updatedBy',
|
||||
collectionName: 'users',
|
||||
interface: null,
|
||||
},
|
||||
});
|
||||
if (updatedByField) {
|
||||
await updatedByField.update({
|
||||
interface: 'updatedBy',
|
||||
options: {
|
||||
...updatedByField.options,
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("Last updated by")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
value: 'id',
|
||||
label: 'nickname',
|
||||
},
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
const createdAtField = await Field.count({
|
||||
filter: {
|
||||
name: 'createdAt',
|
||||
collectionName: 'users',
|
||||
},
|
||||
});
|
||||
if (!createdAtField) {
|
||||
await Field.create({
|
||||
values: {
|
||||
collectionName: 'users',
|
||||
uiSchema: {
|
||||
'x-component-props': {
|
||||
dateFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
type: 'datetime',
|
||||
title: '{{t("Created at")}}',
|
||||
'x-component': 'DatePicker',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
name: 'createdAt',
|
||||
field: 'createdAt',
|
||||
type: 'date',
|
||||
interface: 'createdAt',
|
||||
},
|
||||
});
|
||||
}
|
||||
const updatedAtField = await Field.count({
|
||||
filter: {
|
||||
name: 'updatedAt',
|
||||
collectionName: 'users',
|
||||
},
|
||||
});
|
||||
if (!updatedAtField) {
|
||||
await Field.create({
|
||||
values: {
|
||||
collectionName: 'users',
|
||||
uiSchema: {
|
||||
'x-component-props': {
|
||||
dateFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
type: 'datetime',
|
||||
title: '{{t("Last updated at")}}',
|
||||
'x-component': 'DatePicker',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
name: 'updatedAt',
|
||||
field: 'updatedAt',
|
||||
type: 'date',
|
||||
interface: 'updatedAt',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@ import { Plugin } from '@nocobase/server';
|
||||
import { parse } from '@nocobase/utils';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import * as actions from './actions/users';
|
||||
import { Cache } from '@nocobase/cache';
|
||||
import * as actions from './actions/users';
|
||||
import { UserModel } from './models/UserModel';
|
||||
|
||||
export default class PluginUsersServer extends Plugin {
|
||||
@ -70,6 +70,19 @@ export default class PluginUsersServer extends Plugin {
|
||||
target: 'users',
|
||||
foreignKey: 'createdById',
|
||||
targetKey: 'id',
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("Created by")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
value: 'id',
|
||||
label: 'nickname',
|
||||
},
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
interface: 'createdBy',
|
||||
});
|
||||
}
|
||||
if (updatedBy === true) {
|
||||
@ -85,6 +98,19 @@ export default class PluginUsersServer extends Plugin {
|
||||
target: 'users',
|
||||
foreignKey: 'updatedById',
|
||||
targetKey: 'id',
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("Last updated by")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
value: 'id',
|
||||
label: 'nickname',
|
||||
},
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
interface: 'updatedBy',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user