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
1 changed files with 24 additions and 9 deletions

View File

@ -110,15 +110,7 @@
v-if="new Date(endDate) > new Date()" v-if="new Date(endDate) > new Date()"
> >
<participation-button <participation-button
v-if=" v-if="shouldShowParticipationButton"
anonymousParticipation === null &&
(config.anonymous.participation.allowed ||
(currentActor.id &&
!actorIsOrganizer &&
!event.draft &&
(eventCapacityOK || actorIsParticipant) &&
event.status !== EventStatus.CANCELLED))
"
:participation="participations[0]" :participation="participations[0]"
:event="event" :event="event"
:current-actor="currentActor" :current-actor="currentActor"
@ -1206,6 +1198,29 @@ export default class Event extends EventMixin {
} }
return null; 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>