From 563bffa44f54141078805f3a49e4bdaef8a58b75 Mon Sep 17 00:00:00 2001
From: nicrausaz <n.crausaz99@gmail.com>
Date: Wed, 6 Mar 2019 11:34:43 +0100
Subject: [PATCH] remove animations

---
 canapEPFL/README.md                   |  4 ++--
 canapEPFL/cible.php                   | 10 +++++++---
 canapEPFL/script.js                   | 23 +++++++++++++----------
 canapEPFL/templates/errorTextEdit.php |  4 ++--
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/canapEPFL/README.md b/canapEPFL/README.md
index a304ddc..0807508 100644
--- a/canapEPFL/README.md
+++ b/canapEPFL/README.md
@@ -1,9 +1,9 @@
 # Améliorations en cours
 - [x] Utiliser la nouvelle charte 2018
 - [x] Adapter pour ajouter les postulations dans une DB
-- [x] Ajouter une page pour voir / supprimer sa / ses postulation(s)
+- [x] Ajouter une page pour voir / supprimer ses postulations
 - [x] Commentaires et section du code
-- [ ] Editer ses postulation
+- [ ] Editer ses postulations
 
 # Améliorations possibles du formulaire canap.epfl.ch
 
diff --git a/canapEPFL/cible.php b/canapEPFL/cible.php
index 55e1112..da7f332 100644
--- a/canapEPFL/cible.php
+++ b/canapEPFL/cible.php
@@ -45,9 +45,13 @@
         }
       } else {
         $_SESSION['formError'] = true;
-        $_SESSION['postedForm'] = $_POST;
-        $_SESSION['files'] = $_FILES;
-        include("templates/errorText.php");
+        if (isset($_GET['edit'])) {
+          include("templates/errorTextEdit.php");
+        } else {
+          $_SESSION['postedForm'] = $_POST;
+          $_SESSION['files'] = $_FILES;
+          include("templates/errorText.php");
+        }
       }
     ?>
   </body>
diff --git a/canapEPFL/script.js b/canapEPFL/script.js
index d73ef81..0e90a07 100644
--- a/canapEPFL/script.js
+++ b/canapEPFL/script.js
@@ -58,7 +58,7 @@ function addChildren(parentId, maxItems, childTemplate, addButtonId) {
         var fullTemplate = childTemplate.replace(/\{(.*?)\}/g, i);
         $(parentId).append(fullTemplate);
         if (i == maxItems - 1) {
-            $(addButtonId).hide(750);
+            $(addButtonId).hide();
         }
     }
 }
@@ -111,7 +111,7 @@ function initButtonsAction() {
         }
     });
     $('#editPost').click(function () {
-        document.location.href = "form.php?edit";
+        document.location.href = "/form.php?edit";
     });
     $('#cancelEditBtn').click(function () {
         document.location.href = "viewpostulation.php";
@@ -128,6 +128,9 @@ function initButtonsAction() {
     $('#retourFormulaire').click(function () {
         history.go(-1);
     });
+    $('#retourFormulaireEdit').click(function () {
+        document.location.href = "/form.php?edit";
+    });
     $('#retourAccueil').click(function () {
         document.location.href = "/index.php";
     });
@@ -157,23 +160,23 @@ function initAddChildButtons() {
                 + '<label for="annexe' + nextIndex + '" class="btn btn-secondary btn-sm icon-right">Choisir...</label><br>'
                 + '<small class="error" class="form-text text-muted"></small></td></tr>');
             if (nextIndex == 9) {
-                $('#addInputFile').hide(750);
+                $('#addInputFile').hide();
             }
         }
     });
 }
 
 function setMajState() {
-    $('#maj1')[0].checked ? $("#representants").show(1000) : $("#representants").hide(1000);
+    $('#maj1')[0].checked ? $("#representants").show() : $("#representants").hide();
 }
 
 function setDejaCandState() {
     if ($('#dejaCand1')[0].checked) {
-        $("#dejaCandAnnee").hide(750);
+        $("#dejaCandAnnee").hide();
         $("#dejaCandAnneeInput").val("");
         $("#dejaCandError").html("");
     } else {
-        $("#dejaCandAnnee").show(750);
+        $("#dejaCandAnnee").show();
     }
 }
 
@@ -265,10 +268,10 @@ function showListJob(lieu) {
 }
 function showPolyAndInfoDivs(selectedFormation) {
     if (selectedFormation != "menu") {
-        $("#all").show(1000);
-        selectedFormation == "informaticien" ? $("#infoOnly").show(1000) : $("#infoOnly").hide(500);
-        selectedFormation == "informaticien" ? $("#griTest").show(1000) : $("#griTest").hide(500);
-        selectedFormation == "polyMecanicien" ? $("#polyOnly").show(1000) : $("#polyOnly").hide(500);
+        $("#all").show();
+        selectedFormation == "informaticien" ? $("#infoOnly").show() : $("#infoOnly").hide();
+        selectedFormation == "informaticien" ? $("#griTest").show() : $("#griTest").hide();
+        selectedFormation == "polyMecanicien" ? $("#polyOnly").show() : $("#polyOnly").hide();
     }
 }
 
diff --git a/canapEPFL/templates/errorTextEdit.php b/canapEPFL/templates/errorTextEdit.php
index 4f93b7e..135aa23 100644
--- a/canapEPFL/templates/errorTextEdit.php
+++ b/canapEPFL/templates/errorTextEdit.php
@@ -5,12 +5,12 @@
       if (!$_POST && !$_FILES) {
         echo "<li>Fichiers fournis trop volumineux ! <small>(Taille recommandée env. 2Mo)</small></li>";
       } else {
-        echo "<li>" . $_SESSION['edit_error'] . "</li>";
+        echo $_SESSION['edit_error'] != '' ? "<li>" . $_SESSION['edit_error'] . "</li>" : '';
         foreach($validator->errors() as $error => $errorVal) {
           echo "<li>$errorVal</li>";
         }
       }
     ?>
   </div>
-  <button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="retourFormulaire">Retour au formulaire</button>
+  <button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="retourFormulaireEdit">Retour au formulaire</button>
 </main>
\ No newline at end of file
-- 
GitLab