Fix add/remove admin

master
Max 5 years ago
parent 8cc25f0327
commit 52c7b96e16

@ -1,5 +1,5 @@
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {Levellist} from '../../models/levellist'; import {LevelList} from '../../models/levellist';
import {ActivityService} from '../../services/activity/activity.service'; import {ActivityService} from '../../services/activity/activity.service';
import {Activitylist} from '../../models/activity'; import {Activitylist} from '../../models/activity';
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';

@ -134,7 +134,7 @@
</div> </div>
<mat-card-title class="pointer" (click)="showUserProfile(user)">{{user.username}}</mat-card-title> <mat-card-title class="pointer" (click)="showUserProfile(user)">{{user.username}}</mat-card-title>
<mat-card-subtitle class="pointer" (click)="showUserProfile(user)">{{user.handle}}</mat-card-subtitle> <mat-card-subtitle class="pointer" (click)="showUserProfile(user)">{{user.handle}}</mat-card-subtitle>
<mat-card-subtitle hidden class="pointer" (click)="showUserProfile(user)">[admin] <mat-card-subtitle *ngIf="user.isGroupAdmin" class="pointer" (click)="showUserProfile(user)">[admin]
</mat-card-subtitle> </mat-card-subtitle>
<div id="icon-box" *ngIf="isCreator"> <div id="icon-box" *ngIf="isCreator">
<button mat-icon-button [matMenuTriggerFor]="menu"> <button mat-icon-button [matMenuTriggerFor]="menu">

@ -111,8 +111,8 @@ export class GroupComponent implements OnInit {
}); });
this.groupService.getGroupData(this.id).subscribe(); this.groupService.getGroupData(this.id).subscribe();
this.groupService.group.subscribe(response => { this.groupService.group.subscribe(response => {
this.isAdmin = false;
if (response) { if (response) {
this.isAdmin = false;
this.groupProfile = response; this.groupProfile = response;
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
this.groupProfile.allowedToJoinGroup = this.requestService.isAllowedToJoinGroup(this.groupProfile.id, this.self); this.groupProfile.allowedToJoinGroup = this.requestService.isAllowedToJoinGroup(this.groupProfile.id, this.self);

@ -52,12 +52,10 @@ export class Group {
const user = new User(); const user = new User();
this.admins.push(user.assignFromResponse(admin)); this.admins.push(user.assignFromResponse(admin));
} }
for (const admin of this.admins) {
for (const member of this.members) { for (const member of this.members) {
if (member.userID === admin.userID) { member.isGroupAdmin = !!this.admins.find((a: User) => {
member.isGroupAdmin = true; return a.userID === member.userID;
} });
}
} }
} }

@ -95,9 +95,6 @@ export class GroupService extends BaseService {
groupId groupId
} }
}; };
const group = this.group.getValue();
group.admins = [];
this.group.next(group);
return this.postGraphql(body, null, 0) return this.postGraphql(body, null, 0)
.pipe(tap(response => { .pipe(tap(response => {
const group = this.group.getValue(); const group = this.group.getValue();
@ -117,9 +114,6 @@ export class GroupService extends BaseService {
groupId groupId
} }
}; };
const group = this.group.getValue();
group.admins = [];
this.group.next(group);
return this.postGraphql(body, null, 0) return this.postGraphql(body, null, 0)
.pipe(tap(response => { .pipe(tap(response => {
const group = this.group.getValue(); const group = this.group.getValue();

Loading…
Cancel
Save