Skip to content
Snippets Groups Projects
Commit 078cd553 authored by Alexis POYEN's avatar Alexis POYEN
Browse files

Feat : delete votes

parent 3aeaa8ff
No related branches found
No related tags found
1 merge request!42Resolve "Capture votes"
...@@ -54,12 +54,15 @@ class Vote { ...@@ -54,12 +54,15 @@ class Vote {
<nav class="level"> <nav class="level">
<div class="level-left"></div> <div class="level-left"></div>
<div class="level-right"> <div class="level-right">
<button id="votes-return" class="button is-danger level-item"> <button id="votes-return" class="button level-item">
Retour Retour
</button> </button>
<button id="votes-cancel" class="button level-item"> <button id="votes-cancel" class="button level-item">
Annuler Annuler
</button> </button>
<button id="votes-delete" class="button is-danger level-item">
Supprimer
</button>
<button id="votes-save" class="button is-success level-item"> <button id="votes-save" class="button is-success level-item">
Sauvegarder Sauvegarder
</button> </button>
...@@ -106,6 +109,11 @@ class Vote { ...@@ -106,6 +109,11 @@ class Vote {
.addEventListener("click", function () { .addEventListener("click", function () {
voteHandler.saveVotes(); voteHandler.saveVotes();
}); });
document
.getElementById(`votes-delete`)
.addEventListener("click", function () {
voteHandler.deleteVotes();
});
} }
async refreshBreadCrumb() { async refreshBreadCrumb() {
...@@ -154,7 +162,6 @@ class Vote { ...@@ -154,7 +162,6 @@ class Vote {
</table> </table>
</div> `; </div> `;
let voteHandler = this;
let votes = await this.updatesVotes(); let votes = await this.updatesVotes();
let candidateLists = await this.updateCandidateLists(); let candidateLists = await this.updateCandidateLists();
...@@ -238,6 +245,7 @@ class Vote { ...@@ -238,6 +245,7 @@ class Vote {
} }
async updatesVotes() { async updatesVotes() {
let voteHandler = this;
let votes = await this.VoteModel.getVotes(); let votes = await this.VoteModel.getVotes();
return votes.filter((vote) => { return votes.filter((vote) => {
return vote.DeskRoundID == voteHandler.DeskRoundID; return vote.DeskRoundID == voteHandler.DeskRoundID;
...@@ -245,7 +253,8 @@ class Vote { ...@@ -245,7 +253,8 @@ class Vote {
} }
async updateCandidateLists() { async updateCandidateLists() {
let canddiateLists = await this.CandidateListModel.getCandidateLists(); let voteHandler = this;
let candidateLists = await this.CandidateListModel.getCandidateLists();
return candidateLists.filter((candidateList) => { return candidateLists.filter((candidateList) => {
return ( return (
candidateList.AreaID == voteHandler.AreaID && candidateList.AreaID == voteHandler.AreaID &&
...@@ -253,4 +262,14 @@ class Vote { ...@@ -253,4 +262,14 @@ class Vote {
); );
}); });
} }
async deleteVotes() {
let voteHandler = this;
let votes = await this.updatesVotes();
votes.forEach(async (vote) => {
await voteHandler.VoteModel.deleteVote(vote.ID);
await voteHandler.VoteModel.refreshVotes();
await voteHandler.loadVotes();
});
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment