2020-09-29 09:53:48 +02:00
|
|
|
<template>
|
|
|
|
<div class="list is-hoverable">
|
2021-08-11 12:43:54 +02:00
|
|
|
<b-input
|
2021-11-07 21:02:06 +01:00
|
|
|
dir="auto"
|
2021-08-11 12:43:54 +02:00
|
|
|
:placeholder="$t('Filter by profile or group name')"
|
|
|
|
v-model="actorFilter"
|
|
|
|
/>
|
2022-04-03 22:13:06 +02:00
|
|
|
<transition-group
|
|
|
|
tag="ul"
|
|
|
|
class="grid grid-cols-1 gap-y-3 m-5 max-w-md mx-auto"
|
|
|
|
enter-active-class="duration-300 ease-out"
|
|
|
|
enter-from-class="transform opacity-0"
|
|
|
|
enter-to-class="opacity-100"
|
|
|
|
leave-active-class="duration-200 ease-in"
|
|
|
|
leave-from-class="opacity-100"
|
|
|
|
leave-to-class="transform opacity-0"
|
2020-09-29 09:53:48 +02:00
|
|
|
>
|
2022-04-03 22:13:06 +02:00
|
|
|
<li
|
|
|
|
class="relative focus-within:shadow-lg"
|
|
|
|
v-for="availableActor in actualFilteredAvailableActors"
|
|
|
|
:key="availableActor.id"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
class="sr-only peer"
|
|
|
|
type="radio"
|
|
|
|
:value="availableActor"
|
|
|
|
name="availableActors"
|
|
|
|
v-model="selectedActor"
|
|
|
|
:id="`availableActor-${availableActor.id}`"
|
2020-11-30 10:24:11 +01:00
|
|
|
/>
|
2022-04-03 22:13:06 +02:00
|
|
|
<label
|
|
|
|
class="flex flex-wrap p-3 bg-white border border-gray-300 rounded-lg cursor-pointer hover:bg-gray-50 peer-checked:ring-primary peer-checked:ring-2 peer-checked:border-transparent"
|
|
|
|
:for="`availableActor-${availableActor.id}`"
|
|
|
|
>
|
|
|
|
<figure class="image is-48x48" v-if="availableActor.avatar">
|
|
|
|
<img
|
|
|
|
class="image is-rounded"
|
|
|
|
:src="availableActor.avatar.url"
|
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
</figure>
|
|
|
|
<b-icon v-else size="is-large" icon="account-circle" />
|
|
|
|
<div>
|
|
|
|
<h3>{{ availableActor.name }}</h3>
|
|
|
|
<small>{{ `@${availableActor.preferredUsername}` }}</small>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</li>
|
|
|
|
</transition-group>
|
2020-09-29 09:53:48 +02:00
|
|
|
</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,
|
2021-12-13 17:02:10 +01:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
page: 1,
|
|
|
|
limit: 10,
|
|
|
|
membershipName: this.actorFilter,
|
|
|
|
};
|
|
|
|
},
|
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;
|
|
|
|
|
2021-08-11 12:43:54 +02:00
|
|
|
actorFilter = "";
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
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
|
|
|
}
|
2021-08-11 12:43:54 +02:00
|
|
|
|
|
|
|
get actualFilteredAvailableActors(): IActor[] {
|
|
|
|
return this.actualAvailableActors.filter((actor) => {
|
|
|
|
return [
|
|
|
|
actor.preferredUsername.toLowerCase(),
|
|
|
|
actor.name?.toLowerCase(),
|
|
|
|
actor.domain?.toLowerCase(),
|
|
|
|
].some((match) => match?.includes(this.actorFilter.toLowerCase()));
|
|
|
|
});
|
|
|
|
}
|
2020-09-29 09:53:48 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2021-11-04 18:14:36 +01:00
|
|
|
@use "@/styles/_mixins" as *;
|
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 {
|
2021-11-04 18:14:36 +01:00
|
|
|
@include margin-right(0.5rem);
|
2020-09-29 09:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
span.icon.media-left {
|
2021-11-04 18:14:36 +01:00
|
|
|
@include margin-left(-0.25rem);
|
2020-09-29 09:53:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|