2019-09-20 16:22:03 +00:00
|
|
|
<template>
|
2020-02-18 07:57:00 +00:00
|
|
|
<main class="container">
|
2020-06-18 13:23:05 +00:00
|
|
|
<section v-if="event">
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<router-link :to="{ name: RouteName.MY_EVENTS }">{{ $t("My events") }}</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: event.uuid },
|
|
|
|
}"
|
|
|
|
>{{ event.title }}</router-link
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.PARTICIPANTS,
|
|
|
|
params: { uuid: event.uuid },
|
|
|
|
}"
|
|
|
|
>{{ $t("Participants") }}</router-link
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<h2 class="title">{{ $t("Participants") }}</h2>
|
|
|
|
<b-field :label="$t('Status')" horizontal>
|
|
|
|
<b-select v-model="roles">
|
|
|
|
<option value="">
|
|
|
|
{{ $t("Everything") }}
|
|
|
|
</option>
|
|
|
|
<option :value="ParticipantRole.CREATOR">
|
|
|
|
{{ $t("Organizer") }}
|
|
|
|
</option>
|
|
|
|
<option :value="ParticipantRole.PARTICIPANT">
|
|
|
|
{{ $t("Participant") }}
|
|
|
|
</option>
|
|
|
|
<option :value="ParticipantRole.NOT_APPROVED">
|
|
|
|
{{ $t("Not approved") }}
|
|
|
|
</option>
|
|
|
|
<option :value="ParticipantRole.REJECTED">
|
|
|
|
{{ $t("Rejected") }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
<b-table
|
|
|
|
:data="event.participants.elements"
|
|
|
|
ref="queueTable"
|
|
|
|
detailed
|
|
|
|
detail-key="id"
|
|
|
|
:checked-rows.sync="checkedRows"
|
|
|
|
checkable
|
|
|
|
:is-row-checkable="(row) => row.role !== ParticipantRole.CREATOR"
|
|
|
|
checkbox-position="left"
|
|
|
|
:show-detail-icon="false"
|
|
|
|
:loading="this.$apollo.loading"
|
|
|
|
paginated
|
|
|
|
backend-pagination
|
|
|
|
:pagination-simple="true"
|
|
|
|
:aria-next-label="$t('Next page')"
|
|
|
|
:aria-previous-label="$t('Previous page')"
|
|
|
|
:aria-page-label="$t('Page')"
|
|
|
|
:aria-current-label="$t('Current page')"
|
|
|
|
:total="event.participants.total"
|
|
|
|
:per-page="PARTICIPANTS_PER_PAGE"
|
|
|
|
backend-sorting
|
|
|
|
:default-sort-direction="'desc'"
|
|
|
|
:default-sort="['insertedAt', 'desc']"
|
|
|
|
@page-change="(newPage) => (page = newPage)"
|
|
|
|
@sort="(field, order) => $emit('sort', field, order)"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
<b-table-column field="actor.preferredUsername" :label="$t('Participant')" v-slot="props">
|
|
|
|
<article class="media">
|
|
|
|
<figure class="media-left image is-48x48" v-if="props.row.actor.avatar">
|
|
|
|
<img class="is-rounded" :src="props.row.actor.avatar.url" alt="" />
|
|
|
|
</figure>
|
|
|
|
<b-icon
|
|
|
|
class="media-left"
|
|
|
|
v-else-if="props.row.actor.preferredUsername === 'anonymous'"
|
|
|
|
size="is-large"
|
|
|
|
icon="incognito"
|
|
|
|
/>
|
|
|
|
<b-icon class="media-left" v-else size="is-large" icon="account-circle" />
|
|
|
|
<div class="media-content">
|
|
|
|
<div class="content">
|
|
|
|
<span v-if="props.row.actor.preferredUsername !== 'anonymous'">
|
|
|
|
<span v-if="props.row.actor.name">{{ props.row.actor.name }}</span
|
|
|
|
><br />
|
|
|
|
<span class="is-size-7 has-text-grey"
|
|
|
|
>@{{ usernameWithDomain(props.row.actor) }}</span
|
|
|
|
>
|
|
|
|
</span>
|
|
|
|
<span v-else>
|
|
|
|
{{ $t("Anonymous participant") }}
|
|
|
|
</span>
|
2020-06-18 13:23:05 +00:00
|
|
|
</div>
|
2020-08-18 13:50:50 +00:00
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="role" :label="$t('Role')" v-slot="props">
|
|
|
|
<b-tag type="is-primary" v-if="props.row.role === ParticipantRole.CREATOR">
|
|
|
|
{{ $t("Organizer") }}
|
|
|
|
</b-tag>
|
|
|
|
<b-tag v-else-if="props.row.role === ParticipantRole.PARTICIPANT">
|
|
|
|
{{ $t("Participant") }}
|
|
|
|
</b-tag>
|
|
|
|
<b-tag type="is-warning" v-else-if="props.row.role === ParticipantRole.NOT_APPROVED">
|
|
|
|
{{ $t("Not approved") }}
|
|
|
|
</b-tag>
|
|
|
|
<b-tag type="is-danger" v-else-if="props.row.role === ParticipantRole.REJECTED">
|
|
|
|
{{ $t("Rejected") }}
|
|
|
|
</b-tag>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="metadata.message" :label="$t('Message')" v-slot="props">
|
|
|
|
<span
|
|
|
|
@click="toggleQueueDetails(props.row)"
|
|
|
|
:class="{
|
|
|
|
'ellipsed-message': props.row.metadata.message.length > MESSAGE_ELLIPSIS_LENGTH,
|
|
|
|
}"
|
|
|
|
v-if="props.row.metadata && props.row.metadata.message"
|
|
|
|
>
|
|
|
|
{{ props.row.metadata.message | ellipsize }}
|
|
|
|
</span>
|
|
|
|
<span v-else class="has-text-grey">
|
|
|
|
{{ $t("No message") }}
|
|
|
|
</span>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="insertedAt" :label="$t('Date')" v-slot="props">
|
|
|
|
<span class="has-text-centered">
|
|
|
|
{{ props.row.insertedAt | formatDateString }}<br />{{
|
|
|
|
props.row.insertedAt | formatTimeString
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</b-table-column>
|
2020-06-18 13:23:05 +00:00
|
|
|
<template slot="detail" slot-scope="props">
|
|
|
|
<article v-html="nl2br(props.row.metadata.message)" />
|
2020-02-18 07:57:00 +00:00
|
|
|
</template>
|
2020-06-18 13:23:05 +00:00
|
|
|
<template slot="empty">
|
|
|
|
<section class="section">
|
|
|
|
<div class="content has-text-grey has-text-centered">
|
|
|
|
<p>{{ $t("No participant matches the filters") }}</p>
|
|
|
|
</div>
|
2020-02-18 07:57:00 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
2020-06-18 13:23:05 +00:00
|
|
|
<template slot="bottom-left">
|
|
|
|
<div class="buttons">
|
|
|
|
<b-button
|
|
|
|
@click="acceptParticipants(checkedRows)"
|
|
|
|
type="is-success"
|
|
|
|
:disabled="!canAcceptParticipants"
|
|
|
|
>
|
|
|
|
{{
|
|
|
|
$tc(
|
|
|
|
"No participant to approve|Approve participant|Approve {number} participants",
|
|
|
|
checkedRows.length,
|
|
|
|
{ number: checkedRows.length }
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</b-button>
|
|
|
|
<b-button
|
|
|
|
@click="refuseParticipants(checkedRows)"
|
|
|
|
type="is-danger"
|
|
|
|
:disabled="!canRefuseParticipants"
|
|
|
|
>
|
|
|
|
{{
|
|
|
|
$tc(
|
|
|
|
"No participant to reject|Reject participant|Reject {number} participants",
|
|
|
|
checkedRows.length,
|
|
|
|
{ number: checkedRows.length }
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</b-button>
|
|
|
|
</div>
|
2020-02-18 07:57:00 +00:00
|
|
|
</template>
|
2020-06-18 13:23:05 +00:00
|
|
|
</b-table>
|
|
|
|
</section>
|
2020-02-18 07:57:00 +00:00
|
|
|
</main>
|
2019-09-20 16:22:03 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-06-18 13:23:05 +00:00
|
|
|
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
|
2020-07-09 15:24:28 +00:00
|
|
|
import { DataProxy } from "apollo-cache";
|
2020-02-18 07:57:00 +00:00
|
|
|
import {
|
|
|
|
IEvent,
|
|
|
|
IEventParticipantStats,
|
|
|
|
IParticipant,
|
|
|
|
Participant,
|
|
|
|
ParticipantRole,
|
|
|
|
} from "../../types/event.model";
|
|
|
|
import { PARTICIPANTS, UPDATE_PARTICIPANT } from "../../graphql/event";
|
|
|
|
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
|
2020-07-09 15:24:28 +00:00
|
|
|
import { IPerson, usernameWithDomain } from "../../types/actor";
|
2020-02-18 07:57:00 +00:00
|
|
|
import { CONFIG } from "../../graphql/config";
|
|
|
|
import { IConfig } from "../../types/config.model";
|
|
|
|
import { Paginate } from "../../types/paginate";
|
2020-06-18 13:23:05 +00:00
|
|
|
import { nl2br } from "../../utils/html";
|
|
|
|
import { asyncForEach } from "../../utils/asyncForEach";
|
|
|
|
import RouteName from "../../router/name";
|
2020-03-05 18:32:34 +00:00
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
const PARTICIPANTS_PER_PAGE = 10;
|
2020-03-05 18:32:34 +00:00
|
|
|
const MESSAGE_ELLIPSIS_LENGTH = 130;
|
2019-09-20 16:22:03 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
currentActor: {
|
|
|
|
query: CURRENT_ACTOR_CLIENT,
|
|
|
|
},
|
2019-12-20 12:04:34 +00:00
|
|
|
config: CONFIG,
|
2019-09-20 16:22:03 +00:00
|
|
|
event: {
|
|
|
|
query: PARTICIPANTS,
|
2020-06-18 13:23:05 +00:00
|
|
|
fetchPolicy: "network-only",
|
2019-09-20 16:22:03 +00:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
uuid: this.eventId,
|
|
|
|
page: 1,
|
2020-03-05 18:32:34 +00:00
|
|
|
limit: PARTICIPANTS_PER_PAGE,
|
2020-06-18 13:23:05 +00:00
|
|
|
roles: this.roles,
|
2019-09-30 11:48:47 +00:00
|
|
|
actorId: this.currentActor.id,
|
|
|
|
};
|
|
|
|
},
|
2019-10-13 11:56:24 +00:00
|
|
|
skip() {
|
|
|
|
return !this.currentActor.id;
|
|
|
|
},
|
2019-09-30 11:48:47 +00:00
|
|
|
},
|
2019-09-20 16:22:03 +00:00
|
|
|
},
|
2020-03-05 18:32:34 +00:00
|
|
|
filters: {
|
2020-02-18 07:57:00 +00:00
|
|
|
ellipsize: (text?: string) => text && text.substr(0, MESSAGE_ELLIPSIS_LENGTH).concat("…"),
|
2020-03-05 18:32:34 +00:00
|
|
|
},
|
2019-09-20 16:22:03 +00:00
|
|
|
})
|
|
|
|
export default class Participants extends Vue {
|
|
|
|
@Prop({ required: true }) eventId!: string;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
|
|
page = 1;
|
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
limit = PARTICIPANTS_PER_PAGE;
|
2020-03-05 18:32:34 +00:00
|
|
|
|
2019-09-20 16:22:03 +00:00
|
|
|
event!: IEvent;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
config!: IConfig;
|
2019-09-20 16:22:03 +00:00
|
|
|
|
|
|
|
ParticipantRole = ParticipantRole;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2019-09-20 16:22:03 +00:00
|
|
|
currentActor!: IPerson;
|
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
PARTICIPANTS_PER_PAGE = PARTICIPANTS_PER_PAGE;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
checkedRows: IParticipant[] = [];
|
2019-09-20 16:22:03 +00:00
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
roles: ParticipantRole = ParticipantRole.PARTICIPANT;
|
|
|
|
|
|
|
|
RouteName = RouteName;
|
2019-09-20 16:22:03 +00:00
|
|
|
|
2020-07-09 15:24:28 +00:00
|
|
|
usernameWithDomain = usernameWithDomain;
|
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
@Ref("queueTable") readonly queueTable!: any;
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
const roleQuery = this.$route.query.role as string;
|
|
|
|
if (Object.values(ParticipantRole).includes(roleQuery as ParticipantRole)) {
|
|
|
|
this.roles = roleQuery as ParticipantRole;
|
|
|
|
}
|
2019-09-20 16:22:03 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 18:32:34 +00:00
|
|
|
get participantStats(): IEventParticipantStats | null {
|
|
|
|
if (!this.event) return null;
|
|
|
|
return this.event.participantStats;
|
2019-12-20 12:04:34 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
@Watch("page")
|
2019-09-20 16:22:03 +00:00
|
|
|
loadMoreParticipants() {
|
2020-06-18 13:23:05 +00:00
|
|
|
this.$apollo.queries.event.fetchMore({
|
2019-09-20 16:22:03 +00:00
|
|
|
// New variables
|
|
|
|
variables: {
|
|
|
|
page: this.page,
|
|
|
|
limit: this.limit,
|
|
|
|
},
|
|
|
|
// Transform the previous result with new data
|
|
|
|
updateQuery: (previousResult, { fetchMoreResult }) => {
|
2020-06-18 13:23:05 +00:00
|
|
|
const oldParticipants = previousResult.event.participants;
|
|
|
|
const newParticipants = fetchMoreResult.event.participants;
|
2019-09-20 16:22:03 +00:00
|
|
|
|
|
|
|
return {
|
2020-06-18 13:23:05 +00:00
|
|
|
event: {
|
|
|
|
...previousResult.event,
|
|
|
|
participants: {
|
|
|
|
elements: [...oldParticipants.elements, ...newParticipants.elements],
|
|
|
|
total: newParticipants.total,
|
|
|
|
__typename: oldParticipants.__typename,
|
|
|
|
},
|
2019-09-20 16:22:03 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async acceptParticipant(participant: IParticipant) {
|
|
|
|
try {
|
|
|
|
const { data } = await this.$apollo.mutate({
|
2019-09-30 11:48:47 +00:00
|
|
|
mutation: UPDATE_PARTICIPANT,
|
2019-09-20 16:22:03 +00:00
|
|
|
variables: {
|
|
|
|
id: participant.id,
|
|
|
|
moderatorActorId: this.currentActor.id,
|
2019-09-30 11:48:47 +00:00
|
|
|
role: ParticipantRole.PARTICIPANT,
|
2019-09-20 16:22:03 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async refuseParticipant(participant: IParticipant) {
|
|
|
|
try {
|
|
|
|
const { data } = await this.$apollo.mutate({
|
2019-09-30 11:48:47 +00:00
|
|
|
mutation: UPDATE_PARTICIPANT,
|
2019-09-20 16:22:03 +00:00
|
|
|
variables: {
|
|
|
|
id: participant.id,
|
|
|
|
moderatorActorId: this.currentActor.id,
|
2019-09-30 11:48:47 +00:00
|
|
|
role: ParticipantRole.REJECTED,
|
2019-09-20 16:22:03 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 13:23:05 +00:00
|
|
|
|
|
|
|
async acceptParticipants(participants: IParticipant[]) {
|
|
|
|
await asyncForEach(participants, async (participant: IParticipant) => {
|
|
|
|
await this.acceptParticipant(participant);
|
|
|
|
});
|
|
|
|
this.checkedRows = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
async refuseParticipants(participants: IParticipant[]) {
|
|
|
|
await asyncForEach(participants, async (participant: IParticipant) => {
|
|
|
|
await this.refuseParticipant(participant);
|
|
|
|
});
|
|
|
|
this.checkedRows = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We can accept participants if at least one of them is not approved
|
|
|
|
*/
|
|
|
|
get canAcceptParticipants(): boolean {
|
|
|
|
return this.checkedRows.some((participant: IParticipant) =>
|
|
|
|
[ParticipantRole.NOT_APPROVED, ParticipantRole.REJECTED].includes(participant.role)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We can refuse participants if at least one of them is something different than not approved
|
|
|
|
*/
|
|
|
|
get canRefuseParticipants(): boolean {
|
|
|
|
return this.checkedRows.some(
|
|
|
|
(participant: IParticipant) => participant.role !== ParticipantRole.REJECTED
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
MESSAGE_ELLIPSIS_LENGTH = MESSAGE_ELLIPSIS_LENGTH;
|
|
|
|
|
|
|
|
nl2br = nl2br;
|
|
|
|
|
|
|
|
toggleQueueDetails(row: IParticipant) {
|
|
|
|
if (row.metadata.message && row.metadata.message.length < MESSAGE_ELLIPSIS_LENGTH) return;
|
|
|
|
this.queueTable.toggleDetails(row);
|
|
|
|
}
|
2019-09-20 16:22:03 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
|
|
<style lang="scss" scoped>
|
2020-06-18 13:23:05 +00:00
|
|
|
@import "../../variables.scss";
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
section {
|
|
|
|
padding: 1rem 0;
|
|
|
|
}
|
2020-06-17 13:54:24 +00:00
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
.table {
|
|
|
|
.ellipsed-message {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
span.tag {
|
|
|
|
&.is-primary {
|
|
|
|
background-color: $primary;
|
|
|
|
}
|
2020-06-17 13:54:24 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2019-10-09 15:03:35 +00:00
|
|
|
|
2020-06-18 13:23:05 +00:00
|
|
|
nav.breadcrumb {
|
|
|
|
a {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2019-10-09 15:03:35 +00:00
|
|
|
</style>
|