Add moderator switch

This commit is contained in:
syuilo 2020-01-30 06:00:43 +09:00
parent cb615f633c
commit d8cc5eeecb

View file

@ -3,6 +3,7 @@
<template #header><mk-user-name :user="user"/></template> <template #header><mk-user-name :user="user"/></template>
<div class="vrcsvlkm"> <div class="vrcsvlkm">
<mk-button @click="changePassword()">{{ $t('changePassword') }}</mk-button> <mk-button @click="changePassword()">{{ $t('changePassword') }}</mk-button>
<mk-switch v-if="$store.state.i.isAdmin" @change="toggleModerator()" v-model="moderator">{{ $t('moderator') }}</mk-switch>
<mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch> <mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch>
<mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch> <mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch>
</div> </div>
@ -34,6 +35,7 @@ export default Vue.extend({
data() { data() {
return { return {
moderator: this.user.isModerator,
silenced: this.user.isSilenced, silenced: this.user.isSilenced,
suspended: this.user.isSuspended, suspended: this.user.isSuspended,
}; };
@ -94,8 +96,12 @@ export default Vue.extend({
if (confirm.canceled) { if (confirm.canceled) {
this.suspended = !this.suspended; this.suspended = !this.suspended;
} else { } else {
this.$root.api(this.silenced ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: this.user.id }); this.$root.api(this.suspended ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: this.user.id });
} }
},
async toggleModerator() {
this.$root.api(this.moderator ? 'admin/moderators/add' : 'admin/moderators/remove', { userId: this.user.id });
} }
} }
}); });