2020-02-08 15:11:12 +09:00
|
|
|
<template>
|
|
|
|
<div class="">
|
|
|
|
<portal to="icon"><fa :icon="faUsers"/></portal>
|
2020-07-25 01:56:52 +09:00
|
|
|
<portal to="title">{{ $t('groups') }}</portal>
|
2020-02-08 15:11:12 +09:00
|
|
|
|
|
|
|
<mk-button @click="create" primary style="margin: 0 auto var(--margin) auto;"><fa :icon="faPlus"/> {{ $t('createGroup') }}</mk-button>
|
|
|
|
|
|
|
|
<mk-container :body-togglable="true">
|
|
|
|
<template #header><fa :icon="faUsers"/> {{ $t('ownedGroups') }}</template>
|
|
|
|
<mk-pagination :pagination="ownedPagination" #default="{items}" ref="owned">
|
2020-07-04 18:28:57 +09:00
|
|
|
<div class="_card" v-for="group in items" :key="group.id">
|
2020-02-08 15:47:16 +09:00
|
|
|
<div class="_title"><router-link :to="`/my/groups/${ group.id }`" class="_link">{{ group.name }}</router-link></div>
|
2020-02-08 16:51:27 +09:00
|
|
|
<div class="_content"><mk-avatars :user-ids="group.userIds"/></div>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</mk-pagination>
|
|
|
|
</mk-container>
|
|
|
|
|
|
|
|
<mk-container :body-togglable="true">
|
|
|
|
<template #header><fa :icon="faEnvelopeOpenText"/> {{ $t('invites') }}</template>
|
2020-02-13 02:17:54 +09:00
|
|
|
<mk-pagination :pagination="invitationPagination" #default="{items}" ref="invitations">
|
2020-07-04 18:28:57 +09:00
|
|
|
<div class="_card" v-for="invitation in items" :key="invitation.id">
|
2020-02-13 02:17:54 +09:00
|
|
|
<div class="_title">{{ invitation.group.name }}</div>
|
|
|
|
<div class="_content"><mk-avatars :user-ids="invitation.group.userIds"/></div>
|
2020-02-08 15:47:16 +09:00
|
|
|
<div class="_footer">
|
2020-02-13 02:17:54 +09:00
|
|
|
<mk-button @click="acceptInvite(invitation)" primary inline><fa :icon="faCheck"/> {{ $t('accept') }}</mk-button>
|
|
|
|
<mk-button @click="rejectInvite(invitation)" primary inline><fa :icon="faBan"/> {{ $t('reject') }}</mk-button>
|
2020-02-08 15:47:16 +09:00
|
|
|
</div>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</mk-pagination>
|
|
|
|
</mk-container>
|
|
|
|
|
|
|
|
<mk-container :body-togglable="true">
|
|
|
|
<template #header><fa :icon="faUsers"/> {{ $t('joinedGroups') }}</template>
|
2020-02-09 03:40:09 +09:00
|
|
|
<mk-pagination :pagination="joinedPagination" #default="{items}" ref="joined">
|
2020-07-04 18:28:57 +09:00
|
|
|
<div class="_card" v-for="group in items" :key="group.id">
|
2020-02-08 15:47:16 +09:00
|
|
|
<div class="_title">{{ group.name }}</div>
|
2020-02-08 16:51:27 +09:00
|
|
|
<div class="_content"><mk-avatars :user-ids="group.userIds"/></div>
|
2020-02-08 15:11:12 +09:00
|
|
|
</div>
|
|
|
|
</mk-pagination>
|
|
|
|
</mk-container>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faUsers, faPlus, faEnvelopeOpenText } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkPagination from '../../components/ui/pagination.vue';
|
|
|
|
import MkButton from '../../components/ui/button.vue';
|
|
|
|
import MkContainer from '../../components/ui/container.vue';
|
2020-02-08 16:51:27 +09:00
|
|
|
import MkAvatars from '../../components/avatars.vue';
|
2020-02-08 15:11:12 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t('groups') as string,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
MkPagination,
|
|
|
|
MkButton,
|
|
|
|
MkContainer,
|
2020-02-08 16:51:27 +09:00
|
|
|
MkAvatars,
|
2020-02-08 15:11:12 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
ownedPagination: {
|
|
|
|
endpoint: 'users/groups/owned',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
joinedPagination: {
|
|
|
|
endpoint: 'users/groups/joined',
|
|
|
|
limit: 10,
|
|
|
|
},
|
2020-02-13 02:17:54 +09:00
|
|
|
invitationPagination: {
|
2020-02-08 15:11:12 +09:00
|
|
|
endpoint: 'i/user-group-invites',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
faUsers, faPlus, faEnvelopeOpenText
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async create() {
|
|
|
|
const { canceled, result: name } = await this.$root.dialog({
|
|
|
|
title: this.$t('groupName'),
|
|
|
|
input: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
await this.$root.api('users/groups/create', { name: name });
|
|
|
|
this.$refs.owned.reload();
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
iconOnly: true, autoClose: true
|
|
|
|
});
|
|
|
|
},
|
2020-02-13 02:17:54 +09:00
|
|
|
acceptInvite(invitation) {
|
2020-02-09 03:40:09 +09:00
|
|
|
this.$root.api('users/groups/invitations/accept', {
|
2020-02-13 02:17:54 +09:00
|
|
|
invitationId: invitation.id
|
2020-02-09 03:40:09 +09:00
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
iconOnly: true, autoClose: true
|
|
|
|
});
|
2020-02-13 02:17:54 +09:00
|
|
|
this.$refs.invitations.reload();
|
2020-02-09 03:40:09 +09:00
|
|
|
this.$refs.joined.reload();
|
|
|
|
});
|
|
|
|
},
|
2020-02-13 02:17:54 +09:00
|
|
|
rejectInvite(invitation) {
|
2020-02-09 03:40:09 +09:00
|
|
|
this.$root.api('users/groups/invitations/reject', {
|
2020-02-13 02:17:54 +09:00
|
|
|
invitationId: invitation.id
|
2020-02-09 03:40:09 +09:00
|
|
|
}).then(() => {
|
2020-02-13 02:17:54 +09:00
|
|
|
this.$refs.invitations.reload();
|
2020-02-09 03:40:09 +09:00
|
|
|
});
|
|
|
|
}
|
2020-02-08 15:11:12 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|