From 709e7eade68e24ded4ff94a6a040c95336d826a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Passerat?=
 <jeremie.passerat@etu.univ-orleans.fr>
Date: Wed, 9 Jun 2021 17:04:21 +0200
Subject: [PATCH] Fonctions 'detail contenu' ok

---
 src/Index.vue                        |   2 +-
 src/Maj.vue                          | 195 +++++++++++++++------------
 src/components/Consulter_Contenu.vue |  11 +-
 src/components/Volet_Base.vue        |  84 ++++++------
 src/service/Service.js               |  13 +-
 5 files changed, 165 insertions(+), 140 deletions(-)

diff --git a/src/Index.vue b/src/Index.vue
index bf0f9cdb..d0ae1f1e 100644
--- a/src/Index.vue
+++ b/src/Index.vue
@@ -4,7 +4,7 @@
 
     <Menu v-show="etat !== 'unlogged'" v-bind:auteur="auteur" v-bind:etat="etat" v-bind:isNotif="isNotif"  v-bind:variante="variante" @menu_choisi="changerPage"></Menu>
     <Contenu v-show="etat === 'Contenu'"  v-bind:auteur="auteur"  @choix_variante="choixVariante" @publication="publication"></Contenu>
-    <Maj v-show="etat === 'Mises à jour'"  v-bind:contenuEnPublication="contenuEnPublication" ></Maj>
+    <Maj v-show="etat === 'Mises à jour'" v-bind:auteur="auteur"  v-bind:contenuEnPublication="contenuEnPublication" ></Maj>
     <Profil v-show="etat === 'Profil'"  ></Profil>
     <Tags v-show="etat === 'Tags'"  ></Tags>
     <p style="text-align: center" v-show="errorLogin">Login ou mot de passe erroné</p>
diff --git a/src/Maj.vue b/src/Maj.vue
index 0e30b6f6..26445608 100644
--- a/src/Maj.vue
+++ b/src/Maj.vue
@@ -2,115 +2,134 @@
   <div>
     <span class="niveau" id="recues" v-on:click="naviguer">Maj Recues</span><br>
     <div id="detailRecues" class="masque">
-    <table>
-      <thead>
-      <tr>
-        <th colspan="6">Contenus</th>
-      </tr>
-      </thead>
-      <tr>
-        <th>Titre</th>
-        <th>Auteur</th>
-        <th>Version actuelle</th>
-        <th>Date Version actuelle</th>
-        <th>Accepter</th>
-        <th>Refuser</th>
-
-
-      </tr>
-      <tbody>
-
-
-      <tr>
-        <td>Contenu1</td>
-        <td>Auteur1</td>
-        <td>1</td>
-        <td>01/06/2021</td>
-        <td id="valider"><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
-        <td id="refuser"><img v-bind:src="imageCroix"   alt='' height=20 width=20></td>
-
-      </tr>
-      </tbody>
-    </table>
+      <table>
+        <thead>
+        <tr>
+          <th colspan="6">Contenus</th>
+        </tr>
+        </thead>
+        <tr>
+          <th>Titre</th>
+          <th>Auteur</th>
+          <th>Version actuelle</th>
+          <th>Date Version actuelle</th>
+          <th>Accepter</th>
+          <th>Refuser</th>
+
+
+        </tr>
+        <tbody>
+
+<!--        <tr v-show="!panierChoisi" v-for="item in contenusbanque" :key="item.titre">
+          <td class="modal titreContenu" v-on:click="chargerContenu(item, 'banque')" v-popover:tooltip="'prévisualisation'">{{ item._id }}</td>
+          <td>{{ item.auteur }}</td>
+          <td>The table body</td>
+          <td>with two columns</td>
+          <td>with two columns</td>
+          <td>with two columns</td>
+          <td class="modal tagContenu" v-popover:tooltip="'tags'">with two columns</td>
+
+          <td class="boutonSupprimer">  <input type="checkbox" v-on:change="ajouterCoche(item._id, item.versionEnCours)" class="horns" name="horns"/></td>
+
+        </tr>-->
+
+        <tr v-for="item in contenusRecu" :key="item._id">
+          <td>Contenu1</td>
+          <td>{{ item.auteurDemande }}</td>
+          <td>1</td>
+          <td>01/06/2021</td>
+          <td id="valider"><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
+          <td id="refuser"><img v-bind:src="imageCroix"   alt='' height=20 width=20></td>
+
+        </tr>
+        </tbody>
+      </table>
     </div>
     <span class="niveau" id="proposees" v-on:click="naviguer">Maj Proposées</span>
     <div id="detailProposees" class="masque">
-    <table>
-      <thead>
-      <tr>
-        <th colspan="8">Contenus</th>
-      </tr>
-      </thead>
-      <tr>
-        <th>Titre</th>
-        <th>Auteur</th>
-        <th>Version proposée</th>
-        <th>Date Version proposée</th>
-        <th>Etat</th>
-        <th>Conserver</th>
-
-        <th>Créer Nouveau</th>
-        <th>Supprimer</th>
-
-
-      </tr>
-      <tbody>
-
-      <tr>
-        <td>Contenu1</td>
-        <td>Auteur1</td>
-        <td>1</td>
-        <td>01/06/2021</td>
-        <td>En Cours</td>
-        <td></td>
-        <td></td>
-        <td></td>
-
-        <!--        <td id="valider"><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
-                <td id="refuser"><img v-bind:src="imageCroix"   alt='' height=20 width=20></td>-->
-
-
-      </tr>
-      <tr>
-      <td>Contenu1</td>
-      <td>Auteur1</td>
-      <td>1</td>
-      <td>01/06/2021</td>
-      <td>Refusée</td>
-      <td><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
-      <td><img v-bind:src="imgNouveau"  alt='' height=20 width=20></td>
-      <td><img v-bind:src="imgPoubelle"  alt='' height=20 width=20></td>
-
-      <!--        <td id="valider"><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
-              <td id="refuser"><img v-bind:src="imageCroix"   alt='' height=20 width=20></td>-->
-
-
-      </tr>
-      </tbody>
-    </table>
-  </div>
+      <table>
+        <thead>
+        <tr>
+          <th colspan="8">Contenus</th>
+        </tr>
+        </thead>
+        <tr>
+
+          <th>Titre</th>
+          <th>Auteur</th>
+          <th>Version proposée</th>
+          <th>Date Version proposée</th>
+          <th>Etat</th>
+          <th>Conserver</th>
+          <th>Créer Nouveau</th>
+          <th>Supprimer</th>
+
+        </tr>
+        <tbody>
+
+        <tr  v-for="item in contenusPropose" :key="item._id">
+          <td>Contenu1</td>
+          <td>{{ item.auteurContenu }}</td>
+          <td>1</td>
+          <td>01/06/2021</td>
+          <td>{{ item.etat }}</td>
+          <td v-on:click="conserver"><img v-bind:src="imageCoche"  alt='' height=20 width=20></td>
+          <td v-on:click="creerNouveau"><img v-bind:src="imgNouveau"  alt='' height=20 width=20></td>
+          <td v-on:click="supprimer"><img v-bind:src="imgPoubelle"  alt='' height=20 width=20></td>
+        </tr>
+        </tbody>
+      </table>
+    </div>
   </div>
 </template>
 
 <script>
+import Service from "@/service/Service";
+
 export default {
   name: "Maj",
-  props: ['contenuEnPublication'],
+  props: ['contenuEnPublication', 'auteur'],
   methods: {
     naviguer: function (e) {
       e.target.classList.toggle("niveau-down")
       //alert(e.target.id)
       document.getElementById("detail" + e.target.id[0].toUpperCase() + e.target.id.substring(1)).classList.toggle('affiche')
+    },
+    conserver: function () {
+      alert("conserver")
+    },
+    creerNouveau: function() {
+      alert("creerNouveau")
+    },
+    supprimer: function () {
+      alert("supprimer")
     }
   },
   data: function () {
-    return{
+    return {
       imageCoche: "https://e7.pngegg.com/pngimages/485/477/png-clipart-check-mark-computer-icons-green-check-circle-angle-text.png",
       imageCroix: "https://e7.pngegg.com/pngimages/993/267/png-clipart-computer-icons-red-cross-miscellaneous-logo.png",
       imgPoubelle: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAflBMVEX///8AAACampq4uLh5eXlcXFxlZWXr6+vFxcVFRUWurq6ioqL39/doaGju7u7Z2dmIiIjX19eoqKicnJxZWVlvb28qKirDw8Pl5eU6Ojq5ublAQEDOzs7f398dHR1OTk4xMTGRkZERERGLi4sbGxt+fn4kJCQLCwt0dHRSUlJ5VCwrAAAIRUlEQVR4nO2d6VYbSwyEHbyBMWbHEBKwCev7v+C9jruOMyqpx2YZKTn6fiLj6WJ60TZDr5ckSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkyd9PfzjajWHfe8g7svdtV/a8h7wjqTAVxicVpsL4QGF/Nq4z6//lCvdbP7mfCoOSCjekwqikwg2pMCqpcEMqjMq/r/CwjPtH6yd/lE8edjCq7RlcDFu4KeM+aPvg8KB88qbtgxeDDhXefvPgtkOFB+3D+QIOUmEqTIWpMBWmwlSYCj+Vm/bhfAE3HSqc9z2Yd6gwSZIkSbbm+HLQBZfHbgp/tPshn0J7SvKr+NmRwp9uCqcdKZy6Kew9dCLwwU9gb9GJ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YqtF4+G+vA79E+AUel4YqpCuHgyeDJQUMdcV7DnW4EF6pC4+Wzvu/01BA+F0rwy1aFCENEM0CX/7ByO0QhTQ1r1fd568FyoD4MsGwO8KI3m41P5/3GuJez8YpZ47OX/fnpeDaTOX3vF2AxonTxwm82qfMs+vQjFS3WKO/5/BDRXJrP/38lcfowgPIWzA8R40mLBp+s0FuOwr+v8HP/J2Kssswa7R+PvJ94B776yv8PEKtosUZ7Sff7iZbDWKH8v5IPEM+l+ewjP96Br79m/v3EKlokSZIkSZIkX81/MjFrMKxwu60AAAAASUVORK5CYII=",
-      imgNouveau: "https://png.pngtree.com/png-vector/20190129/ourmid/pngtree-vector-new-icon-png-image_423422.jpg"
+      imgNouveau: "https://png.pngtree.com/png-vector/20190129/ourmid/pngtree-vector-new-icon-png-image_423422.jpg",
+      contenusRecu: [],
+      contenusPropose: []
     }
-  }
+  },
+  watch: {
+    auteur: function () {
+      let that = this
+      // Dès que l'auteur est connu, on charge tous ses contenus
+
+      Service.getPublicationsRecues(this.auteur).then(function (response) {
+        that.contenusRecu = response.data
+
+      })
+
+      Service.getPublicationsProposees(this.auteur).then(function (response) {
+        that.contenusPropose = response.data
+      })
+    }
+  },
 }
 </script>
 
diff --git a/src/components/Consulter_Contenu.vue b/src/components/Consulter_Contenu.vue
index 63d3cdb8..ef30ad8a 100644
--- a/src/components/Consulter_Contenu.vue
+++ b/src/components/Consulter_Contenu.vue
@@ -9,7 +9,7 @@
       <button v-show="contenuCliqueProvenance !== 'banque'" v-on:click="actionContenu('supprimer')">supprimer le contenu</button>
       <button v-show="contenuCliqueProvenance === 'en-cours'" v-on:click="actionContenu('publier')">publier le contenu</button>
       <button v-show="contenuCliqueProvenance === 'banque'" v-on:click="actionContenu('mettreFavori')">mettre le contenu en tiers</button>
-  <br>
+      <br>
 
     </div>
 
@@ -24,14 +24,7 @@ export default {
   props: ['contenuClique', 'contenuCliqueProvenance'],
   methods: {
     actionContenu: function (action) {
-
-      if (this.contenuCliqueProvenance === 'en-cours'){
-
-        this.$emit("actionContenu", {action: action, id_contenu: this.contenuClique.reference, version: this.contenuClique.version})
-
-      } else {
-      this.$emit("actionContenu", {action: action, id_contenu: this.contenuClique._id, version: this.contenuClique.versionEnCours["numero"]})
-      }
+      this.$emit("actionContenu", {action: action, contenu: this.contenuClique})
     },
     revenirArriere: function () {
       this.$emit("retour_arriere", {panierChoisi: this.contenuCliqueProvenance !== 'banque'})
diff --git a/src/components/Volet_Base.vue b/src/components/Volet_Base.vue
index 9552caf7..730af578 100644
--- a/src/components/Volet_Base.vue
+++ b/src/components/Volet_Base.vue
@@ -144,7 +144,6 @@ export default {
 
       Service.getPanierAuteur(this.auteur).then(function (response) {
         that.contenus = response.data
-        alert(that.contenus.length)
       })
       Service.getBanqueAuteur(this.auteur).then(function (response) {
         that.contenusbanque = response.data
@@ -183,7 +182,6 @@ export default {
     supprimerContenus: function () {
 
       if (this.panierChoisi){
-
         for(let i = 0; i < this.checkes.length; i++) {
           if(this.checkes[i][1] === "perso"){
             Service.supprimerContenu(JSON.stringify(this.checkes[i][0]))
@@ -195,7 +193,6 @@ export default {
           }
         }
 
-
       }
       else {
         for(let i = 0; i < this.checkes.length; i++) {
@@ -221,7 +218,6 @@ export default {
       })
     },
     chargerContenu: function (item, provenance){
-      alert(item.provenance)
       this.modeConsultation = true;
       this.contenuClique = item
       this.contenuCliqueProvenance = provenance
@@ -232,17 +228,24 @@ export default {
     },
     actionContenu: function (event) {
       this.modeConsultation = false
+      let data = {}
+      let that = this
       switch (event.action) {
         case "mettreFavori":
+
+          data = {auteur: this.auteur, id_tiers:JSON.stringify(event.contenu._id) , version: event.contenu.versionEnCours["numero"]}
+          Service.creerContenuTiers(data)
+
+          Service.getPanierAuteur(this.auteur).then(function (response) {
+            that.contenus = response.data
+            that.nouveauContenu = !that.nouveauContenu
+          })
           this.panierChoisi = false
-          this.contenus.push(({titre: this.contenuClique , provenance: "tiers"}))
           break
         case "modifier":
-          alert("let's go step by step")
           this.panierChoisi = true
           if (this.contenuCliqueProvenance !== 'en-cours'){
-            let that = this
-            let data = {auteur: this.auteur, id_contenu: JSON.stringify(event.id_contenu), version: event.version}
+            data = {auteur: this.auteur, id_contenu: JSON.stringify(event.contenu._id), version: event.contenu.versionEnCours["numero"]}
             Service.creerEnCours(data).then( function() {
               Service.getPanierAuteur(that.auteur).then(function (response) {
                 that.contenus = response.data
@@ -253,45 +256,48 @@ export default {
         case "supprimer":
           this.panierChoisi = true
 
-// 3 cas : suppression perso, suppression tiers et suppression en cours
-          if (this.contenuCliqueProvenance !== 'perso'){
-            for (let i = 0; i < this.contenus.length; i++){
-              if (this.contenus[i].titre === this.contenuClique){
-                this.contenus.splice(i, 1)
-              }
-            }
+          if(this.contenuCliqueProvenance === "perso"){
+            Service.supprimerContenu(JSON.stringify(event.contenu._id))
+          } else if (this.contenuCliqueProvenance === "tiers"){
+            Service.supprimerTiers(this.auteur, JSON.stringify(event.contenu._id))
           } else {
-            for (let i = 0; i < this.contenus.length; i++){
-              if (this.contenus[i].titre === this.contenuClique){
-                this.contenus[i].auteur = "Aucun"
-              }
-            }
+            Service.supprimerEnCours(JSON.stringify(event.contenu._id))
           }
-          break
-        case "publier":
-          this.panierChoisi = true
-          this.$emit("publication", {document: this.contenuClique})
-          break
-      }
-    },
-    ajouterCoche: function (idContenu, provenance) {
-      let existant = false
-      for (let i = 0; i < this.checkes.length; i++){
 
-        if (this.checkes[i][0] === idContenu){
-          existant = true
-        }
-      }
+          Service.getPanierAuteur(this.auteur).then(function (response) {
+            that.contenus = response.data
+            that.nouveauContenu = !that.nouveauContenu
+          })
+
+      break
+    case "publier":
+      alert("Je veux publier")
+      this.panierChoisi = true
+      data = {id_contenu: JSON.stringify(event.contenu.reference), id_contenu_en_cours: JSON.stringify(event.contenu._id), auteur_en_cours: this.auteur}
+      //request.args.get('id_contenu'), request.args.get('id_contenu_en_cours'),
+      Service.creerDemandePublication(data)
+      // this.$emit("publication", {document: this.contenuClique})
+      break
+    }
+  },
+  ajouterCoche: function (idContenu, provenance) {
+    let existant = false
+    for (let i = 0; i < this.checkes.length; i++){
 
-      if (existant){
-        this.checkes.splice(this.checkes.indexOf([idContenu, provenance]), 1)
-      }
-      else {
-        this.checkes.push([idContenu, provenance])
+      if (this.checkes[i][0] === idContenu){
+        existant = true
       }
     }
+
+    if (existant){
+      this.checkes.splice(this.checkes.indexOf([idContenu, provenance]), 1)
+    }
+    else {
+      this.checkes.push([idContenu, provenance])
+    }
   }
 }
+}
 
 </script>
 
diff --git a/src/service/Service.js b/src/service/Service.js
index 50755862..a857bb47 100644
--- a/src/service/Service.js
+++ b/src/service/Service.js
@@ -71,13 +71,20 @@ export default {
     majCOntenu(){
 
 
-    }
+    },
 
     // bonus : fonction de récupération des tags pour getPanier et getBanque
 
+    getPublicationsRecues(auteur){
+        return axios.get(urlBase + "demandePublication/" + auteur + "/False")
+    },
 
+    getPublicationsProposees(auteur){
+        return axios.get(urlBase + "demandePublication/" + auteur + "/True")
+    },
 
+    creerDemandePublication(data) {
+        axios.post(urlBase + "demandePublication" , data)
 
-
-
+    }
 }
\ No newline at end of file
-- 
2.18.1