show preferred texts in summary, icons for votes

This commit is contained in:
Baptiste Lemoine 2020-01-30 12:55:40 +01:00
parent ca69160ea9
commit 0e8d18cd80
3 changed files with 252 additions and 870 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,19 @@
<h2 >Résumé</h2 >
<div class="preferred" >
<i class='fa fa-star' ></i >
Pour l'instant, le choix ayant reçu le plus grand nombre de votes ( {{config.currentPoll.choices_count.maxScore}} )
est :
Pour l'instant,
<span *ngIf='severalPreferred' >
les
</span > <span *ngIf='!severalPreferred' >
le
</span >
choix ayant reçu le plus grand nombre de votes ( {{config.currentPoll.choices_count.maxScore}} points )
<span *ngIf='severalPreferred' >
sont à égalité
</span > <span *ngIf='!severalPreferred' >
est
</span >
:
<span class='preferred-result' >
{{preferred}}
</span >
@ -14,11 +25,11 @@
Pseudo
</td >
<td
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )'
*ngFor='let choice of config.currentPoll.choices'
>
{{k}} )
{{config.currentPoll.choices_count.counts[k].choice_text}}
<!-- {{choice.id}} )-->
{{choice.text}}
</td >
</tr >
<!-- somme des points, dont un demi point pour les "peut être" -->
@ -31,29 +42,35 @@
<td >
<i class='fa fa-plus-circle' ></i > points
</td >
<!-- <td-->
<!-- *ngFor='let choice of config.currentPoll.choices'-->
<!-- [ngClass]='{"has-max-score" : config.currentPoll.choices_count.maxScore === config.currentPoll.choices_count.counts[choice.id].score}' >-->
<!-- {{config.currentPoll.choices[choice.id].score}}-->
<!-- </td >-->
<td
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )'
[ngClass]='{"has-max-score" : config.currentPoll.choices_count.maxScore === config.currentPoll.choices_count.counts[k].score}' >
{{config.currentPoll.choices_count.counts[k].score}}
*ngFor='let choice of config.currentPoll.choices'
>
id: {{choice.id}}
<!-- {{config.currentPoll.choices[choice.id].score}}-->
</td >
</tr >
<tr class='details' >
<td >
<i class='fa fa-eye' ></i >
</td >
<td *ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' >
id: {{k}}
<td *ngFor='let choice of config.currentPoll.choices' >
id: {{choice.id}}
<br >
yes {{config.currentPoll.choices_count.counts[k].yes.count}}
<br >
maybe
{{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}}
<!-- yes {{config.currentPoll.choices_count.counts[choice.id].yes.count}}-->
<!-- <br >-->
<!-- maybe-->
<!-- {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}}-->
<!-- <br >-->
<!-- no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}}-->
<br >
no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}}
<br >
score :
{{(config.currentPoll.choices_count.counts[k].score)}}
<!-- score :-->
<!-- {{(config.currentPoll.choices_count.counts[choice.id].score)}}-->
</td >
</tr >
@ -74,8 +91,15 @@
</td >
<td *ngFor='let v of getKeys(voteStack.votes)' >
<span *ngIf='voteStack.votes[v].value' >
id {{v}} )
{{voteStack.votes[v].value}}
<img
*ngIf="voteStack.votes[v].value == 'yes'"
src='../../../../assets/img/votant-sur.svg'
alt='yes' >
<img
*ngIf="voteStack.votes[v].value == 'maybe'"
src='../../../../assets/img/votant-pas-sur.svg'
alt='yes' >
</span >
</td >
</tr >

View File

@ -10,6 +10,7 @@ import {mockPoll3} from "../../../config/mocks/mock-poll3";
export class VotingSummaryComponent implements OnInit {
preferred: string = 'rien';
severalPreferred: boolean = false;
@Input() pollconfig = mockPoll3;
@ -19,6 +20,11 @@ export class VotingSummaryComponent implements OnInit {
ngOnInit() {
this.computePreferred();
console.log(' this.pollconfig.choices', this.pollconfig.choices)
console.log(' this.pollconfig.choices_count', this.pollconfig.choices_count.counts)
console.log('this.pollconfig.choices_count.counts[10]', this.pollconfig.choices_count.counts[10])
console.log('this.pollconfig.choices[2].id', this.pollconfig.choices[2].id)
console.log('this.pollconfig.choices_count.counts[]', this.pollconfig.choices_count.counts[this.pollconfig.choices[2].id].score)
}
getKeys(obj) {
@ -29,9 +35,21 @@ export class VotingSummaryComponent implements OnInit {
* find the most "yes"
*/
computePreferred() {
let keys = Object.keys(this.pollconfig.choices_count.counts);
this.preferred = '';
this.severalPreferred = false;
let maxScore = this.pollconfig.choices_count.maxScore;
keys.forEach(item => {
if (maxScore === this.pollconfig.choices_count.counts[item].score) {
if (this.preferred.length) {
this.preferred += ', '
this.severalPreferred = true;
}
// find the favourite
this.preferred += this.pollconfig.choices_count.counts[item].choice_text;
}
this.pollconfig.stacks.forEach(stack => {
// find the favourite
});
}