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:
parent
58483d7024
commit
ee07e8f0ce
@ -9,8 +9,8 @@ const PollValues = {
|
|||||||
yes: 'Yes',
|
yes: 'Yes',
|
||||||
no: 'No',
|
no: 'No',
|
||||||
abstain: 'Abstain',
|
abstain: 'Abstain',
|
||||||
amount_global_abstain: 'General abstain',
|
amount_global_abstain: 'General Abstain',
|
||||||
amount_global_no: 'General no'
|
amount_global_no: 'General No'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Leftover votes -->
|
<!-- Leftover votes -->
|
||||||
<h4
|
<h4 *ngIf="poll.pollmethod === AssignmentPollMethod.Votes && poll.votes_amount > 1">
|
||||||
*ngIf="poll.pollmethod === AssignmentPollMethod.Votes && poll.votes_amount > 1"
|
{{ 'Available votes' | translate }}:
|
||||||
>
|
|
||||||
{{ 'Available votes' | translate }}: {{ getVotesCount() }}/{{ poll.votes_amount }}
|
<b>
|
||||||
|
{{ getVotesAvailable() }}/{{ poll.votes_amount }}
|
||||||
|
</b>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<!-- Options and Actions -->
|
<!-- Options and Actions -->
|
||||||
@ -75,6 +77,7 @@
|
|||||||
|
|
||||||
<div *ngIf="poll.global_abstain">
|
<div *ngIf="poll.global_abstain">
|
||||||
<button
|
<button
|
||||||
|
class="vote-button"
|
||||||
mat-raised-button
|
mat-raised-button
|
||||||
(click)="saveGlobalVote('A')"
|
(click)="saveGlobalVote('A')"
|
||||||
[ngClass]="voteRequestData.global === 'A' ? 'voted-abstain' : ''"
|
[ngClass]="voteRequestData.global === 'A' ? 'voted-abstain' : ''"
|
||||||
|
@ -96,6 +96,10 @@ export class AssignmentPollVoteComponent extends BasePollVoteComponent<ViewAssig
|
|||||||
return Object.keys(this.voteRequestData.votes).filter(key => this.voteRequestData.votes[key]).length;
|
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 {
|
private isGlobalOptionSelected(): boolean {
|
||||||
return !!this.voteRequestData.global;
|
return !!this.voteRequestData.global;
|
||||||
}
|
}
|
||||||
|
@ -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 { ViewUnifiedChange, ViewUnifiedChangeType } from 'app/shared/models/motions/view-unified-change';
|
||||||
import { ParsePollNumberPipe } from 'app/shared/pipes/parse-poll-number.pipe';
|
import { ParsePollNumberPipe } from 'app/shared/pipes/parse-poll-number.pipe';
|
||||||
import { PollKeyVerbosePipe } from 'app/shared/pipes/poll-key-verbose.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 { getRecommendationTypeName } from 'app/shared/utils/recommendation-type-names';
|
||||||
import { MotionExportInfo } from './motion-export.service';
|
import { MotionExportInfo } from './motion-export.service';
|
||||||
import { MotionPollService } from './motion-poll.service';
|
import { MotionPollService } from './motion-poll.service';
|
||||||
@ -67,7 +66,6 @@ export class MotionPdfService {
|
|||||||
private linenumberingService: LinenumberingService,
|
private linenumberingService: LinenumberingService,
|
||||||
private commentRepo: MotionCommentSectionRepositoryService,
|
private commentRepo: MotionCommentSectionRepositoryService,
|
||||||
private pollKeyVerbose: PollKeyVerbosePipe,
|
private pollKeyVerbose: PollKeyVerbosePipe,
|
||||||
private pollPercentBase: PollPercentBasePipe,
|
|
||||||
private parsePollNumber: ParsePollNumberPipe,
|
private parsePollNumber: ParsePollNumberPipe,
|
||||||
private motionPollService: MotionPollService
|
private motionPollService: MotionPollService
|
||||||
) {}
|
) {}
|
||||||
@ -381,11 +379,13 @@ export class MotionPdfService {
|
|||||||
const value = votingResult.value[0];
|
const value = votingResult.value[0];
|
||||||
const resultValue = this.parsePollNumber.transform(value.amount);
|
const resultValue = this.parsePollNumber.transform(value.amount);
|
||||||
column1.push(`${votingOption}:`);
|
column1.push(`${votingOption}:`);
|
||||||
column2.push(resultValue);
|
|
||||||
if (value.showPercent) {
|
if (value.showPercent) {
|
||||||
const resultInPercent = this.pollPercentBase.transform(value.amount, poll);
|
const resultInPercent = this.motionPollService.getVoteValueInPercent(value.amount, poll);
|
||||||
column3.push(resultInPercent);
|
column2.push(`(${resultInPercent})`);
|
||||||
|
} else {
|
||||||
|
column2.push('');
|
||||||
}
|
}
|
||||||
|
column3.push(resultValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -203,8 +203,10 @@ export abstract class PollService {
|
|||||||
const totalByBase = this.getPercentBase(poll);
|
const totalByBase = this.getPercentBase(poll);
|
||||||
if (totalByBase && totalByBase > 0) {
|
if (totalByBase && totalByBase > 0) {
|
||||||
const percentNumber = (value / totalByBase) * 100;
|
const percentNumber = (value / totalByBase) * 100;
|
||||||
const result = percentNumber % 1 === 0 ? percentNumber : percentNumber.toFixed(PERCENT_DECIMAL_PLACES);
|
if (percentNumber >= 0) {
|
||||||
return `${result} %`;
|
const result = percentNumber % 1 === 0 ? percentNumber : percentNumber.toFixed(PERCENT_DECIMAL_PLACES);
|
||||||
|
return `${result} %`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -349,10 +351,17 @@ export abstract class PollService {
|
|||||||
const fields = this.getPollDataFields(poll);
|
const fields = this.getPollDataFields(poll);
|
||||||
return poll.options.map(option => {
|
return poll.options.map(option => {
|
||||||
const votingResults = fields.map(field => {
|
const votingResults = fields.map(field => {
|
||||||
|
const voteValue = option[field];
|
||||||
const votingKey = this.translate.instant(this.pollKeyVerbose.transform(field));
|
const votingKey = this.translate.instant(this.pollKeyVerbose.transform(field));
|
||||||
const resultValue = this.parsePollNumber.transform(option[field]);
|
const resultValue = this.parsePollNumber.transform(voteValue);
|
||||||
const resultInPercent = this.getVoteValueInPercent(option[field], poll);
|
const resultInPercent = this.getVoteValueInPercent(voteValue, poll);
|
||||||
return `${votingKey} ${resultValue} (${resultInPercent})`;
|
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(' · ')}`;
|
return `${option.user.short_name} · ${votingResults.join(' · ')}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user