From 435bb59472e54d69e6d2a0cd106935ae6f10312c Mon Sep 17 00:00:00 2001 From: Finn Stutzenstein Date: Mon, 5 Oct 2020 11:35:20 +0200 Subject: [PATCH] Add parsing of decimal fields for projector data Fixes an issue where the projector would not show special poll values, such as "majority" or "not counted" --- client/src/app/shared/models/motions/motion-poll.ts | 5 +++++ client/src/app/shared/models/poll/base-poll.ts | 4 ---- client/src/app/shared/pipes/parse-poll-number.pipe.ts | 2 +- client/src/app/site/motions/models/view-motion-poll.ts | 4 ++++ .../assignment-poll/assignment-poll-slide.component.ts | 5 +++++ .../motions/motion-poll/motion-poll-slide.component.ts | 5 +++++ client/src/app/slides/polls/base-poll-slide.component.ts | 9 ++++++++- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/client/src/app/shared/models/motions/motion-poll.ts b/client/src/app/shared/models/motions/motion-poll.ts index 0e551bdbd..1e39d6584 100644 --- a/client/src/app/shared/models/motions/motion-poll.ts +++ b/client/src/app/shared/models/motions/motion-poll.ts @@ -13,6 +13,7 @@ export enum MotionPollMethod { export class MotionPoll extends BasePoll { public static COLLECTIONSTRING = 'motions/motion-poll'; public static defaultGroupsConfig = 'motion_poll_default_groups'; + public static DECIMAL_FIELDS = ['votesvalid', 'votesinvalid', 'votescast']; public id: number; public motion_id: number; @@ -29,4 +30,8 @@ export class MotionPoll extends BasePoll extends BaseSlideComponentDirective { @@ -19,6 +19,11 @@ export class BasePollSlideComponentDirective< @Input() public set data(value: SlideData) { this._data = value; + this.getDecimalFields().forEach(field => { + if (value.data.poll[field] !== undefined) { + value.data.poll[field] = parseFloat(value.data.poll[field]); + } + }); if (value.data.poll.state === PollState.Published) { const chartData = this.pollService.generateChartData(value.data.poll); this.chartDataSubject.next(chartData); @@ -37,4 +42,6 @@ export class BasePollSlideComponentDirective< ) { super(); } + + protected abstract getDecimalFields(): string[]; }