From 1de73d5701dc696b33092b680d4444f927bc4eba Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Thu, 30 Jan 2020 12:01:59 +0100 Subject: [PATCH] improved shared poll list --- .../models/view-assignment-poll.ts | 5 ++++ .../site/motions/models/view-motion-poll.ts | 5 ++++ .../poll-list/poll-list.component.html | 25 ++++++++----------- .../app/site/polls/models/view-base-poll.ts | 9 +++---- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/client/src/app/site/assignments/models/view-assignment-poll.ts b/client/src/app/site/assignments/models/view-assignment-poll.ts index 3d739e694..ec92f1d87 100644 --- a/client/src/app/site/assignments/models/view-assignment-poll.ts +++ b/client/src/app/site/assignments/models/view-assignment-poll.ts @@ -3,6 +3,7 @@ import { BehaviorSubject } from 'rxjs'; import { ChartData } from 'app/shared/components/charts/charts.component'; import { AssignmentPoll, AssignmentPollMethods } from 'app/shared/models/assignments/assignment-poll'; import { PollColor } from 'app/shared/models/poll/base-poll'; +import { BaseViewModel } from 'app/site/base/base-view-model'; import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable'; import { ViewBasePoll } from 'app/site/polls/models/view-base-poll'; import { ViewAssignment } from './view-assignment'; @@ -29,6 +30,10 @@ export class ViewAssignmentPoll extends ViewBasePoll implements return AssignmentPollMethodsVerbose[this.pollmethod]; } + public getContentObject(): BaseViewModel { + return this.assignment; + } + public getSlide(): ProjectorElementBuildDeskriptor { // TODO: update to new voting system? return { diff --git a/client/src/app/site/motions/models/view-motion-poll.ts b/client/src/app/site/motions/models/view-motion-poll.ts index d80818cf2..737fe7913 100644 --- a/client/src/app/site/motions/models/view-motion-poll.ts +++ b/client/src/app/site/motions/models/view-motion-poll.ts @@ -1,6 +1,7 @@ import { ChartData } from 'app/shared/components/charts/charts.component'; import { MotionPoll, MotionPollMethods } from 'app/shared/models/motions/motion-poll'; import { PollColor } from 'app/shared/models/poll/base-poll'; +import { BaseViewModel } from 'app/site/base/base-view-model'; import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable'; import { ViewMotionOption } from 'app/site/motions/models/view-motion-option'; import { ViewBasePoll } from 'app/site/polls/models/view-base-poll'; @@ -32,6 +33,10 @@ export class ViewMotionPoll extends ViewBasePoll implements MotionPo return ['Votes']; } + public getContentObject(): BaseViewModel { + return this.motion; + } + public generateTableData(): {}[] { let tableData = this.options.flatMap(vote => this.tableKeys.map(key => ({ key: key, value: vote[key] }))); tableData.push(...this.voteKeys.map(key => ({ key: key, value: this[key] }))); diff --git a/client/src/app/site/polls/components/poll-list/poll-list.component.html b/client/src/app/site/polls/components/poll-list/poll-list.component.html index 1ea1802b4..0efc9a146 100644 --- a/client/src/app/site/polls/components/poll-list/poll-list.component.html +++ b/client/src/app/site/polls/components/poll-list/poll-list.component.html @@ -11,28 +11,25 @@ [listObservableProvider]="polls" [vScrollFixed]="64" [columns]="tableColumnDefinition" - [listStorageKey]="'polls'" + listStorageKey="polls" [filterProps]="filterProps" [filterService]="filterService" > -
- +
+ {{ poll.title }}
-
- {{ poll.pollClassTypeVerbose }} +
+ + {{ poll.getContentObject().getListTitle() }}
-
+
+ {{ poll.stateVerbose }}
-
- check_circle - warning +
+ check_circle + warning
diff --git a/client/src/app/site/polls/models/view-base-poll.ts b/client/src/app/site/polls/models/view-base-poll.ts index 0b850f89e..0b28c742d 100644 --- a/client/src/app/site/polls/models/view-base-poll.ts +++ b/client/src/app/site/polls/models/view-base-poll.ts @@ -1,11 +1,10 @@ import { ChartData } from 'app/shared/components/charts/charts.component'; import { BasePoll, PollState } from 'app/shared/models/poll/base-poll'; import { ViewAssignmentOption } from 'app/site/assignments/models/view-assignment-option'; -import { ViewAssignmentPoll } from 'app/site/assignments/models/view-assignment-poll'; import { BaseProjectableViewModel } from 'app/site/base/base-projectable-view-model'; +import { BaseViewModel } from 'app/site/base/base-view-model'; import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable'; import { ViewMotionOption } from 'app/site/motions/models/view-motion-option'; -import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll'; import { ViewGroup } from 'app/site/users/models/view-group'; import { ViewUser } from 'app/site/users/models/view-user'; @@ -71,9 +70,7 @@ export abstract class ViewBasePoll = any> extends Bas } public get parentLink(): string { - return this.pollClassType === 'motion' - ? `/motions/${((this)).poll.motion_id}` - : `/assignments/${((this)).poll.assignment_id}/`; + return `/${this.pollClassType}s/${this.getContentObject().id}`; } public get stateVerbose(): string { @@ -111,6 +108,8 @@ export abstract class ViewBasePoll = any> extends Bas public abstract getSlide(): ProjectorElementBuildDeskriptor; + public abstract getContentObject(): BaseViewModel; + /** * Initializes labels for a chart. */