Clearer logic whether to show or not the participation button

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-12-01 12:33:58 +01:00
parent a76917b8e1
commit 4b021f50e5
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -110,15 +110,7 @@
v-if="new Date(endDate) > new Date()"
>
<participation-button
v-if="
anonymousParticipation === null &&
(config.anonymous.participation.allowed ||
(currentActor.id &&
!actorIsOrganizer &&
!event.draft &&
(eventCapacityOK || actorIsParticipant) &&
event.status !== EventStatus.CANCELLED))
"
v-if="shouldShowParticipationButton"
:participation="participations[0]"
:event="event"
:current-actor="currentActor"
@ -1206,6 +1198,29 @@ export default class Event extends EventMixin {
}
return null;
}
get shouldShowParticipationButton(): boolean {
// So that people can cancel their participation
if (
this.actorIsParticipant ||
(this.config.anonymous.participation.allowed &&
this.anonymousParticipation)
)
return true;
// You can participate to draft or cancelled events
if (this.event.draft || this.event.status === EventStatus.CANCELLED)
return false;
// Organizer can't participate
if (this.actorIsOrganizer) return false;
// If capacity is OK
if (this.eventCapacityOK) return true;
// Else
return false;
}
}
</script>
<style lang="scss" scoped>