2020-08-31 10:40:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="container section" v-if="group">
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.GROUP,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
2020-09-29 07:53:48 +00:00
|
|
|
>{{ group.name }}</router-link
|
2020-08-31 10:40:30 +00:00
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.TODO_LISTS,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
|
|
|
>{{ $t("Events") }}</router-link
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<section>
|
|
|
|
<h1 class="title" v-if="group">
|
2020-11-30 09:24:11 +00:00
|
|
|
{{
|
|
|
|
$t("{group}'s events", {
|
|
|
|
group: group.name || group.preferredUsername,
|
|
|
|
})
|
|
|
|
}}
|
2020-08-31 10:40:30 +00:00
|
|
|
</h1>
|
2020-10-01 13:57:07 +00:00
|
|
|
<p v-if="isCurrentActorMember">
|
2020-08-31 10:40:30 +00:00
|
|
|
{{
|
|
|
|
$t(
|
2020-10-22 08:48:49 +00:00
|
|
|
"When a moderator from the group creates an event and attributes it to the group, it will show up here."
|
2020-08-31 10:40:30 +00:00
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
2020-10-22 08:48:49 +00:00
|
|
|
<router-link
|
|
|
|
v-if="isCurrentActorAGroupModerator"
|
|
|
|
:to="{
|
|
|
|
name: RouteName.CREATE_EVENT,
|
2021-06-11 16:29:16 +00:00
|
|
|
query: { actorId: group.id },
|
2020-10-22 08:48:49 +00:00
|
|
|
}"
|
|
|
|
class="button is-primary"
|
|
|
|
>{{ $t("+ Create an event") }}</router-link
|
|
|
|
>
|
2020-08-31 10:40:30 +00:00
|
|
|
<b-loading :active.sync="$apollo.loading"></b-loading>
|
2020-09-02 15:42:17 +00:00
|
|
|
<section v-if="group">
|
2020-08-31 10:40:30 +00:00
|
|
|
<subtitle>
|
2020-09-02 15:42:17 +00:00
|
|
|
{{ showPassedEvents ? $t("Past events") : $t("Upcoming events") }}
|
2020-08-31 10:40:30 +00:00
|
|
|
</subtitle>
|
2020-09-02 15:42:17 +00:00
|
|
|
<b-switch v-model="showPassedEvents">{{ $t("Past events") }}</b-switch>
|
2020-12-09 08:56:53 +00:00
|
|
|
<transition-group name="list" tag="div" class="event-list">
|
2020-09-02 15:42:17 +00:00
|
|
|
<EventListViewCard
|
|
|
|
v-for="event in group.organizedEvents.elements"
|
|
|
|
:key="event.id"
|
|
|
|
:event="event"
|
2020-10-01 13:57:07 +00:00
|
|
|
:options="{ memberofGroup: isCurrentActorMember }"
|
2020-09-02 15:42:17 +00:00
|
|
|
/>
|
2020-08-31 10:40:30 +00:00
|
|
|
</transition-group>
|
2020-09-02 15:42:17 +00:00
|
|
|
<b-message
|
2020-11-30 09:24:11 +00:00
|
|
|
v-if="
|
|
|
|
group.organizedEvents.elements.length === 0 &&
|
|
|
|
$apollo.loading === false
|
|
|
|
"
|
2020-09-02 15:42:17 +00:00
|
|
|
type="is-danger"
|
|
|
|
>
|
|
|
|
{{ $t("No events found") }}
|
|
|
|
</b-message>
|
2020-12-09 08:56:53 +00:00
|
|
|
<b-pagination
|
|
|
|
:total="group.organizedEvents.total"
|
|
|
|
v-model="eventsPage"
|
|
|
|
:per-page="EVENTS_PAGE_LIMIT"
|
|
|
|
:aria-next-label="$t('Next page')"
|
|
|
|
:aria-previous-label="$t('Previous page')"
|
|
|
|
:aria-page-label="$t('Page')"
|
|
|
|
:aria-current-label="$t('Current page')"
|
|
|
|
>
|
|
|
|
</b-pagination>
|
2020-08-31 10:40:30 +00:00
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-10-22 08:48:49 +00:00
|
|
|
import { Component } from "vue-property-decorator";
|
|
|
|
import { mixins } from "vue-class-component";
|
2020-08-31 10:40:30 +00:00
|
|
|
import RouteName from "@/router/name";
|
2020-09-02 15:42:17 +00:00
|
|
|
import Subtitle from "@/components/Utils/Subtitle.vue";
|
|
|
|
import EventListViewCard from "@/components/Event/EventListViewCard.vue";
|
2021-06-11 16:30:28 +00:00
|
|
|
import { PERSON_MEMBERSHIPS } from "@/graphql/actor";
|
2020-10-22 08:48:49 +00:00
|
|
|
import GroupMixin from "@/mixins/group";
|
2020-11-27 18:27:44 +00:00
|
|
|
import { IMember } from "@/types/actor/member.model";
|
2020-12-09 08:56:53 +00:00
|
|
|
import { FETCH_GROUP_EVENTS } from "@/graphql/event";
|
2021-06-11 16:30:28 +00:00
|
|
|
import { usernameWithDomain } from "../../types/actor";
|
2020-08-31 10:40:30 +00:00
|
|
|
|
2020-12-09 08:56:53 +00:00
|
|
|
const EVENTS_PAGE_LIMIT = 10;
|
|
|
|
|
2020-08-31 10:40:30 +00:00
|
|
|
@Component({
|
|
|
|
apollo: {
|
2020-10-01 13:57:07 +00:00
|
|
|
memberships: {
|
|
|
|
query: PERSON_MEMBERSHIPS,
|
|
|
|
fetchPolicy: "cache-and-network",
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
id: this.currentActor.id,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update: (data) => data.person.memberships.elements,
|
|
|
|
skip() {
|
|
|
|
return !this.currentActor || !this.currentActor.id;
|
|
|
|
},
|
|
|
|
},
|
2020-08-31 10:40:30 +00:00
|
|
|
group: {
|
2020-12-09 08:56:53 +00:00
|
|
|
query: FETCH_GROUP_EVENTS,
|
2020-08-31 10:40:30 +00:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
name: this.$route.params.preferredUsername,
|
2020-09-02 15:42:17 +00:00
|
|
|
beforeDateTime: this.showPassedEvents ? new Date() : null,
|
|
|
|
afterDateTime: this.showPassedEvents ? null : new Date(),
|
2020-12-09 08:56:53 +00:00
|
|
|
organisedEventsPage: this.eventsPage,
|
|
|
|
organisedEventslimit: EVENTS_PAGE_LIMIT,
|
2020-08-31 10:40:30 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-09-02 15:42:17 +00:00
|
|
|
components: {
|
|
|
|
Subtitle,
|
|
|
|
EventListViewCard,
|
|
|
|
},
|
2021-05-25 14:21:29 +00:00
|
|
|
metaInfo() {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore
|
|
|
|
const { group } = this;
|
|
|
|
return {
|
|
|
|
title: this.$t("{group} events", {
|
2021-06-16 12:47:36 +00:00
|
|
|
group: group?.name || usernameWithDomain(group),
|
2021-05-25 14:21:29 +00:00
|
|
|
}) as string,
|
|
|
|
};
|
|
|
|
},
|
2020-08-31 10:40:30 +00:00
|
|
|
})
|
2020-10-22 08:48:49 +00:00
|
|
|
export default class GroupEvents extends mixins(GroupMixin) {
|
2020-10-01 13:57:07 +00:00
|
|
|
memberships!: IMember[];
|
|
|
|
|
2020-12-09 08:56:53 +00:00
|
|
|
eventsPage = 1;
|
|
|
|
|
2020-08-31 10:40:30 +00:00
|
|
|
usernameWithDomain = usernameWithDomain;
|
|
|
|
|
|
|
|
RouteName = RouteName;
|
2020-09-02 15:42:17 +00:00
|
|
|
|
2020-12-09 08:56:53 +00:00
|
|
|
EVENTS_PAGE_LIMIT = EVENTS_PAGE_LIMIT;
|
2020-10-01 13:57:07 +00:00
|
|
|
|
|
|
|
get isCurrentActorMember(): boolean {
|
|
|
|
if (!this.group || !this.memberships) return false;
|
2020-11-30 09:24:11 +00:00
|
|
|
return this.memberships
|
|
|
|
.map(({ parent: { id } }) => id)
|
|
|
|
.includes(this.group.id);
|
2020-10-01 13:57:07 +00:00
|
|
|
}
|
2020-12-09 08:56:53 +00:00
|
|
|
|
|
|
|
get showPassedEvents(): boolean {
|
|
|
|
return (
|
|
|
|
this.$route.query.future !== undefined &&
|
|
|
|
this.$route.query.future.toString() === "false"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
set showPassedEvents(value: boolean) {
|
|
|
|
this.$router.push({ query: { future: this.showPassedEvents.toString() } });
|
|
|
|
}
|
2020-08-31 10:40:30 +00:00
|
|
|
}
|
|
|
|
</script>
|
2020-10-22 08:48:49 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.container.section {
|
|
|
|
background: $white;
|
|
|
|
}
|
2020-12-09 08:56:53 +00:00
|
|
|
|
|
|
|
div.event-list {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
2020-10-22 08:48:49 +00:00
|
|
|
</style>
|