2020-02-08 15:11:12 +09:00
|
|
|
<template>
|
|
|
|
<div class="mk-group-page">
|
|
|
|
<transition name="zoom" mode="out-in">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div v-if="group" class="_section">
|
2020-02-08 15:11:12 +09:00
|
|
|
<div class="_content">
|
2020-12-26 10:47:36 +09:00
|
|
|
<MkButton inline @click="invite()">{{ $ts.invite }}</MkButton>
|
|
|
|
<MkButton inline @click="renameGroup()">{{ $ts.rename }}</MkButton>
|
|
|
|
<MkButton inline @click="transfer()">{{ $ts.transfer }}</MkButton>
|
|
|
|
<MkButton inline @click="deleteGroup()">{{ $ts.delete }}</MkButton>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="zoom" mode="out-in">
|
2021-04-10 18:17:42 +09:00
|
|
|
<div v-if="group" class="_section members _gap">
|
2020-12-26 10:47:36 +09:00
|
|
|
<div class="_title">{{ $ts.members }}</div>
|
2020-02-08 15:11:12 +09:00
|
|
|
<div class="_content">
|
|
|
|
<div class="users">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div class="user _panel" v-for="user in users" :key="user.id">
|
2021-04-17 23:52:54 +09:00
|
|
|
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
|
2020-02-08 15:11:12 +09:00
|
|
|
<div class="body">
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkUserName :user="user" class="name"/>
|
|
|
|
<MkAcct :user="user" class="acct"/>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
<div class="action">
|
2021-04-20 23:22:59 +09:00
|
|
|
<button class="_button" @click="removeUser(user)"><i class="fas fa-times"></i></button>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import Progress from '@client/scripts/loading';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 12:54:12 +09:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-02-08 15:11:12 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-02-08 15:11:12 +09:00
|
|
|
components: {
|
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
2021-01-18 00:53:48 +09:00
|
|
|
props: {
|
|
|
|
groupId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-02-08 15:11:12 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.group ? {
|
2020-11-03 20:36:12 +09:00
|
|
|
title: this.group.name,
|
2021-04-20 23:22:59 +09:00
|
|
|
icon: 'fas fa-users',
|
2020-10-17 20:12:00 +09:00
|
|
|
} : null),
|
2020-02-08 15:11:12 +09:00
|
|
|
group: null,
|
|
|
|
users: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2021-01-18 00:53:48 +09:00
|
|
|
groupId: 'fetch',
|
2020-02-08 15:11:12 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/groups/show', {
|
2021-01-18 00:53:48 +09:00
|
|
|
groupId: this.groupId
|
2020-02-08 15:11:12 +09:00
|
|
|
}).then(group => {
|
|
|
|
this.group = group;
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/show', {
|
2020-02-08 15:11:12 +09:00
|
|
|
userIds: this.group.userIds
|
|
|
|
}).then(users => {
|
|
|
|
this.users = users;
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
invite() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.selectUser().then(user => {
|
|
|
|
os.apiWithDialog('users/groups/invite', {
|
2020-02-08 15:11:12 +09:00
|
|
|
groupId: this.group.id,
|
|
|
|
userId: user.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeUser(user) {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/groups/pull', {
|
2020-02-08 15:11:12 +09:00
|
|
|
groupId: this.group.id,
|
|
|
|
userId: user.id
|
|
|
|
}).then(() => {
|
|
|
|
this.users = this.users.filter(x => x.id !== user.id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async renameGroup() {
|
2020-10-17 20:12:00 +09:00
|
|
|
const { canceled, result: name } = await os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.groupName,
|
2020-02-08 15:11:12 +09:00
|
|
|
input: {
|
|
|
|
default: this.group.name
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.api('users/groups/update', {
|
2020-02-08 15:11:12 +09:00
|
|
|
groupId: this.group.id,
|
|
|
|
name: name
|
|
|
|
});
|
|
|
|
|
|
|
|
this.group.name = name;
|
|
|
|
},
|
|
|
|
|
2020-02-08 15:17:35 +09:00
|
|
|
transfer() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.selectUser().then(user => {
|
|
|
|
os.apiWithDialog('users/groups/transfer', {
|
2020-02-08 15:17:35 +09:00
|
|
|
groupId: this.group.id,
|
|
|
|
userId: user.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-02-08 15:11:12 +09:00
|
|
|
async deleteGroup() {
|
2020-10-17 20:12:00 +09:00
|
|
|
const { canceled } = await os.dialog({
|
2020-02-08 15:11:12 +09:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: this.group.name }),
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
await os.apiWithDialog('users/groups/delete', {
|
2020-02-08 15:11:12 +09:00
|
|
|
groupId: this.group.id
|
|
|
|
});
|
|
|
|
this.$router.push('/my/groups');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-group-page {
|
|
|
|
> .members {
|
|
|
|
> ._content {
|
|
|
|
> .users {
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 20:12:00 +09:00
|
|
|
padding: 16px;
|
2020-02-08 15:11:12 +09:00
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
flex: 1;
|
|
|
|
padding: 8px;
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
display: block;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .acct {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|