Skip to content

Commit

Permalink
#14 disabled all controls in team page if not a team member
Browse files Browse the repository at this point in the history
  • Loading branch information
ryzhak committed Oct 26, 2018
1 parent aa4881f commit 2a2c8a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/app/dashboard/group-member/group-member.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1 class="h3 display">Members of group DevZenTeam</h1>

<div *ngIf="!loading" class="row pb-2">
<div class="col-lg-12 text-right">
<button (click)="displayAddGroupMemberDialog = true" class="btn btn-primary">Add</button>
<button (click)="displayAddGroupMemberDialog = true" [disabled]="!isTeamMember" class="btn btn-primary">Add</button>
</div>
</div>

Expand All @@ -34,7 +34,7 @@ <h1 class="h3 display">Members of group DevZenTeam</h1>
<td>{{ web3Service.fromWei(member.dztBalance,"ether") }}</td>
<td>{{ web3Service.fromWei(member.dztRepBalance,"ether") }}</td>
<td>
<button (click)="deleteGroupMember(member)" class="btn btn-danger">Delete</button>
<button (click)="deleteGroupMember(member)" [disabled]="!isTeamMember" class="btn btn-danger">Delete</button>
</td>
</tr>
</tbody>
Expand Down
15 changes: 12 additions & 3 deletions src/app/dashboard/group-member/group-member.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class GroupMemberComponent implements OnInit {

displayAddGroupMemberDialog = false;
formGroupMember: FormGroup;
isTeamMember = false;
loading = false;
members: GroupMember[] = [];

Expand All @@ -32,18 +33,26 @@ export class GroupMemberComponent implements OnInit {
let sub;
// if DevZenDaoService initialized then we don't need to wait for it to load the contracts
if(this.devZenDaoService.isInitialized) {
sub = this.devZenDaoService.getGroupMembers(this.devZenDaoService.GROUP_DEV_ZEN_TEAM);
sub = forkJoin(
this.devZenDaoService.getGroupMembers(this.devZenDaoService.GROUP_DEV_ZEN_TEAM),
this.devZenDaoService.isTeamMember()
);
} else {
// wait for the DevZenDaoService to be initialized
sub = this.devZenDaoService.init.pipe(
switchMap(() => {
return this.devZenDaoService.getGroupMembers(this.devZenDaoService.GROUP_DEV_ZEN_TEAM);
return forkJoin(
this.devZenDaoService.getGroupMembers(this.devZenDaoService.GROUP_DEV_ZEN_TEAM),
this.devZenDaoService.isTeamMember()
);
})
);
}

sub.pipe(
switchMap(members => {
switchMap(data => {
const members = data[0];
this.isTeamMember = data[1];
let requests = [];
Object.keys(members).map(
index => {
Expand Down

0 comments on commit 2a2c8a3

Please sign in to comment.