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 > <h2 >Résumé</h2 >
<div class="preferred" > <div class="preferred" >
<i class='fa fa-star' ></i > <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}} ) Pour l'instant,
est : <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' > <span class='preferred-result' >
{{preferred}} {{preferred}}
</span > </span >
@ -14,11 +25,11 @@
Pseudo Pseudo
</td > </td >
<td <td
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' *ngFor='let choice of config.currentPoll.choices'
> >
{{k}} ) <!-- {{choice.id}} )-->
{{config.currentPoll.choices_count.counts[k].choice_text}} {{choice.text}}
</td > </td >
</tr > </tr >
<!-- somme des points, dont un demi point pour les "peut être" --> <!-- somme des points, dont un demi point pour les "peut être" -->
@ -31,29 +42,35 @@
<td > <td >
<i class='fa fa-plus-circle' ></i > points <i class='fa fa-plus-circle' ></i > points
</td > </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 <td
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' *ngFor='let choice of config.currentPoll.choices'
[ngClass]='{"has-max-score" : config.currentPoll.choices_count.maxScore === config.currentPoll.choices_count.counts[k].score}' > >
{{config.currentPoll.choices_count.counts[k].score}} id: {{choice.id}}
<!-- {{config.currentPoll.choices[choice.id].score}}-->
</td > </td >
</tr > </tr >
<tr class='details' > <tr class='details' >
<td > <td >
<i class='fa fa-eye' ></i > <i class='fa fa-eye' ></i >
</td > </td >
<td *ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' > <td *ngFor='let choice of config.currentPoll.choices' >
id: {{k}} id: {{choice.id}}
<br > <br >
yes {{config.currentPoll.choices_count.counts[k].yes.count}} <!-- yes {{config.currentPoll.choices_count.counts[choice.id].yes.count}}-->
<br > <!-- <br >-->
maybe <!-- maybe-->
{{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}} <!-- {{(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 > <br >
no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}} <!-- score :-->
<br > <!-- {{(config.currentPoll.choices_count.counts[choice.id].score)}}-->
score :
{{(config.currentPoll.choices_count.counts[k].score)}}
</td > </td >
</tr > </tr >
@ -74,8 +91,15 @@
</td > </td >
<td *ngFor='let v of getKeys(voteStack.votes)' > <td *ngFor='let v of getKeys(voteStack.votes)' >
<span *ngIf='voteStack.votes[v].value' > <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 > </span >
</td > </td >
</tr > </tr >

View File

@ -10,6 +10,7 @@ import {mockPoll3} from "../../../config/mocks/mock-poll3";
export class VotingSummaryComponent implements OnInit { export class VotingSummaryComponent implements OnInit {
preferred: string = 'rien'; preferred: string = 'rien';
severalPreferred: boolean = false;
@Input() pollconfig = mockPoll3; @Input() pollconfig = mockPoll3;
@ -19,6 +20,11 @@ export class VotingSummaryComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.computePreferred(); 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) { getKeys(obj) {
@ -29,9 +35,21 @@ export class VotingSummaryComponent implements OnInit {
* find the most "yes" * find the most "yes"
*/ */
computePreferred() { 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
}); });
} }