Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ELC_elections
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gestion-des-assemblees
ELC_elections
Commits
e1ce07e2
Commit
e1ce07e2
authored
4 years ago
by
Alexis POYEN
Browse files
Options
Downloads
Patches
Plain Diff
Feat : display votes captured
parent
13d401a1
No related branches found
No related tags found
1 merge request
!42
Resolve "Capture votes"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/components/vote/votes.js
+89
-1
89 additions, 1 deletion
web/components/vote/votes.js
with
89 additions
and
1 deletion
web/components/vote/votes.js
+
89
−
1
View file @
e1ce07e2
...
...
@@ -6,6 +6,8 @@ import * as AreaModel from "/services/model/area-model.js";
import
*
as
SectionModel
from
"
/services/model/section-model.js
"
;
import
*
as
DeskModel
from
"
/services/model/desk-model.js
"
;
import
*
as
DeskRoundModel
from
"
/services/model/deskRound-model.js
"
;
import
*
as
VoteModel
from
"
/services/model/vote-model.js
"
;
import
*
as
CandidateListModel
from
"
/services/model/candidateList-model.js
"
;
export
async
function
mount
(
parent
)
{
const
voteComponent
=
new
Vote
(
parent
);
...
...
@@ -22,6 +24,8 @@ class Vote {
this
.
SectionModel
=
SectionModel
.
getSectionModel
();
this
.
DeskModel
=
DeskModel
.
getDeskModel
();
this
.
DeskRoundModel
=
DeskRoundModel
.
getDeskRoundModel
();
this
.
VoteModel
=
VoteModel
.
getVoteModel
();
this
.
CandidateListModel
=
CandidateListModel
.
getCandidateListModel
();
}
async
displayVotes
(
RoundID
,
AreaID
,
DeskRoundID
)
{
...
...
@@ -31,6 +35,8 @@ class Vote {
this
.
SectionModel
.
current_user
=
await
Auth
.
GetUser
();
this
.
DeskModel
.
current_user
=
await
Auth
.
GetUser
();
this
.
DeskRoundModel
.
current_user
=
await
Auth
.
GetUser
();
this
.
VoteModel
.
current_user
=
await
Auth
.
GetUser
();
this
.
CandidateListModel
.
current_user
=
await
Auth
.
GetUser
();
this
.
RoundID
=
RoundID
;
this
.
AreaID
=
AreaID
;
...
...
@@ -44,7 +50,7 @@ class Vote {
</nav>
</p>
</header>
<div id="votes-table
s
" class="card-content"></div>
<div id="votes-table" class="card-content"></div>
<nav class="level">
<div class="level-left"></div>
<div class="level-right">
...
...
@@ -63,9 +69,28 @@ class Vote {
this
.
handleDom
();
await
this
.
refreshBreadCrumb
();
await
this
.
loadVotes
();
}
voteTemplate
(
candidateList
)
{
return
/* HTML */
`
<tr id="votes-vote-
${
candidateList
.
ID
}
">
<td>
${
candidateList
.
Name
}
</td>
<td>
<input
class="input"
type="number"
id="
${
candidateList
.
ID
}
-vote-voice"
/>
</td>
</tr>
`
;
}
handleDom
()
{}
async
refreshBreadCrumb
()
{
let
round
=
await
this
.
RoundModel
.
getRound
(
this
.
RoundID
);
let
election
=
await
this
.
ElectionModel
.
getElection
(
round
.
ElectionID
);
...
...
@@ -96,4 +121,67 @@ class Vote {
el
.
innerHTML
=
"
<a>
"
+
desk
.
Name
+
"
</a>
"
;
breadcrumb
.
appendChild
(
el
);
}
async
loadVotes
()
{
document
.
getElementById
(
"
votes-table
"
).
innerHTML
=
/* HTML */
`<div
class="table-container"
>
<table class="table is-bordered is-narrow is-hoverable is-fullwidth">
<thead>
<tr class="is-selected">
<th>Liste</th>
<th>Nombre de voix</th>
</tr>
</thead>
<tbody id="votes-list"></tbody>
</table>
</div> `
;
let
voteHandler
=
this
;
let
votes
=
await
this
.
VoteModel
.
getVotes
();
votes
=
votes
.
filter
((
vote
)
=>
{
return
vote
.
DeskRoundID
==
voteHandler
.
DeskRoundID
;
});
console
.
log
(
votes
);
let
candidateLists
=
await
this
.
CandidateListModel
.
getCandidateLists
();
candidateLists
=
candidateLists
.
filter
((
candidateList
)
=>
{
return
candidateList
.
AreaID
==
voteHandler
.
AreaID
;
});
const
markup
=
candidateLists
.
map
((
vote
)
=>
this
.
voteTemplate
(
vote
))
.
join
(
""
);
document
.
getElementById
(
"
votes-list
"
).
innerHTML
=
markup
;
document
.
getElementById
(
"
votes-list
"
).
innerHTML
+=
/* HTML */
`
<tr">
<td>Votes blanc</td>
<td>
<input
class="input"
type="number"
id="blank-vote-voice"
/>
</td>
</tr>
`
;
document
.
getElementById
(
"
votes-list
"
).
innerHTML
+=
/* HTML */
`
<tr>
<td>Votes nul</td>
<td>
<input class="input" type="number" id="null-vote-voice" />
</td>
</tr>
`
;
votes
.
forEach
((
vote
)
=>
{
if
(
vote
.
Blank
)
{
document
.
getElementById
(
"
blank-vote-voice
"
).
value
=
vote
.
VoiceNumber
;
}
else
if
(
vote
.
NullVote
)
{
document
.
getElementById
(
"
null-vote-voice
"
).
value
=
vote
.
VoiceNumber
;
}
else
{
document
.
getElementById
(
vote
.
CandidateListID
+
"
-vote-voice
"
).
value
=
vote
.
VoiceNumber
;
}
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment