2019-01-21 14:08:22 +00:00
|
|
|
<template>
|
2019-10-01 18:10:53 +00:00
|
|
|
<section class="container">
|
2019-01-21 14:08:22 +00:00
|
|
|
<h1>
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Group List') }}
|
2019-01-21 14:08:22 +00:00
|
|
|
</h1>
|
|
|
|
<b-loading :active.sync="$apollo.loading"></b-loading>
|
|
|
|
<div class="columns">
|
|
|
|
<GroupCard
|
|
|
|
v-for="group in groups"
|
|
|
|
:key="group.uuid"
|
|
|
|
:group="group"
|
|
|
|
class="column is-one-quarter-desktop is-half-mobile"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-04-03 15:29:03 +00:00
|
|
|
<router-link class="button" :to="{ name: RouteName.CREATE_GROUP }">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Create group') }}
|
2019-01-21 14:08:22 +00:00
|
|
|
</router-link>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-02-22 13:55:47 +00:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import { RouteName } from '@/router';
|
2019-01-21 14:08:22 +00:00
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class GroupList extends Vue {
|
|
|
|
groups = [];
|
|
|
|
loading = true;
|
|
|
|
|
2019-04-03 15:29:03 +00:00
|
|
|
RouteName = RouteName;
|
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
created() {
|
|
|
|
this.fetchData();
|
|
|
|
}
|
|
|
|
|
|
|
|
usernameWithDomain(actor) {
|
2019-03-22 09:57:14 +00:00
|
|
|
return actor.username + (actor.domain === null ? '' : `@${actor.domain}`);
|
2019-01-21 14:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fetchData() {
|
|
|
|
// FIXME: remove eventFetch
|
|
|
|
// eventFetch('/groups', this.$store)
|
|
|
|
// .then(response => response.json())
|
|
|
|
// .then((data) => {
|
|
|
|
// console.log(data);
|
|
|
|
// this.loading = false;
|
|
|
|
// this.groups = data.data;
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteGroup(group) {
|
|
|
|
const router = this.$router;
|
|
|
|
// FIXME: remove eventFetch
|
|
|
|
// eventFetch(`/groups/${this.usernameWithDomain(group)}`, this.$store, { method: 'DELETE' })
|
|
|
|
// .then(response => response.json())
|
|
|
|
// .then(() => router.push('/groups'));
|
|
|
|
}
|
|
|
|
|
|
|
|
viewActor(actor) {
|
|
|
|
this.$router.push({
|
2019-02-22 13:55:47 +00:00
|
|
|
name: RouteName.GROUP,
|
2019-03-22 09:57:14 +00:00
|
|
|
params: { name: this.usernameWithDomain(actor) },
|
2019-01-21 14:08:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
joinGroup(group) {
|
|
|
|
const router = this.$router;
|
|
|
|
// FIXME: remove eventFetch
|
|
|
|
// eventFetch(`/groups/${this.usernameWithDomain(group)}/join`, this.$store, { method: 'POST' })
|
|
|
|
// .then(response => response.json())
|
|
|
|
// .then(() => router.push({ name: 'Group', params: { name: this.usernameWithDomain(group) } }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
|
|
<style scoped>
|
|
|
|
</style>
|