+
{{ 'Single votes' | translate }}
('users_activate_vote_weight')
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 b049cada1..34f09ac08 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
@@ -12,9 +12,7 @@
{{ poll.typeVerbose | translate }} ·
@@ -64,19 +62,8 @@
-
-
-
-
-
-
-
- {{ 'Counting of votes is in progress ...' | translate }}
-
-
+
+
@@ -95,9 +82,7 @@
matTooltip="{{ 'More' | translate }}"
*ngIf="poll.isPublished"
>
-
- visibility
-
+
visibility
diff --git a/client/src/app/site/cinema/components/cinema/cinema.component.ts b/client/src/app/site/cinema/components/cinema/cinema.component.ts
index eeb992999..78c74edcd 100644
--- a/client/src/app/site/cinema/components/cinema/cinema.component.ts
+++ b/client/src/app/site/cinema/components/cinema/cinema.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, ViewChild } from '@angular/core';
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser';
@@ -90,7 +90,8 @@ export class CinemaComponent extends BaseViewComponentDirective implements OnIni
private projectorService: ProjectorService,
private projectorRepo: ProjectorRepositoryService,
private closService: CurrentListOfSpeakersService,
- private listOfSpeakersRepo: ListOfSpeakersRepositoryService
+ private listOfSpeakersRepo: ListOfSpeakersRepositoryService,
+ private cd: ChangeDetectorRef
) {
super(title, translate, snackBar);
}
diff --git a/client/src/app/site/cinema/components/poll-collection/poll-collection.component.html b/client/src/app/site/cinema/components/poll-collection/poll-collection.component.html
index 797f4f5ed..0caa505fd 100644
--- a/client/src/app/site/cinema/components/poll-collection/poll-collection.component.html
+++ b/client/src/app/site/cinema/components/poll-collection/poll-collection.component.html
@@ -1,13 +1,32 @@
-
-
- {{ getPollVoteTitle(poll) }}
-
+
-
-
-
+
-
-
-
-
+
+
+
+ {{ getPollVoteTitle(poll) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/src/app/site/cinema/components/poll-collection/poll-collection.component.ts b/client/src/app/site/cinema/components/poll-collection/poll-collection.component.ts
index 5aec27166..725774cdf 100644
--- a/client/src/app/site/cinema/components/poll-collection/poll-collection.component.ts
+++ b/client/src/app/site/cinema/components/poll-collection/poll-collection.component.ts
@@ -1,25 +1,52 @@
-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';
import { TranslateService } from '@ngx-translate/core';
import { map } from 'rxjs/operators';
+import { ViewAssignment } from 'app/site/assignments/models/view-assignment';
+import { ViewAssignmentPoll } from 'app/site/assignments/models/view-assignment-poll';
import { BaseViewComponentDirective } from 'app/site/base/base-view';
import { BaseViewModel } from 'app/site/base/base-view-model';
+import { ViewMotion } from 'app/site/motions/models/view-motion';
+import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll';
import { ViewBasePoll } from 'app/site/polls/models/view-base-poll';
import { PollListObservableService } from 'app/site/polls/services/poll-list-observable.service';
@Component({
selector: 'os-poll-collection',
templateUrl: './poll-collection.component.html',
- styleUrls: ['./poll-collection.component.scss']
+ styleUrls: ['./poll-collection.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush
})
export class PollCollectionComponent extends BaseViewComponentDirective implements OnInit {
public polls: ViewBasePoll[];
+ public lastPublishedPoll: ViewBasePoll;
+
+ private _currentProjection: BaseViewModel
;
+
+ public get currentProjection(): BaseViewModel {
+ return this._currentProjection;
+ }
+
+ /**
+ * CLEANUP: This function belongs to "HasViewPolls"/ ViewModelWithPolls
+ */
+ public get hasProjectedModelOpenPolls(): boolean {
+ if (this.currentProjection instanceof ViewMotion || this.currentProjection instanceof ViewAssignment) {
+ const currPolls: ViewMotionPoll[] | ViewAssignmentPoll[] = this.currentProjection.polls;
+ return currPolls.some((p: ViewMotionPoll | ViewAssignmentPoll) => p.isStarted);
+ }
+ return false;
+ }
+
@Input()
- private currentProjection: BaseViewModel;
+ public set currentProjection(viewModel: BaseViewModel) {
+ this._currentProjection = viewModel;
+ this.updateLastPublished();
+ }
private get showExtendedTitle(): boolean {
const areAllPollsSameModel = this.polls.every(
@@ -27,7 +54,7 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
);
if (this.currentProjection && areAllPollsSameModel) {
- return this.polls[0].getContentObject() !== this.currentProjection;
+ return this.polls[0]?.getContentObject() !== this.currentProjection;
} else {
return !areAllPollsSameModel;
}
@@ -37,7 +64,8 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
title: Title,
translate: TranslateService,
snackBar: MatSnackBar,
- private pollService: PollListObservableService
+ private pollService: PollListObservableService,
+ private cd: ChangeDetectorRef
) {
super(title, translate, snackBar);
}
@@ -46,9 +74,17 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
this.subscriptions.push(
this.pollService
.getViewModelListObservable()
- .pipe(map(polls => polls.filter(poll => poll.canBeVotedFor())))
+ .pipe(
+ map(polls => {
+ return polls.filter(poll => {
+ return poll.canBeVotedFor();
+ });
+ })
+ )
.subscribe(polls => {
this.polls = polls;
+ this.cd.markForCheck();
+ this.updateLastPublished();
})
);
}
@@ -57,6 +93,10 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
return poll.id;
}
+ public getPollDetailLink(poll: ViewBasePoll): string {
+ return poll.parentLink;
+ }
+
public getPollVoteTitle(poll: ViewBasePoll): string {
const contentObject = poll.getContentObject();
const listTitle = contentObject.getListTitle();
@@ -70,7 +110,35 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
}
}
- public getPollDetailLink(poll: ViewBasePoll): string {
- return poll.parentLink;
+ /**
+ * Helper function to detect new latest published polls and set them.
+ */
+ private updateLastPublished(): void {
+ const lastPublished = this.getLastfinshedPoll(this.currentProjection);
+ if (lastPublished !== this.lastPublishedPoll) {
+ this.lastPublishedPoll = lastPublished;
+ this.cd.markForCheck();
+ }
+ }
+
+ /**
+ * CLEANUP: This function belongs to "HasViewPolls"/ ViewModelWithPolls
+ * *class* (is an interface right now)
+ *
+ * @param viewModel
+ */
+ private getLastfinshedPoll(viewModel: BaseViewModel): ViewBasePoll {
+ if (viewModel instanceof ViewMotion || viewModel instanceof ViewAssignment) {
+ let currPolls: ViewMotionPoll[] | ViewAssignmentPoll[] = viewModel.polls;
+ /**
+ * Although it should, since the union type could use `.filter
+ * without any problem, without an any cast it will not work
+ */
+ currPolls = (currPolls as any[])
+ .filter((p: ViewMotionPoll | ViewAssignmentPoll) => p.stateHasVotes)
+ .reverse();
+ return currPolls[0];
+ }
+ return null;
}
}
diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts
index 8dbba0814..783f9cf9c 100644
--- a/client/src/app/site/motions/models/view-motion.ts
+++ b/client/src/app/site/motions/models/view-motion.ts
@@ -11,6 +11,7 @@ import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
import { Searchable } from 'app/site/base/searchable';
import { SlideOptions } from 'app/site/base/slide-options';
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
+import { HasViewPolls } from 'app/site/polls/models/has-view-polls';
import { ViewTag } from 'app/site/tags/models/view-tag';
import { ViewUser } from 'app/site/users/models/view-user';
import { AmendmentType } from '../motions.constants';
@@ -355,7 +356,7 @@ export class ViewMotion
}
}
-interface TIMotionRelations {
+interface TIMotionRelations extends HasViewPolls {
category?: ViewCategory;
submitters: ViewSubmitter[];
supporters?: ViewUser[];
@@ -369,7 +370,6 @@ interface TIMotionRelations {
amendments?: ViewMotion[];
changeRecommendations?: ViewMotionChangeRecommendation[];
diffLines?: DiffLinesInParagraph[];
- polls: ViewMotionPoll[];
}
export interface ViewMotion extends MotionWithoutNestedModels, TIMotionRelations {}
diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html
index 959cb52ed..f4c201569 100644
--- a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html
+++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html
@@ -29,68 +29,63 @@