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