From 9c738b5d8e67039430fa686832706c051b171373 Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 1 Dec 2020 13:46:12 +0100 Subject: [PATCH] Add poll meta info component Adds a component to display the assignment polls meta info --- .../models/assignments/assignment-poll.ts | 4 ++ .../assignment-poll/assignment-poll.module.ts | 4 +- .../assignment-poll-detail.component.html | 14 +----- .../assignment-poll-detail.component.scss | 6 --- .../assignment-poll-meta-info.component.html | 44 +++++++++++++++++++ .../assignment-poll-meta-info.component.scss | 23 ++++++++++ ...ssignment-poll-meta-info.component.spec.ts | 27 ++++++++++++ .../assignment-poll-meta-info.component.ts | 37 ++++++++++++++++ .../assignment-poll.component.html | 17 +++---- .../assignment-poll.component.scss | 3 -- .../assignment-poll.component.ts | 12 ++++- client/src/app/site/cinema/cinema.module.ts | 3 +- 12 files changed, 158 insertions(+), 36 deletions(-) create mode 100644 client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.html create mode 100644 client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.scss create mode 100644 client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.spec.ts create mode 100644 client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.ts diff --git a/client/src/app/shared/models/assignments/assignment-poll.ts b/client/src/app/shared/models/assignments/assignment-poll.ts index 1381a9ebf..4711b99ae 100644 --- a/client/src/app/shared/models/assignments/assignment-poll.ts +++ b/client/src/app/shared/models/assignments/assignment-poll.ts @@ -67,6 +67,10 @@ export class AssignmentPoll extends BasePoll< return this.pollmethod === AssignmentPollMethod.YNA; } + public get hasGlobalOption(): boolean { + return this.global_yes || this.global_no || this.global_abstain; + } + public get pollmethodFields(): CalculablePollKey[] { if (this.pollmethod === AssignmentPollMethod.YN) { return ['yes', 'no']; diff --git a/client/src/app/site/assignments/modules/assignment-poll/assignment-poll.module.ts b/client/src/app/site/assignments/modules/assignment-poll/assignment-poll.module.ts index f7cdda681..0200964e0 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/assignment-poll.module.ts +++ b/client/src/app/site/assignments/modules/assignment-poll/assignment-poll.module.ts @@ -5,6 +5,7 @@ import { SharedModule } from 'app/shared/shared.module'; import { PollsModule } from 'app/site/polls/polls.module'; import { AssignmentPollDetailComponent } from './components/assignment-poll-detail/assignment-poll-detail.component'; import { AssignmentPollDialogComponent } from './components/assignment-poll-dialog/assignment-poll-dialog.component'; +import { AssignmentPollMetaInfoComponent } from './components/assignment-poll-meta-info/assignment-poll-meta-info.component'; import { AssignmentPollRoutingModule } from './assignment-poll-routing.module'; import { AssignmentPollVoteComponent } from './components/assignment-poll-vote/assignment-poll-vote.component'; import { AssignmentPollComponent } from './components/assignment-poll/assignment-poll.component'; @@ -14,7 +15,8 @@ import { AssignmentPollComponent } from './components/assignment-poll/assignment AssignmentPollComponent, AssignmentPollDetailComponent, AssignmentPollVoteComponent, - AssignmentPollDialogComponent + AssignmentPollDialogComponent, + AssignmentPollMetaInfoComponent ], exports: [AssignmentPollComponent, AssignmentPollVoteComponent], imports: [CommonModule, AssignmentPollRoutingModule, SharedModule, PollsModule] diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.html b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.html index 07302b53d..7cd9e994f 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.html +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.html @@ -102,19 +102,7 @@ -
- - {{ 'Groups' | translate }}: - - - {{ group.getTitle() | translate }}, - - - - - {{ '100% base' | translate }}: {{ poll.percentBaseVerbose | translate }} - -
+ diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.scss b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.scss index de55c583a..d38b492a6 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.scss +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-detail/assignment-poll-detail.component.scss @@ -30,12 +30,6 @@ } } -.assignment-poll-meta { - display: grid; - text-align: right; - padding-top: 20px; -} - .openslides-theme .pbl-ngrid-no-data { top: 10%; } diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.html b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.html new file mode 100644 index 000000000..20ec66e22 --- /dev/null +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.html @@ -0,0 +1,44 @@ + + + +
+ {{ 'Candidates' | translate }}: +
    +
  1. {{ getOptionTitle(option) | translate }}
  2. +
+
+
+ {{ 'Options' | translate }}: +
    +
  • {{ pollPropertyVerbose.global_yes | translate }}
  • +
  • {{ pollPropertyVerbose.global_no | translate }}
  • +
  • {{ pollPropertyVerbose.global_abstain | translate }}
  • +
+
+
+ +
+ + + {{ 'Entitled to vote' | translate }}: + + + {{ group.getTitle() | translate }}, + +
+
+ + + + {{ 'Voting method' | translate }}: {{ poll.pollmethodVerbose | translate }} + + ({{ poll.votes_amount }} {{ 'Votes' | translate }}) +
+
+ + + + {{ '100% base' | translate }}: {{ poll.percentBaseVerbose | translate }} + +
+
diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.scss b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.scss new file mode 100644 index 000000000..239f254d3 --- /dev/null +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.scss @@ -0,0 +1,23 @@ +:host { + width: 100%; + padding-top: 20px; + display: grid; + grid-template-columns: 2fr auto; +} + +.meta-info-left { + ul, + ol { + margin: 0; + padding-left: 2em; + } + + div + div { + margin-top: 1em; + } +} + +.meta-info-right { + text-align: right; + align-self: flex-end; +} diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.spec.ts b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.spec.ts new file mode 100644 index 000000000..886726cc4 --- /dev/null +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.spec.ts @@ -0,0 +1,27 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { E2EImportsModule } from 'e2e-imports.module'; + +import { AssignmentPollMetaInfoComponent } from './assignment-poll-meta-info.component'; + +describe('AssignmentPollMetaInfoComponent', () => { + let component: AssignmentPollMetaInfoComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [E2EImportsModule], + declarations: [AssignmentPollMetaInfoComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AssignmentPollMetaInfoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.ts b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.ts new file mode 100644 index 000000000..3533ca617 --- /dev/null +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll-meta-info/assignment-poll-meta-info.component.ts @@ -0,0 +1,37 @@ +import { Component, Input } from '@angular/core'; + +import { ViewAssignmentOption } from 'app/site/assignments/models/view-assignment-option'; +import { ViewAssignmentPoll } from 'app/site/assignments/models/view-assignment-poll'; +import { UnknownUserLabel } from 'app/site/assignments/modules/assignment-poll/services/assignment-poll.service'; +import { PollPropertyVerbose } from 'app/site/polls/models/view-base-poll'; + +@Component({ + selector: 'os-assignment-poll-meta-info', + templateUrl: './assignment-poll-meta-info.component.html', + styleUrls: ['./assignment-poll-meta-info.component.scss'] +}) +export class AssignmentPollMetaInfoComponent { + public pollPropertyVerbose = PollPropertyVerbose; + private unknownUserLabel = UnknownUserLabel; + + @Input() + public poll: ViewAssignmentPoll; + + @Input() + public showCandidates = true; + + public get hasGlobalOption(): boolean { + return this.poll.hasGlobalOption; + } + + public constructor() {} + + public userCanVoe(): boolean { + // this.poll.canBeVotedFor + return true; + } + + public getOptionTitle(option: ViewAssignmentOption): string { + return option.user?.getShortName().trim() ?? this.unknownUserLabel; + } +} 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 34f09ac08..648ce6edd 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 @@ -74,17 +74,12 @@ - - + + diff --git a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.scss b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.scss index abfbffdda..6e86c8e38 100644 --- a/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.scss +++ b/client/src/app/site/assignments/modules/assignment-poll/components/assignment-poll/assignment-poll.component.scss @@ -18,8 +18,5 @@ .poll-detail-button-wrapper { display: flex; margin: auto 0; - > a { - margin-left: auto; - } } } 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 27ee43e37..d193ef68c 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 @@ -9,6 +9,7 @@ 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 { VotingService } from 'app/core/ui-services/voting.service'; import { VotingPrivacyWarningComponent } from 'app/shared/components/voting-privacy-warning/voting-privacy-warning.component'; import { infoDialogSettings } from 'app/shared/utils/dialog-settings'; import { ViewAssignmentPoll } from 'app/site/assignments/models/view-assignment-poll'; @@ -67,6 +68,14 @@ export class AssignmentPollComponent return false; } + public get showMetaInfo(): boolean { + return !this.poll.stateHasVotes && this.operator.hasPerms(this.permission.assignmentsCanManage); + } + + public get showCandidatesInMetaInfo(): boolean { + return !this.poll.stateHasVotes && !this.votingService.canVote(this.poll); + } + public constructor( titleService: Title, matSnackBar: MatSnackBar, @@ -78,7 +87,8 @@ export class AssignmentPollComponent private pollService: AssignmentPollService, private formBuilder: FormBuilder, private pdfService: AssignmentPollPdfService, - private operator: OperatorService + private operator: OperatorService, + private votingService: VotingService ) { super(titleService, matSnackBar, translate, dialog, promptService, repo, pollDialog); } diff --git a/client/src/app/site/cinema/cinema.module.ts b/client/src/app/site/cinema/cinema.module.ts index 9e0b47ea3..07f3729fe 100644 --- a/client/src/app/site/cinema/cinema.module.ts +++ b/client/src/app/site/cinema/cinema.module.ts @@ -7,9 +7,10 @@ import { CinemaRoutingModule } from './cinema-routing.module'; import { CinemaComponent } from './components/cinema/cinema.component'; import { MotionPollModule } from '../motions/modules/motion-poll/motion-poll.module'; import { PollCollectionComponent } from './components/poll-collection/poll-collection.component'; +import { PollsModule } from '../polls/polls.module'; @NgModule({ - imports: [CommonModule, CinemaRoutingModule, MotionPollModule, AssignmentPollModule, SharedModule], + imports: [CommonModule, CinemaRoutingModule, MotionPollModule, AssignmentPollModule, SharedModule, PollsModule], declarations: [CinemaComponent, PollCollectionComponent] }) export class CinemaModule {}