enhance: ロールの並び順を設定可能に
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export class roleDisplayOrder1678602320354 {
|
||||
name = 'roleDisplayOrder1678602320354'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "role" ADD "displayOrder" integer NOT NULL DEFAULT '0'`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "role" DROP COLUMN "displayOrder"`);
|
||||
}
|
||||
}
|
@@ -61,6 +61,7 @@ export class RoleEntityService {
|
||||
isModerator: role.isModerator,
|
||||
asBadge: role.asBadge,
|
||||
canEditMembersByModerator: role.canEditMembersByModerator,
|
||||
displayOrder: role.displayOrder,
|
||||
policies: policies,
|
||||
usersCount: assignedCount,
|
||||
});
|
||||
|
@@ -390,9 +390,10 @@ export class UserEntityService implements OnModuleInit {
|
||||
emojis: this.customEmojiService.populateEmojis(user.emojis, user.host),
|
||||
onlineStatus: this.getOnlineStatus(user),
|
||||
// パフォーマンス上の理由でローカルユーザーのみ
|
||||
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.map(r => ({
|
||||
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.sort((a, b) => b.displayOrder - a.displayOrder).map(r => ({
|
||||
name: r.name,
|
||||
iconUrl: r.iconUrl,
|
||||
displayOrder: r.displayOrder,
|
||||
}))) : undefined,
|
||||
|
||||
...(opts.detail ? {
|
||||
@@ -429,7 +430,7 @@ export class UserEntityService implements OnModuleInit {
|
||||
userId: user.id,
|
||||
}).then(result => result >= 1)
|
||||
: false,
|
||||
roles: this.roleService.getUserRoles(user.id).then(roles => roles.filter(role => role.isPublic).map(role => ({
|
||||
roles: this.roleService.getUserRoles(user.id).then(roles => roles.filter(role => role.isPublic).sort((a, b) => b.displayOrder - a.displayOrder).map(role => ({
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
color: role.color,
|
||||
@@ -437,6 +438,7 @@ export class UserEntityService implements OnModuleInit {
|
||||
description: role.description,
|
||||
isModerator: role.isModerator,
|
||||
isAdministrator: role.isAdministrator,
|
||||
displayOrder: role.displayOrder,
|
||||
}))),
|
||||
} : {}),
|
||||
|
||||
|
@@ -144,6 +144,12 @@ export class Role {
|
||||
})
|
||||
public canEditMembersByModerator: boolean;
|
||||
|
||||
// UIに表示する際の並び順用(大きいほど先頭)
|
||||
@Column('integer', {
|
||||
default: 0,
|
||||
})
|
||||
public displayOrder: number;
|
||||
|
||||
@Column('jsonb', {
|
||||
default: { },
|
||||
})
|
||||
|
@@ -27,6 +27,7 @@ export const paramDef = {
|
||||
isAdministrator: { type: 'boolean' },
|
||||
asBadge: { type: 'boolean' },
|
||||
canEditMembersByModerator: { type: 'boolean' },
|
||||
displayOrder: { type: 'number' },
|
||||
policies: {
|
||||
type: 'object',
|
||||
},
|
||||
@@ -43,6 +44,7 @@ export const paramDef = {
|
||||
'isAdministrator',
|
||||
'asBadge',
|
||||
'canEditMembersByModerator',
|
||||
'displayOrder',
|
||||
'policies',
|
||||
],
|
||||
} as const;
|
||||
@@ -76,6 +78,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
isModerator: ps.isModerator,
|
||||
asBadge: ps.asBadge,
|
||||
canEditMembersByModerator: ps.canEditMembersByModerator,
|
||||
displayOrder: ps.displayOrder,
|
||||
policies: ps.policies,
|
||||
}).then(x => this.rolesRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
|
@@ -35,6 +35,7 @@ export const paramDef = {
|
||||
isAdministrator: { type: 'boolean' },
|
||||
asBadge: { type: 'boolean' },
|
||||
canEditMembersByModerator: { type: 'boolean' },
|
||||
displayOrder: { type: 'number' },
|
||||
policies: {
|
||||
type: 'object',
|
||||
},
|
||||
@@ -52,6 +53,7 @@ export const paramDef = {
|
||||
'isAdministrator',
|
||||
'asBadge',
|
||||
'canEditMembersByModerator',
|
||||
'displayOrder',
|
||||
'policies',
|
||||
],
|
||||
} as const;
|
||||
@@ -85,6 +87,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
isAdministrator: ps.isAdministrator,
|
||||
asBadge: ps.asBadge,
|
||||
canEditMembersByModerator: ps.canEditMembersByModerator,
|
||||
displayOrder: ps.displayOrder,
|
||||
policies: ps.policies,
|
||||
});
|
||||
const updated = await this.rolesRepository.findOneByOrFail({ id: ps.roleId });
|
||||
|
Reference in New Issue
Block a user