2020-02-08 06:11:12 +00:00
|
|
|
<template>
|
|
|
|
<div class="">
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_section" style="padding: 0;">
|
2020-11-17 05:59:15 +00:00
|
|
|
<MkTab v-model:value="tab">
|
2020-12-26 01:47:36 +00:00
|
|
|
<option value="owned">{{ $ts.ownedGroups }}</option>
|
|
|
|
<option value="joined">{{ $ts.joinedGroups }}</option>
|
2021-04-20 14:22:59 +00:00
|
|
|
<option value="invites"><i class="fas fa-envelope-open-text"></i> {{ $ts.invites }}</option>
|
2020-11-17 05:59:15 +00:00
|
|
|
</MkTab>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2020-02-08 06:11:12 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_section">
|
|
|
|
<div class="_content" v-if="tab === 'owned'">
|
2021-04-20 14:22:59 +00:00
|
|
|
<MkButton @click="create" primary style="margin: 0 auto var(--margin) auto;"><i class="fas fa-plus"></i> {{ $ts.createGroup }}</MkButton>
|
2020-02-08 06:11:12 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkPagination :pagination="ownedPagination" #default="{items}" ref="owned">
|
|
|
|
<div class="_card" v-for="group in items" :key="group.id">
|
2020-10-24 16:21:41 +00:00
|
|
|
<div class="_title"><MkA :to="`/my/groups/${ group.id }`" class="_link">{{ group.name }}</MkA></div>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_content"><MkAvatars :user-ids="group.userIds"/></div>
|
2020-02-08 06:47:16 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2020-02-08 06:11:12 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_content" v-else-if="tab === 'joined'">
|
|
|
|
<MkPagination :pagination="joinedPagination" #default="{items}" ref="joined">
|
|
|
|
<div class="_card" v-for="group in items" :key="group.id">
|
|
|
|
<div class="_title">{{ group.name }}</div>
|
|
|
|
<div class="_content"><MkAvatars :user-ids="group.userIds"/></div>
|
|
|
|
</div>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_content" v-else-if="tab === 'invites'">
|
|
|
|
<MkPagination :pagination="invitationPagination" #default="{items}" ref="invitations">
|
|
|
|
<div class="_card" v-for="invitation in items" :key="invitation.id">
|
|
|
|
<div class="_title">{{ invitation.group.name }}</div>
|
|
|
|
<div class="_content"><MkAvatars :user-ids="invitation.group.userIds"/></div>
|
|
|
|
<div class="_footer">
|
2021-04-20 14:22:59 +00:00
|
|
|
<MkButton @click="acceptInvite(invitation)" primary inline><i class="fas fa-check"></i> {{ $ts.accept }}</MkButton>
|
|
|
|
<MkButton @click="rejectInvite(invitation)" primary inline><i class="fas fa-ban"></i> {{ $ts.reject }}</MkButton>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-02-08 06:11:12 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
|
|
|
import MkAvatars from '@client/components/avatars.vue';
|
|
|
|
import MkTab from '@client/components/tab.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 03:54:12 +00:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-02-08 06:11:12 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-02-08 06:11:12 +00:00
|
|
|
components: {
|
|
|
|
MkPagination,
|
|
|
|
MkButton,
|
|
|
|
MkContainer,
|
2020-10-17 11:12:00 +00:00
|
|
|
MkTab,
|
2020-02-08 07:51:27 +00:00
|
|
|
MkAvatars,
|
2020-02-08 06:11:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 03:54:12 +00:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.groups,
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-users'
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
tab: 'owned',
|
2020-02-08 06:11:12 +00:00
|
|
|
ownedPagination: {
|
|
|
|
endpoint: 'users/groups/owned',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
joinedPagination: {
|
|
|
|
endpoint: 'users/groups/joined',
|
|
|
|
limit: 10,
|
|
|
|
},
|
2020-02-12 17:17:54 +00:00
|
|
|
invitationPagination: {
|
2020-02-08 06:11:12 +00:00
|
|
|
endpoint: 'i/user-group-invites',
|
|
|
|
limit: 10,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async create() {
|
2020-10-17 11:12:00 +00:00
|
|
|
const { canceled, result: name } = await os.dialog({
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.groupName,
|
2020-02-08 06:11:12 +00:00
|
|
|
input: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 11:12:00 +00:00
|
|
|
await os.api('users/groups/create', { name: name });
|
2020-02-08 06:11:12 +00:00
|
|
|
this.$refs.owned.reload();
|
2020-10-17 11:12:00 +00:00
|
|
|
os.success();
|
2020-02-08 06:11:12 +00:00
|
|
|
},
|
2020-02-12 17:17:54 +00:00
|
|
|
acceptInvite(invitation) {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('users/groups/invitations/accept', {
|
2020-02-12 17:17:54 +00:00
|
|
|
invitationId: invitation.id
|
2020-02-08 18:40:09 +00:00
|
|
|
}).then(() => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.success();
|
2020-02-12 17:17:54 +00:00
|
|
|
this.$refs.invitations.reload();
|
2020-02-08 18:40:09 +00:00
|
|
|
this.$refs.joined.reload();
|
|
|
|
});
|
|
|
|
},
|
2020-02-12 17:17:54 +00:00
|
|
|
rejectInvite(invitation) {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('users/groups/invitations/reject', {
|
2020-02-12 17:17:54 +00:00
|
|
|
invitationId: invitation.id
|
2020-02-08 18:40:09 +00:00
|
|
|
}).then(() => {
|
2020-02-12 17:17:54 +00:00
|
|
|
this.$refs.invitations.reload();
|
2020-02-08 18:40:09 +00:00
|
|
|
});
|
|
|
|
}
|
2020-02-08 06:11:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|