From a407a56051f4b77a4bec7bd63bb939865ad6d5ba Mon Sep 17 00:00:00 2001 From: allilengyi Date: Mon, 21 Feb 2022 20:26:43 +0100 Subject: [PATCH] Set default event visibility from group privacy setting Closes #912 --- js/src/views/Event/Edit.vue | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/js/src/views/Event/Edit.vue b/js/src/views/Event/Edit.vue index aebe18e02..2240edf27 100644 --- a/js/src/views/Event/Edit.vue +++ b/js/src/views/Event/Edit.vue @@ -616,6 +616,7 @@ import { EventJoinOptions, EventStatus, EventVisibility, + GroupVisibility, MemberRole, ParticipantRole, } from "@/types/enums"; @@ -639,6 +640,7 @@ import { LOGGED_USER_DRAFTS, PERSON_STATUS_GROUP, } from "../../graphql/actor"; +import { FETCH_GROUP } from "../../graphql/group"; import { displayNameAndUsername, IActor, @@ -719,6 +721,21 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10; ); }, }, + group: { + query: FETCH_GROUP, + fetchPolicy: "cache-and-network", + variables() { + return { + name: this.event?.attributedTo?.preferredUsername, + }; + }, + skip() { + return ( + !this.event?.attributedTo || + !this.event?.attributedTo?.preferredUsername + ); + }, + }, }, metaInfo() { return { @@ -737,6 +754,8 @@ export default class EditEvent extends Vue { @Prop({ type: Boolean, default: false }) isDuplicate!: boolean; + group!: IGroup; + currentActor!: IActor; loggedUser!: IUser; @@ -782,6 +801,16 @@ export default class EditEvent extends Vue { } } + @Watch("group") + updateEventVisibility(group: IGroup): void { + if (!this.isUpdate && group.visibility == GroupVisibility.UNLISTED) { + this.event.visibility = EventVisibility.UNLISTED; + } + if (!this.isUpdate && group.visibility == GroupVisibility.PUBLIC) { + this.event.visibility = EventVisibility.PUBLIC; + } + } + private initializeEvent() { const roundUpTo15Minutes = (time: Date) => { time.setMilliseconds(Math.round(time.getMilliseconds() / 1000) * 1000);