Skip to content

Commit

Permalink
Update functionality to add groupmembers (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmet committed Aug 24, 2024
1 parent 2faeed4 commit 15a4bbd
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component, Inject, OnInit } from "@angular/core";
import { Observable } from "rxjs";
import { Observable, combineLatest } from "rxjs";
import { GroupRegistrationService } from "../../service/group-registration.sevice";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { Participant } from "../../model/Participant";
import { Group } from "../../model/Group";
import { GroupService } from "../../service/group.service";
import { CourseRegistrationService } from "../../service/course-registration.service";
import { map } from "rxjs/operators";

@Component({
selector: "app-group-deregister-dialog",
Expand Down Expand Up @@ -40,8 +41,22 @@ export class GroupDeregisterDialogComponent implements OnInit {

loadMembers(): void {
if (this.data.adding) {
this.members$ = this.courseRegistrationService.getCourseParticipants(
this.data.cid
const courseMembers$ =
this.courseRegistrationService.getCourseParticipants(this.data.cid);
const groupMembers$ = this.groupRegistrationService.getGroupParticipants(
this.data.cid,
this.data.gid
);

this.members$ = combineLatest([courseMembers$, groupMembers$]).pipe(
map(([courseMembers, groupMembers]) =>
courseMembers.filter(
(courseMember) =>
!groupMembers.some(
(groupMember) => groupMember.user.id === courseMember.user.id
)
)
)
);
} else {
this.members$ = this.groupRegistrationService.getGroupParticipants(
Expand Down

0 comments on commit 15a4bbd

Please sign in to comment.