diff --git a/client/src/app/shared/components/assignment-poll-detail-content/assignment-poll-detail-content.component.html b/client/src/app/shared/components/assignment-poll-detail-content/assignment-poll-detail-content.component.html index 8b2e1f615..1d30173af 100644 --- a/client/src/app/shared/components/assignment-poll-detail-content/assignment-poll-detail-content.component.html +++ b/client/src/app/shared/components/assignment-poll-detail-content/assignment-poll-detail-content.component.html @@ -30,7 +30,7 @@
- {{ vote.amount | pollPercentBase: poll }} + {{ vote.amount | pollPercentBase: poll:'assignment' }} {{ vote.amount | parsePollNumber }} diff --git a/client/src/app/shared/components/motion-poll-detail-content/motion-poll-detail-content.component.html b/client/src/app/shared/components/motion-poll-detail-content/motion-poll-detail-content.component.html index 80698a620..3b8f2f314 100644 --- a/client/src/app/shared/components/motion-poll-detail-content/motion-poll-detail-content.component.html +++ b/client/src/app/shared/components/motion-poll-detail-content/motion-poll-detail-content.component.html @@ -20,7 +20,7 @@ - {{ row.value[0].amount | pollPercentBase: poll }} + {{ row.value[0].amount | pollPercentBase: poll:'motion' }} diff --git a/client/src/app/shared/pipes/poll-percent-base.pipe.ts b/client/src/app/shared/pipes/poll-percent-base.pipe.ts index 51c04065d..72866be5f 100644 --- a/client/src/app/shared/pipes/poll-percent-base.pipe.ts +++ b/client/src/app/shared/pipes/poll-percent-base.pipe.ts @@ -14,7 +14,7 @@ import { PollData } from 'app/site/polls/services/poll.service'; * * @example * ```html - * {{ voteYes | pollPercentBase: poll }} + * {{ voteYes | pollPercentBase: poll:'assignment' }} * ``` */ @Pipe({ @@ -26,10 +26,16 @@ export class PollPercentBasePipe implements PipeTransform { private motionPollService: MotionPollService ) {} - public transform(value: number, poll: PollData): string | null { + public transform(value: number, poll: PollData, type: 'motion' | 'assignment'): string | null { // logic handles over the pollService to avoid circular dependencies let voteValueInPercent: string; - if ((poll).assignment) { + + /** + * PollData has not enough explicit information to simply guess the type correctly. + * This should not be a problem when PollData is a real model or a real type. Since + * we cannot expect the projector to work with real types for now, we need to provice the type + */ + if (type === 'assignment') { voteValueInPercent = this.assignmentPollService.getVoteValueInPercent(value, poll); } else { voteValueInPercent = this.motionPollService.getVoteValueInPercent(value, poll); diff --git a/client/src/app/site/assignments/services/assignment-pdf.service.ts b/client/src/app/site/assignments/services/assignment-pdf.service.ts index 50f144482..25119640f 100644 --- a/client/src/app/site/assignments/services/assignment-pdf.service.ts +++ b/client/src/app/site/assignments/services/assignment-pdf.service.ts @@ -232,7 +232,7 @@ export class AssignmentPdfService { .map((singleResult: VotingResult) => { const votingKey = this.translate.instant(this.pollKeyVerbose.transform(singleResult.vote)); const resultValue = this.parsePollNumber.transform(singleResult.amount); - const resultInPercent = this.pollPercentBase.transform(singleResult.amount, poll); + const resultInPercent = this.pollPercentBase.transform(singleResult.amount, poll, 'assignment'); return `${votingKey}${!!votingKey ? ': ' : ''}${resultValue} ${ singleResult.showPercent && resultInPercent ? resultInPercent : '' }`; diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html index 25a8fc426..4a25ec32c 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html @@ -94,7 +94,7 @@ {{ row.value[0].amount | parsePollNumber }} - {{ row.value[0].amount | pollPercentBase: poll }} + {{ row.value[0].amount | pollPercentBase: poll:'motion' }}