Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Imports
import * as Auth from "/services/auth/auth.js";
import * as PartyModel from "/services/model/party-model.js";
import * as CandidateListModel from "/services/model/candidateList-model.js";
import * as AreaModel from "/services/model/area-model.js";
export async function mount(where, parent) {
const resultGeneralComponent = new ResultGeneralComponent(parent);
await resultGeneralComponent.mount(where);
return resultGeneralComponent;
}
class ResultGeneralComponent {
constructor(parent) {
this.parent = parent;
this.PartyModel = PartyModel.getPartyModel();
this.CandidateListModel = CandidateListModel.getCandidateListModel();
this.AreaModel = AreaModel.getAreaModel();
}
async mount(where) {
this.PartyModel.current_user = await Auth.GetUser();
this.CandidateListModel.current_user = await Auth.GetUser();
this.AreaModel.current_user = await Auth.GetUser();
const mountpoint = where;
document.getElementById(mountpoint).innerHTML = /* HTML */ `
<div class="column is-half">
<div class="card-no-hover">
<header class="card-header">
<p class="card-header-title">
Résultats du tour
</p>
</header>
<div id="round-results" class="content"></div>
<div id="round-detaileds-results" class="content"></div>
</div>
</div>
<div class="column is-half">
<div class="card-no-hover">
<header class="card-header">
<p class="card-header-title">
Statistiques
</p>
</header>
<div id="stats-results" class="content"></div>
</div>
</div>
`;
this.handleDom();
this.displayRoundResults();
}
handleDom() {}
displayRoundResults() {
document.getElementById("round-results").innerHTML = "";
if (this.parent.results.status == this.parent.filter) {
for (let i in this.parent.results.roundResults) {
let electeds = this.parent.results.candidateLists
.filter((candidateList) => {
return (
candidateList.PartyID == this.parent.results.roundResults[i].ID
);
})
.reduce((electeds, candidateList) => {
return electeds + candidateList.SeatsAttributed;
}, 0);
document.getElementById(
"round-results"
).innerHTML += this.parent.progressBarTemplate(
this.parent.results.roundResults[i],
this.parent.results.roundResults[i].Color,
electeds
);
}
} else {
if (this.parent.results.status == "no_results") {
document.getElementById(
"round-results"
).innerHTML = this.parent.showWarningResults(
"Aucun résultats n'ont étaient saisis sur cette zone"
);
} else if (this.parent.results.status == "incompleted") {
document.getElementById(
"round-results"
).innerHTML = this.parent.showWarningResults(
"Les résultats pour cette zone ne sont pas complets"
);
} else if (this.parent.results.status == "not validated") {
document.getElementById(
"round-results"
).innerHTML = this.parent.showWarningResults(
"Les résultats pour cette zone n'ont pas étaient validés"
);
}
}
this.displayRoundDetailedResults();
}
async displayRoundDetailedResults() {
document.getElementById("round-detaileds-results").innerHTML =
'<br/><h5 class="title is-5">Statistiques</h5>';
if (this.parent.filter === "partial")
document.getElementById(
"round-detaileds-results"
).innerHTML += this.parent.progressBarTemplate(
{
Name: "Pourcentage de saisie",
Percentage: this.parent.results.stats.PercentageConsiderated,
VoiceNumber: null,
},
"grey",
null
);
document.getElementById(
"round-detaileds-results"
).innerHTML += this.parent.progressBarTemplate(
{
Name: "Abstention",
Percentage: this.parent.results.stats.Abstention,
VoiceNumber: null,
},
"grey",
null
);
document.getElementById(
"round-detaileds-results"
).innerHTML += this.parent.progressBarTemplate(
{
Name: "Votes blancs",
Percentage: this.parent.results.stats.BlankPercentage,
VoiceNumber: this.parent.results.stats.BlankVoiceNumber,
},
"grey",
null
);
document.getElementById(
"round-detaileds-results"
).innerHTML += this.parent.progressBarTemplate(
{
Name: "Votes nuls",
Percentage: this.parent.results.stats.NullVotePercentage,
VoiceNumber: this.parent.results.stats.NullVoteVoiceNumber,
},
"grey",
null
);
}
}