Merge branch 'allilengyi/mobilizon-issue912' into 'main'

Set default event visibility from group privacy setting

Closes #912

See merge request framasoft/mobilizon!1197
This commit is contained in:
Thomas Citharel 2022-04-01 13:13:23 +00:00
commit 7c770dd59c

View file

@ -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);