Hide started assignment polls

Hide assignment polls in started state if user does not have
the manage permission
This commit is contained in:
Sean 2020-11-30 15:27:12 +01:00
parent 652b727386
commit 90ac27ff43
2 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,4 @@
<mat-card class="os-card" *ngIf="poll">
<mat-card class="os-card" *ngIf="showPoll">
<div class="assignment-poll-wrapper">
<div>
<!-- Title -->

View File

@ -6,6 +6,7 @@ import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { OperatorService } from 'app/core/core-services/operator.service';
import { AssignmentPollRepositoryService } from 'app/core/repositories/assignments/assignment-poll-repository.service';
import { PromptService } from 'app/core/ui-services/prompt.service';
import { VotingPrivacyWarningComponent } from 'app/shared/components/voting-privacy-warning/voting-privacy-warning.component';
@ -53,6 +54,19 @@ export class AssignmentPollComponent
return this.descriptionForm.get('description').value !== this.poll.description;
}
public get showPoll(): boolean {
if (this.poll) {
if (
this.operator.hasPerms(this.permission.assignmentsCanManage) ||
this.poll.isPublished ||
(this.poll.isEVoting && !this.poll.isCreated)
) {
return true;
}
}
return false;
}
public constructor(
titleService: Title,
matSnackBar: MatSnackBar,
@ -63,7 +77,8 @@ export class AssignmentPollComponent
pollDialog: AssignmentPollDialogService,
private pollService: AssignmentPollService,
private formBuilder: FormBuilder,
private pdfService: AssignmentPollPdfService
private pdfService: AssignmentPollPdfService,
private operator: OperatorService
) {
super(titleService, matSnackBar, translate, dialog, promptService, repo, pollDialog);
}