[Front-end] Allow remote moderators to edit group events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
53dc3f470b
commit
961f08e27f
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<section>
|
<section>
|
||||||
<div class="container" v-if="isCurrentActorOrganizer">
|
<div class="container" v-if="hasCurrentActorPermissionsToEdit">
|
||||||
<h1 class="title" v-if="isUpdate === true">
|
<h1 class="title" v-if="isUpdate === true">
|
||||||
{{ $t("Update event {name}", { name: event.title }) }}
|
{{ $t("Update event {name}", { name: event.title }) }}
|
||||||
</h1>
|
</h1>
|
||||||
@ -269,6 +269,11 @@
|
|||||||
</b-field>
|
</b-field>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container section" v-else>
|
||||||
|
<b-message type="is-danger">
|
||||||
|
{{ $t("Only group moderators can create, edit and delete events.") }}
|
||||||
|
</b-message>
|
||||||
|
</div>
|
||||||
<b-modal v-model="dateSettingsIsOpen" has-modal-card trap-focus>
|
<b-modal v-model="dateSettingsIsOpen" has-modal-card trap-focus>
|
||||||
<form action>
|
<form action>
|
||||||
<div class="modal-card" style="width: auto">
|
<div class="modal-card" style="width: auto">
|
||||||
@ -305,7 +310,7 @@
|
|||||||
aria-label="main navigation"
|
aria-label="main navigation"
|
||||||
class="navbar save__navbar"
|
class="navbar save__navbar"
|
||||||
:class="{ 'is-fixed-bottom': showFixedNavbar }"
|
:class="{ 'is-fixed-bottom': showFixedNavbar }"
|
||||||
v-if="isCurrentActorOrganizer"
|
v-if="hasCurrentActorPermissionsToEdit"
|
||||||
>
|
>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="navbar-menu">
|
<div class="navbar-menu">
|
||||||
@ -457,6 +462,7 @@ import {
|
|||||||
EventJoinOptions,
|
EventJoinOptions,
|
||||||
EventStatus,
|
EventStatus,
|
||||||
EventVisibility,
|
EventVisibility,
|
||||||
|
MemberRole,
|
||||||
ParticipantRole,
|
ParticipantRole,
|
||||||
} from "@/types/enums";
|
} from "@/types/enums";
|
||||||
import OrganizerPickerWrapper from "../../components/Event/OrganizerPickerWrapper.vue";
|
import OrganizerPickerWrapper from "../../components/Event/OrganizerPickerWrapper.vue";
|
||||||
@ -472,8 +478,15 @@ import {
|
|||||||
IDENTITIES,
|
IDENTITIES,
|
||||||
LOGGED_USER_DRAFTS,
|
LOGGED_USER_DRAFTS,
|
||||||
LOGGED_USER_PARTICIPATIONS,
|
LOGGED_USER_PARTICIPATIONS,
|
||||||
|
PERSON_MEMBERSHIP_GROUP,
|
||||||
} from "../../graphql/actor";
|
} from "../../graphql/actor";
|
||||||
import { displayNameAndUsername, IActor, IGroup } from "../../types/actor";
|
import {
|
||||||
|
displayNameAndUsername,
|
||||||
|
IActor,
|
||||||
|
IGroup,
|
||||||
|
IPerson,
|
||||||
|
usernameWithDomain,
|
||||||
|
} from "../../types/actor";
|
||||||
import { TAGS } from "../../graphql/tags";
|
import { TAGS } from "../../graphql/tags";
|
||||||
import { ITag } from "../../types/tag.model";
|
import { ITag } from "../../types/tag.model";
|
||||||
import {
|
import {
|
||||||
@ -519,6 +532,22 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
|||||||
return !this.eventId;
|
return !this.eventId;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
person: {
|
||||||
|
query: PERSON_MEMBERSHIP_GROUP,
|
||||||
|
fetchPolicy: "cache-and-network",
|
||||||
|
variables() {
|
||||||
|
return {
|
||||||
|
id: this.currentActor.id,
|
||||||
|
group: usernameWithDomain(this.event?.attributedTo),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
skip() {
|
||||||
|
return (
|
||||||
|
!this.event?.attributedTo ||
|
||||||
|
!this.event?.attributedTo?.preferredUsername
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
metaInfo() {
|
metaInfo() {
|
||||||
return {
|
return {
|
||||||
@ -545,6 +574,8 @@ export default class EditEvent extends Vue {
|
|||||||
|
|
||||||
identities: IActor[] = [];
|
identities: IActor[] = [];
|
||||||
|
|
||||||
|
person!: IPerson;
|
||||||
|
|
||||||
config!: IConfig;
|
config!: IConfig;
|
||||||
|
|
||||||
pictureFile: File | null = null;
|
pictureFile: File | null = null;
|
||||||
@ -749,13 +780,23 @@ export default class EditEvent extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCurrentActorOrganizer(): boolean {
|
get hasCurrentActorPermissionsToEdit(): boolean {
|
||||||
return !(
|
return !(
|
||||||
this.eventId &&
|
this.eventId &&
|
||||||
this.event.organizerActor?.id !== undefined &&
|
this.event.organizerActor?.id !== undefined &&
|
||||||
!this.identities
|
!this.identities
|
||||||
.map(({ id }) => id)
|
.map(({ id }) => id)
|
||||||
.includes(this.event.organizerActor?.id)
|
.includes(this.event.organizerActor?.id) &&
|
||||||
|
!this.hasGroupPrivileges
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasGroupPrivileges(): boolean {
|
||||||
|
return (
|
||||||
|
this.person?.memberships?.total > 0 &&
|
||||||
|
[MemberRole.MODERATOR, MemberRole.ADMINISTRATOR].includes(
|
||||||
|
this.person?.memberships?.elements[0].role
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user