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>
<!-- Poll progress bar -->
<div *osPerms="'assignments.can_manage'; and: poll && poll.isStarted">
<os-poll-progress [poll]="poll"></os-poll-progress>
</div>
<os-poll-progress *ngIf="poll && poll.isStarted" [poll]="poll"></os-poll-progress>
<!-- The 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>
</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'">
<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;
}
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 -->
<ng-container *ngIf="poll && !poll.stateHasVotes && poll.type !== 'analog'; else votingResult">
<div *osPerms="'motions.can_manage_polls'; and: poll && poll.isStarted">
<os-poll-progress [poll]="poll"></os-poll-progress>
</div>
<os-poll-progress *ngIf="poll && poll.isStarted" [poll]="poll"></os-poll-progress>
<os-motion-poll-vote [poll]="poll" *ngIf="poll.canBeVotedFor()"></os-motion-poll-vote>
</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 { Title } from '@angular/platform-browser';
@ -13,7 +13,8 @@ import { PollClassType, ViewBasePoll } from 'app/site/polls/models/view-base-pol
@Component({
selector: 'os-poll-progress',
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 {
@Input()
@ -24,14 +25,28 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
return this.poll?.votescast || 0;
}
public get canSeeProgressBar(): boolean {
let canManage = false;
if (this.poll?.pollClassType === PollClassType.Motion) {
canManage = this.operator.hasPerms(this.permission.motionsCanManagePolls);
} else if (this.poll?.pollClassType === PollClassType.Assignment) {
canManage = this.operator.hasPerms(this.permission.assignmentsCanManage);
private get canSeeNames(): boolean {
return this.operator.hasPerms(this.permission.usersCanSeeName);
}
return canManage && this.operator.hasPerms(this.permission.usersCanSeeName);
private get canManageSpeakers(): boolean {
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 false;
}
public get canSeeProgressBar(): boolean {
if (!this.canSeeNames) {
return false;
}
return this.canManageSpeakers || this.canManagePoll;
}
public constructor(
@ -39,7 +54,8 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
protected translate: TranslateService,
snackbar: MatSnackBar,
private userRepo: UserRepositoryService,
private operator: OperatorService
private operator: OperatorService,
private cd: ChangeDetectorRef
) {
super(title, translate, snackbar);
}
@ -67,6 +83,10 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
)
.subscribe(users => {
this.max = users.length;
this.cd.markForCheck();
}),
this.operator.getUserObservable().subscribe(() => {
this.cd.markForCheck();
})
);
}