2018-12-19 07:22:01 +09:00
|
|
|
<template>
|
2019-05-18 20:36:33 +09:00
|
|
|
<div class="ivrbakop">
|
|
|
|
<ui-container v-if="group">
|
|
|
|
<template #header><fa :icon="faUsers"/> {{ group.name }}</template>
|
2018-12-19 07:22:01 +09:00
|
|
|
|
|
|
|
<section>
|
2019-05-18 20:36:33 +09:00
|
|
|
<ui-margin>
|
|
|
|
<ui-button @click="rename"><fa :icon="faICursor"/> {{ $t('rename') }}</ui-button>
|
|
|
|
<ui-button @click="del"><fa :icon="faTrashAlt"/> {{ $t('delete') }}</ui-button>
|
2019-05-22 05:06:52 +09:00
|
|
|
<ui-button @click="transfer"><fa :icon="faCrown"/> {{ $t('transfer') }}</ui-button>
|
2019-05-18 20:36:33 +09:00
|
|
|
</ui-margin>
|
2018-12-19 07:22:01 +09:00
|
|
|
</section>
|
2019-05-18 20:36:33 +09:00
|
|
|
</ui-container>
|
2018-12-19 07:22:01 +09:00
|
|
|
|
2019-05-18 20:36:33 +09:00
|
|
|
<ui-container>
|
|
|
|
<template #header><fa :icon="faUsers"/> {{ $t('users') }}</template>
|
2018-12-19 07:22:01 +09:00
|
|
|
|
|
|
|
<section>
|
2019-05-18 20:36:33 +09:00
|
|
|
<ui-margin>
|
2019-05-19 20:41:23 +09:00
|
|
|
<ui-button @click="invite()"><fa :icon="faPlus"/> {{ $t('invite') }}</ui-button>
|
2019-05-18 20:36:33 +09:00
|
|
|
</ui-margin>
|
2018-12-19 07:22:01 +09:00
|
|
|
<sequential-entrance animation="entranceFromTop" delay="25">
|
2019-05-18 20:36:33 +09:00
|
|
|
<div class="kjlrfbes" v-for="user in users">
|
2018-12-19 07:22:01 +09:00
|
|
|
<div>
|
|
|
|
<a :href="user | userPage">
|
|
|
|
<mk-avatar class="avatar" :user="user" :disable-link="true"/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<header>
|
|
|
|
<b><mk-user-name :user="user"/></b>
|
2019-05-22 14:27:10 +09:00
|
|
|
<span class="is-owner" v-if="group.ownerId === user.id">owner</span>
|
2018-12-19 07:22:01 +09:00
|
|
|
<span class="username">@{{ user | acct }}</span>
|
|
|
|
</header>
|
2019-05-22 14:27:10 +09:00
|
|
|
<div v-if="group.ownerId !== user.id">
|
2018-12-19 07:22:01 +09:00
|
|
|
<a @click="remove(user)">{{ $t('remove-user') }}</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</sequential-entrance>
|
|
|
|
</section>
|
2019-05-18 20:36:33 +09:00
|
|
|
</ui-container>
|
2018-12-19 07:22:01 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../../i18n';
|
2019-05-22 05:06:52 +09:00
|
|
|
import { faCrown, faICursor, faUsers, faPlus } from '@fortawesome/free-solid-svg-icons';
|
2018-12-19 07:22:01 +09:00
|
|
|
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2019-05-18 20:36:33 +09:00
|
|
|
i18n: i18n('common/views/components/user-group-editor.vue'),
|
2018-12-19 07:22:01 +09:00
|
|
|
|
|
|
|
props: {
|
2019-05-18 20:36:33 +09:00
|
|
|
groupId: {
|
2018-12-19 07:22:01 +09:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-05-18 20:36:33 +09:00
|
|
|
group: null,
|
2018-12-19 07:22:01 +09:00
|
|
|
users: [],
|
2019-05-22 05:06:52 +09:00
|
|
|
faCrown, faICursor, faTrashAlt, faUsers, faPlus
|
2018-12-19 07:22:01 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2019-05-18 20:36:33 +09:00
|
|
|
created() {
|
|
|
|
this.$root.api('users/groups/show', {
|
|
|
|
groupId: this.groupId
|
|
|
|
}).then(group => {
|
|
|
|
this.group = group;
|
|
|
|
this.fetchUsers();
|
|
|
|
this.$emit('init', {
|
|
|
|
title: this.group.name,
|
|
|
|
icon: faUsers
|
|
|
|
});
|
|
|
|
});
|
2018-12-19 07:22:01 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2019-05-22 05:06:52 +09:00
|
|
|
fetchGroup() {
|
|
|
|
this.$root.api('users/groups/show', {
|
|
|
|
groupId: this.group.id
|
|
|
|
}).then(group => {
|
|
|
|
this.group = group;
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2018-12-19 07:22:01 +09:00
|
|
|
fetchUsers() {
|
|
|
|
this.$root.api('users/show', {
|
2019-05-18 20:36:33 +09:00
|
|
|
userIds: this.group.userIds
|
2018-12-19 07:22:01 +09:00
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
rename() {
|
|
|
|
this.$root.dialog({
|
|
|
|
title: this.$t('rename'),
|
|
|
|
input: {
|
2019-05-18 20:36:33 +09:00
|
|
|
default: this.group.name
|
2018-12-19 07:22:01 +09:00
|
|
|
}
|
2019-04-23 22:35:26 +09:00
|
|
|
}).then(({ canceled, result: name }) => {
|
2018-12-19 07:22:01 +09:00
|
|
|
if (canceled) return;
|
2019-05-18 20:36:33 +09:00
|
|
|
this.$root.api('users/groups/update', {
|
|
|
|
groupId: this.group.id,
|
2019-04-23 22:35:26 +09:00
|
|
|
name: name
|
2019-05-22 05:06:52 +09:00
|
|
|
}).then(() => {
|
|
|
|
this.fetchGroup();
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2018-12-19 07:22:01 +09:00
|
|
|
});
|
2019-05-22 05:06:52 +09:00
|
|
|
})
|
2018-12-19 07:22:01 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
del() {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'warning',
|
2019-05-18 20:36:33 +09:00
|
|
|
text: this.$t('delete-are-you-sure').replace('$1', this.group.name),
|
2018-12-19 07:22:01 +09:00
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
2019-05-18 20:36:33 +09:00
|
|
|
this.$root.api('users/groups/delete', {
|
|
|
|
groupId: this.group.id
|
2018-12-19 07:22:01 +09:00
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
text: this.$t('deleted')
|
|
|
|
});
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
remove(user: any) {
|
2019-05-18 20:36:33 +09:00
|
|
|
this.$root.api('users/groups/pull', {
|
|
|
|
groupId: this.group.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
2019-05-22 05:06:52 +09:00
|
|
|
this.fetchGroup();
|
2019-05-18 20:36:33 +09:00
|
|
|
this.fetchUsers();
|
2019-05-22 05:06:52 +09:00
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2019-05-18 20:36:33 +09:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-05-19 20:41:23 +09:00
|
|
|
async invite() {
|
2019-05-22 12:55:53 +09:00
|
|
|
const t = this.$t('invited');
|
2019-05-18 20:36:33 +09:00
|
|
|
const { result: user } = await this.$root.dialog({
|
|
|
|
user: {
|
|
|
|
local: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (user == null) return;
|
2019-05-19 20:41:23 +09:00
|
|
|
this.$root.api('users/groups/invite', {
|
2019-05-18 20:36:33 +09:00
|
|
|
groupId: this.group.id,
|
2018-12-19 07:22:01 +09:00
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
2019-05-19 20:41:23 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
2019-05-22 12:55:53 +09:00
|
|
|
text: t
|
2019-05-22 05:06:52 +09:00
|
|
|
});
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async transfer() {
|
|
|
|
const { result: user } = await this.$root.dialog({
|
|
|
|
user: {
|
|
|
|
local: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (user == null) return;
|
|
|
|
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('transfer-are-you-sure').replace('$1', this.group.name).replace('$2', user.username),
|
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
this.$root.api('users/groups/transfer', {
|
|
|
|
groupId: this.group.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
text: this.$t('transferred')
|
|
|
|
});
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
2019-05-19 20:41:23 +09:00
|
|
|
});
|
2018-12-19 07:22:01 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2019-05-18 20:36:33 +09:00
|
|
|
.ivrbakop
|
|
|
|
.kjlrfbes
|
2018-12-19 07:22:01 +09:00
|
|
|
display flex
|
2019-05-18 20:36:33 +09:00
|
|
|
padding 16px
|
2018-12-19 07:22:01 +09:00
|
|
|
border-top solid 1px var(--faceDivider)
|
|
|
|
|
|
|
|
> div:first-child
|
|
|
|
> a
|
|
|
|
> .avatar
|
|
|
|
width 64px
|
|
|
|
height 64px
|
|
|
|
|
|
|
|
> div:last-child
|
|
|
|
flex 1
|
|
|
|
padding-left 16px
|
|
|
|
|
|
|
|
@media (max-width 500px)
|
|
|
|
font-size 14px
|
|
|
|
|
|
|
|
> header
|
2019-05-19 02:39:34 +09:00
|
|
|
color var(--text)
|
|
|
|
|
2019-05-22 05:06:52 +09:00
|
|
|
> .is-owner
|
|
|
|
flex-shrink 0
|
|
|
|
align-self center
|
|
|
|
margin-left 8px
|
|
|
|
padding 1px 6px
|
|
|
|
font-size 80%
|
|
|
|
background var(--groupUserListOwnerBg)
|
|
|
|
color var(--groupUserListOwnerFg)
|
|
|
|
border-radius 3px
|
|
|
|
|
2018-12-19 07:22:01 +09:00
|
|
|
> .username
|
|
|
|
margin-left 8px
|
|
|
|
opacity 0.7
|
|
|
|
|
|
|
|
</style>
|