Enumber Voting results

Enumber the rank of voting results in PDF, Projector and Detail View
This commit is contained in:
Sean 2021-05-05 14:49:42 +02:00
parent 7cf22b86ab
commit 18c75a6d12
2 changed files with 17 additions and 3 deletions

View File

@ -2,6 +2,7 @@
<table class="assignment-result-table" *ngIf="hasResults && canSeeResults"> <table class="assignment-result-table" *ngIf="hasResults && canSeeResults">
<tbody> <tbody>
<tr> <tr>
<td></td>
<th class="voting-option">{{ 'Candidates' | translate }}</th> <th class="voting-option">{{ 'Candidates' | translate }}</th>
<th class="result yes" *ngIf="showYHeader"> <th class="result yes" *ngIf="showYHeader">
<span *ngIf="!isMethodY"> <span *ngIf="!isMethodY">
@ -21,7 +22,10 @@
</th> </th>
<th class="result abstain" *ngIf="isMethodYNA">{{ 'Abstain' | translate }}</th> <th class="result abstain" *ngIf="isMethodYNA">{{ 'Abstain' | translate }}</th>
</tr> </tr>
<tr *ngFor="let row of tableData" [class]="row.class"> <tr *ngFor="let row of tableData; let i = index" [class]="row.class">
<td>
<span *ngIf="row.class === 'user'">{{ i + 1 }}.</span>
</td>
<td class="voting-option"> <td class="voting-option">
<div> <div>
<span> <span>
@ -50,6 +54,7 @@
</td> </td>
</tr> </tr>
<tr *ngIf="isPercentBaseEntitled && poll.entitled_users_at_stop" class="entitled-users-row"> <tr *ngIf="isPercentBaseEntitled && poll.entitled_users_at_stop" class="entitled-users-row">
<td></td>
<td>{{ 'Entitled users' | translate }}</td> <td>{{ 'Entitled users' | translate }}</td>
<td class="result"> <td class="result">
<div class="single-result"> <div class="single-result">

View File

@ -175,6 +175,10 @@ export class AssignmentPdfService {
}); });
pollTableBody.push([ pollTableBody.push([
{
text: '',
style: 'tableHeader'
},
{ {
text: this.translate.instant('Candidates'), text: this.translate.instant('Candidates'),
style: 'tableHeader' style: 'tableHeader'
@ -186,10 +190,15 @@ export class AssignmentPdfService {
]); ]);
const tableData = this.assignmentPollService.generateTableData(poll); const tableData = this.assignmentPollService.generateTableData(poll);
for (const pollResult of tableData) { for (const [index, pollResult] of tableData.entries()) {
const rank = pollResult.class === 'user' ? index + 1 : '';
const voteOption = this.translate.instant(this.pollKeyVerbose.transform(pollResult.votingOption)); const voteOption = this.translate.instant(this.pollKeyVerbose.transform(pollResult.votingOption));
const resultLine = this.getPollResult(pollResult, poll); const resultLine = this.getPollResult(pollResult, poll);
const tableLine = [ const tableLine = [
{
text: rank
},
{ {
text: voteOption text: voteOption
}, },
@ -203,7 +212,7 @@ export class AssignmentPdfService {
resultBody.push({ resultBody.push({
table: { table: {
widths: ['64%', '33%'], widths: ['3%', '65%', '33%'],
headerRows: 1, headerRows: 1,
body: pollTableBody body: pollTableBody
}, },