forked from potsda.mn/mobilizon
Directly load the group in OrganizerPickerWrapper if we have the group ID
Fixes #997 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
a2bb0c0a4d
commit
84a5c6f893
|
@ -148,7 +148,7 @@ import EmptyContent from "../Utils/EmptyContent.vue";
|
||||||
import {
|
import {
|
||||||
CURRENT_ACTOR_CLIENT,
|
CURRENT_ACTOR_CLIENT,
|
||||||
IDENTITIES,
|
IDENTITIES,
|
||||||
LOGGED_USER_MEMBERSHIPS,
|
PERSON_GROUP_MEMBERSHIPS,
|
||||||
} from "../../graphql/actor";
|
} from "../../graphql/actor";
|
||||||
import { Paginate } from "../../types/paginate";
|
import { Paginate } from "../../types/paginate";
|
||||||
import { GROUP_MEMBERS } from "@/graphql/member";
|
import { GROUP_MEMBERS } from "@/graphql/member";
|
||||||
|
@ -184,15 +184,17 @@ const MEMBER_ROLES = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
currentActor: CURRENT_ACTOR_CLIENT,
|
currentActor: CURRENT_ACTOR_CLIENT,
|
||||||
userMemberships: {
|
personMemberships: {
|
||||||
query: LOGGED_USER_MEMBERSHIPS,
|
query: PERSON_GROUP_MEMBERSHIPS,
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
|
id: this.currentActor?.id,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
groupId: this.$route.query?.actorId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
update: (data) => data.loggedUser.memberships,
|
update: (data) => data.person.memberships,
|
||||||
},
|
},
|
||||||
identities: IDENTITIES,
|
identities: IDENTITIES,
|
||||||
},
|
},
|
||||||
|
@ -202,6 +204,9 @@ export default class OrganizerPickerWrapper extends Vue {
|
||||||
|
|
||||||
@Prop({ default: true, type: Boolean }) inline!: boolean;
|
@Prop({ default: true, type: Boolean }) inline!: boolean;
|
||||||
|
|
||||||
|
@Prop({ type: Array, required: false, default: () => [] })
|
||||||
|
contacts!: IActor[];
|
||||||
|
|
||||||
currentActor!: IPerson;
|
currentActor!: IPerson;
|
||||||
|
|
||||||
identities!: IPerson[];
|
identities!: IPerson[];
|
||||||
|
@ -212,13 +217,11 @@ export default class OrganizerPickerWrapper extends Vue {
|
||||||
|
|
||||||
usernameWithDomain = usernameWithDomain;
|
usernameWithDomain = usernameWithDomain;
|
||||||
|
|
||||||
@Prop({ type: Array, required: false, default: () => [] })
|
|
||||||
contacts!: IActor[];
|
|
||||||
members: Paginate<IMember> = { elements: [], total: 0 };
|
members: Paginate<IMember> = { elements: [], total: 0 };
|
||||||
|
|
||||||
membersPage = 1;
|
membersPage = 1;
|
||||||
|
|
||||||
userMemberships: Paginate<IMember> = { elements: [], total: 0 };
|
personMemberships: Paginate<IMember> = { elements: [], total: 0 };
|
||||||
|
|
||||||
data(): Record<string, unknown> {
|
data(): Record<string, unknown> {
|
||||||
return {
|
return {
|
||||||
|
@ -241,15 +244,13 @@ export default class OrganizerPickerWrapper extends Vue {
|
||||||
this.contactFilter = contactFilter;
|
this.contactFilter = contactFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch("userMemberships")
|
@Watch("personMemberships")
|
||||||
setInitialActor(): void {
|
setInitialActor(): void {
|
||||||
if (this.$route.query?.actorId) {
|
if (
|
||||||
const actorId = this.$route.query?.actorId as string;
|
this.personMemberships?.elements[0]?.parent?.id ===
|
||||||
const actor = this.userMemberships.elements.find(
|
this.$route.query?.actorId
|
||||||
({ parent: { id }, role }) =>
|
) {
|
||||||
actorId === id && MEMBER_ROLES.includes(role)
|
this.selectedActor = this.personMemberships?.elements[0]?.parent;
|
||||||
)?.parent as IActor;
|
|
||||||
this.selectedActor = actor;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,30 @@ export const PERSON_STATUS_GROUP = gql`
|
||||||
${ACTOR_FRAGMENT}
|
${ACTOR_FRAGMENT}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const PERSON_GROUP_MEMBERSHIPS = gql`
|
||||||
|
query PersonGroupMemberships($id: ID!, $groupId: ID!) {
|
||||||
|
person(id: $id) {
|
||||||
|
id
|
||||||
|
memberships(groupId: $groupId) {
|
||||||
|
total
|
||||||
|
elements {
|
||||||
|
id
|
||||||
|
role
|
||||||
|
parent {
|
||||||
|
...ActorFragment
|
||||||
|
}
|
||||||
|
invitedBy {
|
||||||
|
...ActorFragment
|
||||||
|
}
|
||||||
|
insertedAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
${ACTOR_FRAGMENT}
|
||||||
|
`;
|
||||||
|
|
||||||
export const GROUP_MEMBERSHIP_SUBSCRIPTION_CHANGED = gql`
|
export const GROUP_MEMBERSHIP_SUBSCRIPTION_CHANGED = gql`
|
||||||
subscription GroupMembershipSubscriptionChanged(
|
subscription GroupMembershipSubscriptionChanged(
|
||||||
$actorId: ID!
|
$actorId: ID!
|
||||||
|
|
Loading…
Reference in a new issue