From 90ac27ff432ef4bad35e1c8bfcf06dc2e27c59e7 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 30 Nov 2020 15:27:12 +0100 Subject: [PATCH] Hide started assignment polls Hide assignment polls in started state if user does not have the manage permission --- .../assignment-poll.component.html | 2 +- .../assignment-poll.component.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.html b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.html index 8131d58c7..b049cada1 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.html +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.html @@ -1,4 +1,4 @@ - +
diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.ts b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.ts index 6c925cd98..b4c122920 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.ts +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.ts @@ -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); }