mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08: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',
|
name: 'systemSettings',
|
||||||
defaultValue: {},
|
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 { parse } from '@nocobase/utils';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
|
||||||
import * as actions from './actions/users';
|
|
||||||
import { Cache } from '@nocobase/cache';
|
import { Cache } from '@nocobase/cache';
|
||||||
|
import * as actions from './actions/users';
|
||||||
import { UserModel } from './models/UserModel';
|
import { UserModel } from './models/UserModel';
|
||||||
|
|
||||||
export default class PluginUsersServer extends Plugin {
|
export default class PluginUsersServer extends Plugin {
|
||||||
@ -70,6 +70,19 @@ export default class PluginUsersServer extends Plugin {
|
|||||||
target: 'users',
|
target: 'users',
|
||||||
foreignKey: 'createdById',
|
foreignKey: 'createdById',
|
||||||
targetKey: 'id',
|
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) {
|
if (updatedBy === true) {
|
||||||
@ -85,6 +98,19 @@ export default class PluginUsersServer extends Plugin {
|
|||||||
target: 'users',
|
target: 'users',
|
||||||
foreignKey: 'updatedById',
|
foreignKey: 'updatedById',
|
||||||
targetKey: 'id',
|
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…
x
Reference in New Issue
Block a user