モデレーター登録を解除できるように (#3876)

This commit is contained in:
MeiMei 2019-01-11 08:11:24 +09:00 committed by syuilo
parent dd77a6194e
commit 1546160f6a
2 changed files with 29 additions and 4 deletions

View file

@ -1276,6 +1276,8 @@ admin/views/moderators.vue:
title: "モデレーターの登録"
add: "登録"
added: "モデレーターを登録しました"
remove: "解除"
removed: "モデレーター登録を解除しました"
admin/views/emoji.vue:
add-emoji:

View file

@ -6,7 +6,8 @@
<ui-input v-model="username" type="text">
<span slot="prefix">@</span>
</ui-input>
<ui-button @click="add" :disabled="adding">{{ $t('add-moderator.add') }}</ui-button>
<ui-button @click="add" :disabled="changing">{{ $t('add-moderator.add') }}</ui-button>
<ui-button @click="remove" :disabled="changing">{{ $t('add-moderator.remove') }}</ui-button>
</section>
</ui-card>
</div>
@ -23,13 +24,13 @@ export default Vue.extend({
data() {
return {
username: '',
adding: false
changing: false
};
},
methods: {
async add() {
this.adding = true;
this.changing = true;
const process = async () => {
const user = await this.$root.api('users/show', parseAcct(this.username));
@ -47,7 +48,29 @@ export default Vue.extend({
});
});
this.adding = false;
this.changing = false;
},
async remove() {
this.changing = true;
const process = async () => {
const user = await this.$root.api('users/show', parseAcct(this.username));
await this.$root.api('admin/moderators/remove', { userId: user.id });
this.$root.dialog({
type: 'success',
text: this.$t('add-moderator.removed')
});
};
await process().catch(e => {
this.$root.dialog({
type: 'error',
text: e.toString()
});
});
this.changing = false;
},
}
});