2020-09-29 09:53:48 +02:00
|
|
|
<template>
|
|
|
|
<div class="list is-hoverable">
|
|
|
|
<b-radio-button
|
2021-03-29 10:33:19 +02:00
|
|
|
v-model="selectedActor"
|
2020-09-29 09:53:48 +02:00
|
|
|
:native-value="availableActor"
|
|
|
|
class="list-item"
|
|
|
|
v-for="availableActor in actualAvailableActors"
|
2021-03-29 10:33:19 +02:00
|
|
|
:class="{ 'is-active': availableActor.id === selectedActor.id }"
|
2020-09-29 09:53:48 +02:00
|
|
|
:key="availableActor.id"
|
|
|
|
>
|
|
|
|
<div class="media">
|
|
|
|
<figure class="image is-48x48" v-if="availableActor.avatar">
|
2020-11-30 10:24:11 +01:00
|
|
|
<img
|
|
|
|
class="media-left is-rounded"
|
|
|
|
:src="availableActor.avatar.url"
|
|
|
|
alt=""
|
|
|
|
/>
|
2020-09-29 09:53:48 +02:00
|
|
|
</figure>
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-icon
|
|
|
|
class="media-left"
|
|
|
|
v-else
|
|
|
|
size="is-large"
|
|
|
|
icon="account-circle"
|
|
|
|
/>
|
2020-09-29 09:53:48 +02:00
|
|
|
<div class="media-content">
|
|
|
|
<h3>{{ availableActor.name }}</h3>
|
|
|
|
<small>{{ `@${availableActor.preferredUsername}` }}</small>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-radio-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2021-03-29 10:33:19 +02:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { IPerson, IActor, Actor } from "@/types/actor";
|
2021-03-29 10:33:19 +02:00
|
|
|
import {
|
|
|
|
CURRENT_ACTOR_CLIENT,
|
|
|
|
IDENTITIES,
|
|
|
|
LOGGED_USER_MEMBERSHIPS,
|
|
|
|
} from "@/graphql/actor";
|
2020-09-29 09:53:48 +02:00
|
|
|
import { Paginate } from "@/types/paginate";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { IMember } from "@/types/actor/member.model";
|
|
|
|
import { MemberRole } from "@/types/enums";
|
2020-09-29 09:53:48 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
groupMemberships: {
|
2021-03-29 10:33:19 +02:00
|
|
|
query: LOGGED_USER_MEMBERSHIPS,
|
|
|
|
update: (data) => data.loggedUser.memberships,
|
2020-09-29 09:53:48 +02:00
|
|
|
},
|
2021-03-29 10:33:19 +02:00
|
|
|
identities: IDENTITIES,
|
|
|
|
currentActor: CURRENT_ACTOR_CLIENT,
|
2020-09-29 09:53:48 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class OrganizerPicker extends Vue {
|
|
|
|
@Prop() value!: IActor;
|
|
|
|
|
|
|
|
@Prop({ required: false, default: false }) restrictModeratorLevel!: boolean;
|
|
|
|
|
|
|
|
groupMemberships: Paginate<IMember> = { elements: [], total: 0 };
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
currentActor!: IPerson;
|
|
|
|
|
|
|
|
get selectedActor(): IActor | undefined {
|
|
|
|
if (this.value?.id) {
|
|
|
|
return this.value;
|
|
|
|
}
|
|
|
|
if (this.currentActor) {
|
2021-06-10 10:33:16 +02:00
|
|
|
return this.identities.find(
|
|
|
|
(identity) => identity.id === this.currentActor.id
|
|
|
|
);
|
2021-03-29 10:33:19 +02:00
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
set selectedActor(actor: IActor | undefined) {
|
|
|
|
this.$emit("input", actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
identities: IActor[] = [];
|
2020-09-29 09:53:48 +02:00
|
|
|
|
|
|
|
Actor = Actor;
|
|
|
|
|
|
|
|
get actualMemberships(): IMember[] {
|
|
|
|
if (this.restrictModeratorLevel) {
|
|
|
|
return this.groupMemberships.elements.filter((membership: IMember) =>
|
2020-11-30 10:24:11 +01:00
|
|
|
[
|
|
|
|
MemberRole.ADMINISTRATOR,
|
|
|
|
MemberRole.MODERATOR,
|
|
|
|
MemberRole.CREATOR,
|
|
|
|
].includes(membership.role)
|
2020-09-29 09:53:48 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return this.groupMemberships.elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
get actualAvailableActors(): IActor[] {
|
2020-11-30 10:24:11 +01:00
|
|
|
return [
|
2021-03-29 10:33:19 +02:00
|
|
|
this.currentActor,
|
|
|
|
...this.identities.filter(
|
|
|
|
(identity: IActor) => identity.id !== this.currentActor?.id
|
|
|
|
),
|
2020-11-30 10:24:11 +01:00
|
|
|
...this.actualMemberships.map((member) => member.parent),
|
2021-03-29 10:33:19 +02:00
|
|
|
].filter((elem) => elem);
|
2020-09-29 09:53:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2020-11-16 10:04:47 +01:00
|
|
|
::v-deep .list-item {
|
2020-09-29 09:53:48 +02:00
|
|
|
box-sizing: content-box;
|
|
|
|
|
|
|
|
label.b-radio {
|
|
|
|
padding: 0.85rem 0;
|
|
|
|
|
|
|
|
.media {
|
|
|
|
padding: 0.25rem 0;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
figure.image,
|
|
|
|
span.icon.media-left {
|
|
|
|
margin-right: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
span.icon.media-left {
|
|
|
|
margin-left: -0.25rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|