Merge pull request #6037 from tsiegleauq/poll-progress-speaker-manage

Allow LOS-Manager to see poll progress
This commit is contained in:
Emanuel Schütze 2021-05-03 13:11:30 +02:00 committed by GitHub
commit 74981e26c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 27 deletions

View File

@ -76,9 +76,7 @@
</div> </div>
<!-- Poll progress bar --> <!-- Poll progress bar -->
<div *osPerms="'assignments.can_manage'; and: poll && poll.isStarted"> <os-poll-progress *ngIf="poll && poll.isStarted" [poll]="poll"></os-poll-progress>
<os-poll-progress [poll]="poll"></os-poll-progress>
</div>
<!-- The Vote --> <!-- The Vote -->
<os-assignment-poll-vote *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-assignment-poll-vote> <os-assignment-poll-vote *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-assignment-poll-vote>

View File

@ -16,7 +16,7 @@
<a [routerLink]="getPollDetailLink(poll)" [state]="{ back: 'true' }">{{ getPollVoteTitle(poll) }}</a> <a [routerLink]="getPollDetailLink(poll)" [state]="{ back: 'true' }">{{ getPollVoteTitle(poll) }}</a>
</p> </p>
<os-poll-progress *ngIf="canManage(poll) && poll.canBeVotedFor()" [poll]="poll"></os-poll-progress> <os-poll-progress *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-poll-progress>
<div *ngIf="poll.pollClassType === 'motion'"> <div *ngIf="poll.pollClassType === 'motion'">
<os-motion-poll-vote [poll]="poll" *ngIf="poll.canBeVotedFor() && !last"></os-motion-poll-vote> <os-motion-poll-vote [poll]="poll" *ngIf="poll.canBeVotedFor() && !last"></os-motion-poll-vote>

View File

@ -143,13 +143,4 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
} }
return null; return null;
} }
public canManage(poll: ViewBasePoll): boolean {
if (poll.pollClassType === PollClassType.Motion) {
return this.operator.hasPerms(this.permission.motionsCanManagePolls);
} else if (poll.pollClassType === PollClassType.Assignment) {
return this.operator.hasPerms(this.permission.assignmentsCanManage);
}
return false;
}
} }

View File

@ -67,9 +67,7 @@
<!-- Results --> <!-- Results -->
<ng-container *ngIf="poll && !poll.stateHasVotes && poll.type !== 'analog'; else votingResult"> <ng-container *ngIf="poll && !poll.stateHasVotes && poll.type !== 'analog'; else votingResult">
<div *osPerms="'motions.can_manage_polls'; and: poll && poll.isStarted"> <os-poll-progress *ngIf="poll && poll.isStarted" [poll]="poll"></os-poll-progress>
<os-poll-progress [poll]="poll"></os-poll-progress>
</div>
<os-motion-poll-vote [poll]="poll" *ngIf="poll.canBeVotedFor()"></os-motion-poll-vote> <os-motion-poll-vote [poll]="poll" *ngIf="poll.canBeVotedFor()"></os-motion-poll-vote>
</ng-container> </ng-container>

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
@ -13,7 +13,8 @@ import { PollClassType, ViewBasePoll } from 'app/site/polls/models/view-base-pol
@Component({ @Component({
selector: 'os-poll-progress', selector: 'os-poll-progress',
templateUrl: './poll-progress.component.html', templateUrl: './poll-progress.component.html',
styleUrls: ['./poll-progress.component.scss'] styleUrls: ['./poll-progress.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class PollProgressComponent extends BaseViewComponentDirective implements OnInit { export class PollProgressComponent extends BaseViewComponentDirective implements OnInit {
@Input() @Input()
@ -24,14 +25,28 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
return this.poll?.votescast || 0; return this.poll?.votescast || 0;
} }
public get canSeeProgressBar(): boolean { private get canSeeNames(): boolean {
let canManage = false; return this.operator.hasPerms(this.permission.usersCanSeeName);
if (this.poll?.pollClassType === PollClassType.Motion) { }
canManage = this.operator.hasPerms(this.permission.motionsCanManagePolls);
} else if (this.poll?.pollClassType === PollClassType.Assignment) { private get canManageSpeakers(): boolean {
canManage = this.operator.hasPerms(this.permission.assignmentsCanManage); return this.operator.hasPerms(this.permission.agendaCanManageListOfSpeakers);
}
private get canManagePoll(): boolean {
if (this.poll.pollClassType === PollClassType.Motion) {
return this.operator.hasPerms(this.permission.motionsCanManagePolls);
} else if (this.poll.pollClassType === PollClassType.Assignment) {
return this.operator.hasPerms(this.permission.assignmentsCanManage);
} }
return canManage && this.operator.hasPerms(this.permission.usersCanSeeName); return false;
}
public get canSeeProgressBar(): boolean {
if (!this.canSeeNames) {
return false;
}
return this.canManageSpeakers || this.canManagePoll;
} }
public constructor( public constructor(
@ -39,7 +54,8 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
protected translate: TranslateService, protected translate: TranslateService,
snackbar: MatSnackBar, snackbar: MatSnackBar,
private userRepo: UserRepositoryService, private userRepo: UserRepositoryService,
private operator: OperatorService private operator: OperatorService,
private cd: ChangeDetectorRef
) { ) {
super(title, translate, snackbar); super(title, translate, snackbar);
} }
@ -67,7 +83,11 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
) )
.subscribe(users => { .subscribe(users => {
this.max = users.length; this.max = users.length;
}) this.cd.markForCheck();
}),
this.operator.getUserObservable().subscribe(() => {
this.cd.markForCheck();
})
); );
} }
} }