2019-05-18 13:36:33 +02:00
|
|
|
<template>
|
2019-05-19 13:41:23 +02:00
|
|
|
<div>
|
2019-05-20 23:34:10 +02:00
|
|
|
<ui-container :body-togglable="true">
|
2019-05-19 13:41:23 +02:00
|
|
|
<template #header><fa :icon="faUsers"/> {{ $t('owned-groups') }}</template>
|
2019-05-18 13:36:33 +02:00
|
|
|
<ui-margin>
|
2019-05-19 13:41:23 +02:00
|
|
|
<ui-button @click="add"><fa :icon="faPlus"/> {{ $t('create-group') }}</ui-button>
|
2019-05-18 13:36:33 +02:00
|
|
|
</ui-margin>
|
2019-05-19 13:41:23 +02:00
|
|
|
<div class="hwgkdrbl" v-for="group in ownedGroups" :key="group.id">
|
|
|
|
<ui-hr/>
|
|
|
|
<ui-margin>
|
|
|
|
<router-link :to="`/i/groups/${group.id}`">{{ group.name }}</router-link>
|
2019-05-21 01:44:36 +02:00
|
|
|
<x-avatars :user-ids="group.userIds" style="margin-top:8px;"/>
|
2019-05-19 13:41:23 +02:00
|
|
|
</ui-margin>
|
|
|
|
</div>
|
|
|
|
</ui-container>
|
|
|
|
|
2019-05-20 23:34:10 +02:00
|
|
|
<ui-container :body-togglable="true">
|
2019-05-19 13:41:23 +02:00
|
|
|
<template #header><fa :icon="faUsers"/> {{ $t('joined-groups') }}</template>
|
|
|
|
<div class="hwgkdrbl" v-for="(group, i) in joinedGroups" :key="group.id">
|
|
|
|
<ui-hr v-if="i != 0"/>
|
|
|
|
<ui-margin>
|
2019-05-21 01:44:36 +02:00
|
|
|
<div>{{ group.name }}</div>
|
|
|
|
<x-avatars :user-ids="group.userIds" style="margin-top:8px;"/>
|
2019-05-19 13:41:23 +02:00
|
|
|
</ui-margin>
|
|
|
|
</div>
|
|
|
|
</ui-container>
|
|
|
|
|
2019-05-20 23:34:10 +02:00
|
|
|
<ui-container :body-togglable="true">
|
2019-05-19 13:41:23 +02:00
|
|
|
<template #header><fa :icon="faEnvelopeOpenText"/> {{ $t('invites') }}</template>
|
|
|
|
<div class="fvlojuur" v-for="(invite, i) in invites" :key="invite.id">
|
|
|
|
<ui-hr v-if="i != 0"/>
|
|
|
|
<ui-margin>
|
|
|
|
<div class="name">{{ invite.group.name }}</div>
|
2019-05-21 01:44:36 +02:00
|
|
|
<x-avatars :user-ids="invite.group.userIds" style="margin-top:8px;"/>
|
2019-05-19 13:41:23 +02:00
|
|
|
<ui-horizon-group>
|
|
|
|
<ui-button @click="acceptInvite(invite)"><fa :icon="faCheck"/> {{ $t('accept-invite') }}</ui-button>
|
|
|
|
<ui-button @click="rejectInvite(invite)"><fa :icon="faBan"/> {{ $t('reject-invite') }}</ui-button>
|
|
|
|
</ui-horizon-group>
|
|
|
|
</ui-margin>
|
|
|
|
</div>
|
|
|
|
</ui-container>
|
|
|
|
</div>
|
2019-05-18 13:36:33 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-05-19 13:41:23 +02:00
|
|
|
import { faUsers, faPlus, faCheck, faBan, faEnvelopeOpenText } from '@fortawesome/free-solid-svg-icons';
|
2019-05-21 01:44:36 +02:00
|
|
|
import i18n from '../../../i18n';
|
|
|
|
import XAvatars from '../../views/components/avatars.vue';
|
2019-05-18 13:36:33 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
i18n: i18n('common/views/components/user-groups.vue'),
|
2019-05-21 01:44:36 +02:00
|
|
|
components: {
|
|
|
|
XAvatars
|
|
|
|
},
|
2019-05-18 13:36:33 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2019-05-19 13:41:23 +02:00
|
|
|
ownedGroups: [],
|
|
|
|
joinedGroups: [],
|
|
|
|
invites: [],
|
|
|
|
faUsers, faPlus, faCheck, faBan, faEnvelopeOpenText
|
2019-05-18 13:36:33 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$root.api('users/groups/owned').then(groups => {
|
2019-05-19 13:41:23 +02:00
|
|
|
this.ownedGroups = groups;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$root.api('users/groups/joined').then(groups => {
|
|
|
|
this.joinedGroups = groups;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$root.api('i/user-group-invites').then(invites => {
|
|
|
|
this.invites = invites;
|
2019-05-18 13:36:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.$emit('init', {
|
|
|
|
title: this.$t('user-groups'),
|
|
|
|
icon: faUsers
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
add() {
|
|
|
|
this.$root.dialog({
|
|
|
|
title: this.$t('group-name'),
|
|
|
|
input: true
|
|
|
|
}).then(async ({ canceled, result: name }) => {
|
|
|
|
if (canceled) return;
|
2019-05-19 13:41:23 +02:00
|
|
|
const group = await this.$root.api('users/groups/create', {
|
2019-05-18 13:36:33 +02:00
|
|
|
name
|
|
|
|
});
|
|
|
|
|
2019-05-19 13:41:23 +02:00
|
|
|
this.ownedGroups.push(group)
|
2019-05-18 13:36:33 +02:00
|
|
|
});
|
|
|
|
},
|
2019-05-19 13:41:23 +02:00
|
|
|
acceptInvite(invite) {
|
|
|
|
this.$root.api('users/groups/invitations/accept', {
|
|
|
|
inviteId: invite.id
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
splash: true
|
|
|
|
});
|
|
|
|
this.$root.api('i/user-group-invites').then(invites => {
|
|
|
|
this.invites = invites;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
rejectInvite(invite) {
|
|
|
|
this.$root.api('users/groups/invitations/reject', {
|
|
|
|
inviteId: invite.id
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.api('i/user-group-invites').then(invites => {
|
|
|
|
this.invites = invites;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-05-18 13:36:33 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.hwgkdrbl
|
|
|
|
display block
|
|
|
|
|
|
|
|
</style>
|