parent
7b790e3cdc
commit
1b65d58a6f
@ -0,0 +1,24 @@
|
||||
export var graphOptions = {
|
||||
legend: {display: false},
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
gridLines: {drawBorder: false, display: false},
|
||||
display: false,
|
||||
stacked: true,
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
maxRotation: 0,
|
||||
minRotation: 0
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxes: [
|
||||
{
|
||||
gridLines: {drawBorder: true, display: false},
|
||||
display: true,
|
||||
stacked: true
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
@ -1 +1,28 @@
|
||||
<p>voting-summary works!</p>
|
||||
<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 est :
|
||||
<span class='preferred-result' >
|
||||
{{preferred}}
|
||||
</span >
|
||||
</div >
|
||||
<div
|
||||
class='line vote-stack'
|
||||
*ngFor='let voteStack of pollconfig.stacks' >
|
||||
|
||||
<div class='vs' >
|
||||
<div class='person' >
|
||||
{{voteStack.pseudo}}
|
||||
</div >
|
||||
<div class='votes-of-the-person' >
|
||||
<div
|
||||
class='vote'
|
||||
*ngFor='let v of voteStack.votes' >
|
||||
<div class='id' >
|
||||
{{v.id}}
|
||||
{{v.answer}}
|
||||
</div >
|
||||
</div >
|
||||
</div >
|
||||
</div >
|
||||
</div >
|
||||
|
@ -0,0 +1,8 @@
|
||||
.person {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.preferred-result {
|
||||
font-weight: 700;
|
||||
font-size: 1.5em;
|
||||
}
|
@ -1,19 +1,64 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {BaseComponent} from "../../base-page/base.component";
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {ConfigService} from "../../../services/config.service";
|
||||
import {mockPoll3} from "../../../config/mock-poll3";
|
||||
|
||||
@Component({
|
||||
selector: 'framadate-voting-summary',
|
||||
templateUrl: './voting-summary.component.html',
|
||||
styleUrls: ['./voting-summary.component.scss']
|
||||
selector: 'framadate-voting-summary',
|
||||
templateUrl: './voting-summary.component.html',
|
||||
styleUrls: ['./voting-summary.component.scss']
|
||||
})
|
||||
export class VotingSummaryComponent extends BaseComponent implements OnInit {
|
||||
export class VotingSummaryComponent implements OnInit {
|
||||
|
||||
private preferred: string = 'rien';
|
||||
private counters: any = {};
|
||||
|
||||
@Input() private pollconfig = mockPoll3;
|
||||
|
||||
constructor(private config: ConfigService) {
|
||||
|
||||
constructor(public config: ConfigService) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
this.computePreferred();
|
||||
}
|
||||
|
||||
/**
|
||||
* find the most "yes"
|
||||
*/
|
||||
computePreferred() {
|
||||
|
||||
let maximumYesCount = 0;
|
||||
let choice_id_max = 0;
|
||||
let winners_id = [];
|
||||
this.pollconfig.stacks.map(stack => {
|
||||
|
||||
stack.votes.map(vote => {
|
||||
let choice_id = vote.id;
|
||||
let answer = vote.answer;
|
||||
if (!this.counters["choice_" + choice_id]) {
|
||||
this.counters["choice_" + choice_id] = {
|
||||
yes: 0,
|
||||
maybe: 0,
|
||||
no: 0,
|
||||
}
|
||||
}
|
||||
this.counters["choice_" + choice_id][answer]++;
|
||||
if (this.counters["choice_" + choice_id]['yes'] > maximumYesCount) {
|
||||
choice_id_max = choice_id;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// find the favourite
|
||||
})
|
||||
console.log('this.counters', this.counters);
|
||||
let choiceTitleFound = this.pollconfig.choices.find(elem => {
|
||||
return elem.id === parseInt(choice_id_max)
|
||||
})
|
||||
this.preferred = choiceTitleFound.name;
|
||||
console.log('choiceTitleFound', choiceTitleFound)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#selectColorblind {
|
||||
direction: rtl;
|
||||
padding:0;
|
||||
}
|
||||
|
Loading…
Reference in new issue