Fix assignment polldata discovery in percent pipe
Fixes an issue where projector data was not delivering enough information to guess if a poll data belongs to an assignment or a motion. This error resultet that the percent base pipe used the percent bases for motions to calculate for assignments
This commit is contained in:
parent
c0fb65316c
commit
98a8de3c2d
@ -30,7 +30,7 @@
|
||||
<div class="single-result" [ngClass]="getVoteClass(vote)" *ngIf="vote && voteFitsMethod(vote)">
|
||||
<span>
|
||||
<span *ngIf="vote.showPercent">
|
||||
{{ vote.amount | pollPercentBase: poll }}
|
||||
{{ vote.amount | pollPercentBase: poll:'assignment' }}
|
||||
</span>
|
||||
{{ vote.amount | parsePollNumber }}
|
||||
</span>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<!-- Percent numbers -->
|
||||
<td class="result-cell-definition">
|
||||
<span *ngIf="row.value[0].showPercent">
|
||||
{{ row.value[0].amount | pollPercentBase: poll }}
|
||||
{{ row.value[0].amount | pollPercentBase: poll:'motion' }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
|
@ -14,7 +14,7 @@ import { PollData } from 'app/site/polls/services/poll.service';
|
||||
*
|
||||
* @example
|
||||
* ```html
|
||||
* <span> {{ voteYes | pollPercentBase: poll }} </span>
|
||||
* <span> {{ voteYes | pollPercentBase: poll:'assignment' }} </span>
|
||||
* ```
|
||||
*/
|
||||
@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 ((<any>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);
|
||||
|
@ -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 : ''
|
||||
}`;
|
||||
|
@ -94,7 +94,7 @@
|
||||
<os-icon-container [icon]="row.value[0].icon" size="large">
|
||||
{{ row.value[0].amount | parsePollNumber }}
|
||||
<span *ngIf="row.value[0].showPercent">
|
||||
{{ row.value[0].amount | pollPercentBase: poll }}
|
||||
{{ row.value[0].amount | pollPercentBase: poll:'motion' }}
|
||||
</span>
|
||||
</os-icon-container>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user