Various small fixes

- Fix an issue in motion PDF which affected motion result percent
  values
- Fix an issue where the voting result bar chart hat a chance to show
  "null"
- Change the available votes display to count down instead of up
- Add the correct button class to the global abstain button
- Add some translatable strings
This commit is contained in:
Sean 2020-03-17 18:38:35 +01:00 committed by Emanuel Schütze
parent 58483d7024
commit ee07e8f0ce
5 changed files with 32 additions and 16 deletions

View File

@ -9,8 +9,8 @@ const PollValues = {
yes: 'Yes',
no: 'No',
abstain: 'Abstain',
amount_global_abstain: 'General abstain',
amount_global_no: 'General no'
amount_global_abstain: 'General Abstain',
amount_global_no: 'General No'
};
/**

View File

@ -6,10 +6,12 @@
</p>
<!-- Leftover votes -->
<h4
*ngIf="poll.pollmethod === AssignmentPollMethod.Votes && poll.votes_amount > 1"
>
{{ 'Available votes' | translate }}: {{ getVotesCount() }}/{{ poll.votes_amount }}
<h4 *ngIf="poll.pollmethod === AssignmentPollMethod.Votes && poll.votes_amount > 1">
{{ 'Available votes' | translate }}:
<b>
{{ getVotesAvailable() }}/{{ poll.votes_amount }}
</b>
</h4>
<!-- Options and Actions -->
@ -75,6 +77,7 @@
<div *ngIf="poll.global_abstain">
<button
class="vote-button"
mat-raised-button
(click)="saveGlobalVote('A')"
[ngClass]="voteRequestData.global === 'A' ? 'voted-abstain' : ''"

View File

@ -96,6 +96,10 @@ export class AssignmentPollVoteComponent extends BasePollVoteComponent<ViewAssig
return Object.keys(this.voteRequestData.votes).filter(key => this.voteRequestData.votes[key]).length;
}
public getVotesAvailable(): number {
return this.poll.votes_amount - this.getVotesCount();
}
private isGlobalOptionSelected(): boolean {
return !!this.voteRequestData.global;
}

View File

@ -13,7 +13,6 @@ import { LinenumberingService } from 'app/core/ui-services/linenumbering.service
import { ViewUnifiedChange, ViewUnifiedChangeType } from 'app/shared/models/motions/view-unified-change';
import { ParsePollNumberPipe } from 'app/shared/pipes/parse-poll-number.pipe';
import { PollKeyVerbosePipe } from 'app/shared/pipes/poll-key-verbose.pipe';
import { PollPercentBasePipe } from 'app/shared/pipes/poll-percent-base.pipe';
import { getRecommendationTypeName } from 'app/shared/utils/recommendation-type-names';
import { MotionExportInfo } from './motion-export.service';
import { MotionPollService } from './motion-poll.service';
@ -67,7 +66,6 @@ export class MotionPdfService {
private linenumberingService: LinenumberingService,
private commentRepo: MotionCommentSectionRepositoryService,
private pollKeyVerbose: PollKeyVerbosePipe,
private pollPercentBase: PollPercentBasePipe,
private parsePollNumber: ParsePollNumberPipe,
private motionPollService: MotionPollService
) {}
@ -381,11 +379,13 @@ export class MotionPdfService {
const value = votingResult.value[0];
const resultValue = this.parsePollNumber.transform(value.amount);
column1.push(`${votingOption}:`);
column2.push(resultValue);
if (value.showPercent) {
const resultInPercent = this.pollPercentBase.transform(value.amount, poll);
column3.push(resultInPercent);
const resultInPercent = this.motionPollService.getVoteValueInPercent(value.amount, poll);
column2.push(`(${resultInPercent})`);
} else {
column2.push('');
}
column3.push(resultValue);
});
}
});

View File

@ -203,8 +203,10 @@ export abstract class PollService {
const totalByBase = this.getPercentBase(poll);
if (totalByBase && totalByBase > 0) {
const percentNumber = (value / totalByBase) * 100;
const result = percentNumber % 1 === 0 ? percentNumber : percentNumber.toFixed(PERCENT_DECIMAL_PLACES);
return `${result} %`;
if (percentNumber >= 0) {
const result = percentNumber % 1 === 0 ? percentNumber : percentNumber.toFixed(PERCENT_DECIMAL_PLACES);
return `${result} %`;
}
}
return null;
}
@ -349,10 +351,17 @@ export abstract class PollService {
const fields = this.getPollDataFields(poll);
return poll.options.map(option => {
const votingResults = fields.map(field => {
const voteValue = option[field];
const votingKey = this.translate.instant(this.pollKeyVerbose.transform(field));
const resultValue = this.parsePollNumber.transform(option[field]);
const resultInPercent = this.getVoteValueInPercent(option[field], poll);
return `${votingKey} ${resultValue} (${resultInPercent})`;
const resultValue = this.parsePollNumber.transform(voteValue);
const resultInPercent = this.getVoteValueInPercent(voteValue, poll);
let resultLabel = `${votingKey}: ${resultValue}`;
// 0 is a valid number in this case
if (resultInPercent !== null) {
resultLabel += ` (${resultInPercent})`;
}
return resultLabel;
});
return `${option.user.short_name} · ${votingResults.join(' · ')}`;