From 3c5278458c732890ca917a38d8243fffd5592065 Mon Sep 17 00:00:00 2001
From: Alexis Poyen <apoyen@mail.apoyen.fr>
Date: Thu, 11 Jun 2020 13:28:28 +0200
Subject: [PATCH] Feat : Update a CandidateList

---
 web/components/management/candidate-lists.js | 19 ++++++++++++-------
 web/components/management/rounds-card.js     |  8 ++++----
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/web/components/management/candidate-lists.js b/web/components/management/candidate-lists.js
index 1958dff..c58460c 100644
--- a/web/components/management/candidate-lists.js
+++ b/web/components/management/candidate-lists.js
@@ -1,6 +1,7 @@
 // Imports
 import * as Auth from "/services/auth/auth.js";
 import * as Common from "/services/common/common.js";
+import * as Messages from "/services/messages/messages.js";
 import * as AreaModel from "/services/model/area-model.js";
 import * as PartyModel from "/services/model/party-model.js";
 import * as CandidateListModel from "/services/model/candidateList-model.js";
@@ -256,7 +257,9 @@ class CandidateList {
           candidateListHandler.editCandidateList(candidateList);
         });
       document
-        .getElementById(`candidateLists-candidateList-delete-${candidateList.ID}`)
+        .getElementById(
+          `candidateLists-candidateList-delete-${candidateList.ID}`
+        )
         .addEventListener("click", function () {
           new Delete(() => {
             candidateListHandler.deleteCandidateList(candidateList);
@@ -280,21 +283,23 @@ class CandidateList {
     });
   }
 
-  newCandidateList() {
+  async newCandidateList() {
     this.method = "POST";
-    this.refreshParties();
+    await this.refreshParties();
     document.getElementById("candidateList-modal-id").value = null;
     document.getElementById("candidateList-modal-party").value = null;
     document.getElementById("candidateList-modal-name").value = null;
     Common.toggleModal("candidateList-modal", "candidateList-modal-card");
   }
 
-  editCandidateList(candidateList) {
+  async editCandidateList(candidateList) {
     this.method = "PUT";
-    this.refreshParties();
+    await this.refreshParties();
     document.getElementById("candidateList-modal-id").value = candidateList.ID;
-    document.getElementById("candidateList-modal-party").value = candidateList.PartyID;
-    document.getElementById("candidateList-modal-name").value = candidateList.Name;
+    document.getElementById("candidateList-modal-party").value =
+      candidateList.PartyID;
+    document.getElementById("candidateList-modal-name").value =
+      candidateList.Name;
     Common.toggleModal("candidateList-modal", "candidateList-modal-card");
   }
 
diff --git a/web/components/management/rounds-card.js b/web/components/management/rounds-card.js
index 19ead68..1dfb0e2 100644
--- a/web/components/management/rounds-card.js
+++ b/web/components/management/rounds-card.js
@@ -228,18 +228,18 @@ class Round {
     // TODO unselect candidateLists
   }
 
-  newRound() {
+  async newRound() {
     this.method = "POST";
-    this.refreshElections();
+    await this.refreshElections();
     document.getElementById("round-modal-id").value = null;
     document.getElementById("round-modal-date").value = null;
     document.getElementById("round-modal-round").value = null;
     Common.toggleModal("round-modal", "round-modal-card");
   }
 
-  editRound(round) {
+  async editRound(round) {
     this.method = "PUT";
-    this.refreshElections();
+    await this.refreshElections();
     document.getElementById("round-modal-id").value = round.ID;
     document.getElementById("round-modal-election-id").value = round.ElectionID;
     document.getElementById("round-modal-date").value = new Date(round.Date)
-- 
GitLab