2020-03-05 19:32:34 +01:00
|
|
|
import {EventJoinOptions} from "@/types/event.model";
|
2019-10-05 21:17:18 +02:00
|
|
|
<docs>
|
|
|
|
A button to set your participation
|
|
|
|
|
|
|
|
##### If the participant has been confirmed
|
|
|
|
```vue
|
|
|
|
<ParticipationButton :participation="{ role: 'PARTICIPANT' }" :currentActor="{ preferredUsername: 'test', avatar: { url: 'https://huit.re/EPX7vs1j' } }" />
|
|
|
|
```
|
|
|
|
|
|
|
|
##### If the participant has not being approved yet
|
|
|
|
```vue
|
|
|
|
<ParticipationButton :participation="{ role: 'NOT_APPROVED' }" :currentActor="{ preferredUsername: 'test', avatar: { url: 'https://huit.re/EPX7vs1j' } }" />
|
|
|
|
```
|
|
|
|
|
|
|
|
##### If the participant has been rejected
|
|
|
|
```vue
|
|
|
|
<ParticipationButton :participation="{ role: 'REJECTED' }" :currentActor="{ preferredUsername: 'test', avatar: { url: 'https://huit.re/EPX7vs1j' } }" />
|
|
|
|
```
|
|
|
|
|
|
|
|
##### If the participant doesn't exist yet
|
|
|
|
```vue
|
|
|
|
<ParticipationButton :participation="null" :currentActor="{ preferredUsername: 'test', avatar: { url: 'https://huit.re/EPX7vs1j' } }" />
|
|
|
|
```
|
|
|
|
</docs>
|
|
|
|
|
2019-09-26 16:38:58 +02:00
|
|
|
<template>
|
|
|
|
<div class="participation-button">
|
|
|
|
<b-dropdown aria-role="list" position="is-bottom-left" v-if="participation && participation.role === ParticipantRole.PARTICIPANT">
|
2019-12-20 13:04:34 +01:00
|
|
|
<button class="button is-success is-large" type="button" slot="trigger">
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-icon icon="check" />
|
2019-09-26 16:38:58 +02:00
|
|
|
<template>
|
|
|
|
<span>{{ $t('I participate') }}</span>
|
|
|
|
</template>
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-icon icon="menu-down" />
|
2019-09-26 16:38:58 +02:00
|
|
|
</button>
|
|
|
|
|
2019-09-30 13:48:47 +02:00
|
|
|
<b-dropdown-item :value="false" aria-role="listitem" @click="confirmLeave" class="has-text-danger">
|
2019-09-26 16:38:58 +02:00
|
|
|
{{ $t('Cancel my participation…')}}
|
|
|
|
</b-dropdown-item>
|
|
|
|
</b-dropdown>
|
|
|
|
|
|
|
|
<div v-else-if="participation && participation.role === ParticipantRole.NOT_APPROVED">
|
|
|
|
<b-dropdown aria-role="list" position="is-bottom-left" class="dropdown-disabled">
|
2019-12-20 13:04:34 +01:00
|
|
|
<button class="button is-success is-large" type="button" slot="trigger">
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-icon icon="timer-sand-empty" />
|
2019-09-26 16:38:58 +02:00
|
|
|
<template>
|
|
|
|
<span>{{ $t('I participate') }}</span>
|
|
|
|
</template>
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-icon icon="menu-down" />
|
2019-09-26 16:38:58 +02:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<!-- <b-dropdown-item :value="false" aria-role="listitem">-->
|
|
|
|
<!-- {{ $t('Change my identity…')}}-->
|
|
|
|
<!-- </b-dropdown-item>-->
|
|
|
|
|
2019-09-30 13:48:47 +02:00
|
|
|
<b-dropdown-item :value="false" aria-role="listitem" @click="confirmLeave" class="has-text-danger">
|
2019-09-26 16:38:58 +02:00
|
|
|
{{ $t('Cancel my participation request…')}}
|
|
|
|
</b-dropdown-item>
|
|
|
|
</b-dropdown>
|
|
|
|
<small>{{ $t('Participation requested!')}}</small><br />
|
|
|
|
<small>{{ $t('Waiting for organization team approval.')}}</small>
|
|
|
|
</div>
|
|
|
|
|
2019-09-30 13:48:47 +02:00
|
|
|
<div v-else-if="participation && participation.role === ParticipantRole.REJECTED">
|
|
|
|
<span>{{ $t('Unfortunately, your participation request was rejected by the organizers.')}}</span>
|
|
|
|
</div>
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-dropdown aria-role="list" position="is-bottom-left" v-else-if="!participation && currentActor.id">
|
|
|
|
<button class="button is-primary is-large" type="button" slot="trigger">
|
2019-09-26 16:38:58 +02:00
|
|
|
<template>
|
|
|
|
<span>{{ $t('Participate') }}</span>
|
|
|
|
</template>
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-icon icon="menu-down" />
|
2019-09-26 16:38:58 +02:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<b-dropdown-item :value="true" aria-role="listitem" @click="joinEvent(currentActor)">
|
|
|
|
<div class="media">
|
|
|
|
<div class="media-left">
|
|
|
|
<figure class="image is-32x32" v-if="currentActor.avatar">
|
|
|
|
<img class="is-rounded" :src="currentActor.avatar.url" alt="" />
|
|
|
|
</figure>
|
|
|
|
</div>
|
|
|
|
<div class="media-content">
|
2020-03-05 19:32:34 +01:00
|
|
|
<span>{{ $t('as {identity}', {identity: currentActor.name || `@${currentActor.preferredUsername}` }) }}</span>
|
2019-09-26 16:38:58 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-dropdown-item>
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
<b-dropdown-item :value="false" aria-role="listitem" @click="joinModal" v-if="identities.length > 1">
|
2019-09-26 16:38:58 +02:00
|
|
|
{{ $t('with another identity…')}}
|
|
|
|
</b-dropdown-item>
|
|
|
|
</b-dropdown>
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-button tag="router-link" :to="{ name: RouteName.EVENT_PARTICIPATE_LOGGED_OUT, params: { uuid: event.uuid } }" v-else-if="!participation && hasAnonymousParticipationMethods" type="is-primary" size="is-large" native-type="button">{{ $t('Participate') }}</b-button>
|
|
|
|
<b-button tag="router-link" :to="{ name: RouteName.EVENT_PARTICIPATE_WITH_ACCOUNT, params: { uuid: event.uuid } }" v-else-if="!currentActor.id" type="is-primary" size="is-large" native-type="button">{{ $t('Participate') }}</b-button>
|
2019-09-26 16:38:58 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
2020-03-05 19:32:34 +01:00
|
|
|
import { EventJoinOptions, IEvent, IParticipant, ParticipantRole } from '@/types/event.model';
|
2019-12-03 11:29:51 +01:00
|
|
|
import { IPerson, Person } from '@/types/actor';
|
2019-12-20 13:04:34 +01:00
|
|
|
import { CURRENT_ACTOR_CLIENT, IDENTITIES } from '@/graphql/actor';
|
2019-12-03 11:29:51 +01:00
|
|
|
import { CURRENT_USER_CLIENT } from '@/graphql/user';
|
2019-12-20 13:04:34 +01:00
|
|
|
import { CONFIG } from '@/graphql/config';
|
|
|
|
import { IConfig } from '@/types/config.model';
|
|
|
|
import { RouteName } from '@/router';
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
currentUser: {
|
|
|
|
query: CURRENT_USER_CLIENT,
|
|
|
|
},
|
2019-12-20 13:04:34 +01:00
|
|
|
currentActor: CURRENT_ACTOR_CLIENT,
|
|
|
|
config: CONFIG,
|
2019-12-03 11:29:51 +01:00
|
|
|
identities: {
|
|
|
|
query: IDENTITIES,
|
|
|
|
update: ({ identities }) => identities ? identities.map(identity => new Person(identity)) : [],
|
|
|
|
skip() {
|
|
|
|
return this.currentUser.isLoggedIn === false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2019-09-26 16:38:58 +02:00
|
|
|
export default class ParticipationButton extends Vue {
|
|
|
|
@Prop({ required: true }) participation!: IParticipant;
|
2019-12-20 13:04:34 +01:00
|
|
|
@Prop({ required: true }) event!: IEvent;
|
2019-09-26 16:38:58 +02:00
|
|
|
@Prop({ required: true }) currentActor!: IPerson;
|
|
|
|
|
|
|
|
ParticipantRole = ParticipantRole;
|
2019-12-03 11:29:51 +01:00
|
|
|
identities: IPerson[] = [];
|
2019-12-20 13:04:34 +01:00
|
|
|
config!: IConfig;
|
|
|
|
RouteName = RouteName;
|
2019-09-26 16:38:58 +02:00
|
|
|
|
|
|
|
joinEvent(actor: IPerson) {
|
2020-03-05 19:32:34 +01:00
|
|
|
if (this.event.joinOptions === EventJoinOptions.RESTRICTED) {
|
|
|
|
this.$emit('joinEventWithConfirmation', actor);
|
|
|
|
} else {
|
|
|
|
this.$emit('joinEvent', actor);
|
|
|
|
}
|
2019-09-26 16:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
joinModal() {
|
|
|
|
this.$emit('joinModal');
|
|
|
|
}
|
|
|
|
|
|
|
|
confirmLeave() {
|
|
|
|
this.$emit('confirmLeave');
|
|
|
|
}
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
get hasAnonymousParticipationMethods(): boolean {
|
|
|
|
return this.event.options.anonymousParticipation;
|
|
|
|
}
|
2019-09-26 16:38:58 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<style lang="scss" scoped>
|
2019-09-26 16:38:58 +02:00
|
|
|
.participation-button {
|
|
|
|
.dropdown {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
|
|
&.dropdown-disabled button {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
2019-09-26 16:38:58 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
.anonymousParticipationModal {
|
|
|
|
/deep/ .animation-content {
|
|
|
|
z-index: 1;
|
2019-09-26 16:38:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|