From a7b1c6cfae1cf63af09a999b1d8619fdb8ba094d 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, 7 Jul 2021 16:02:28 +0200 Subject: [PATCH] Corrections 'vague 1' ok --- src/Contenu.vue | 14 ++++++- src/Index.vue | 12 ++++-- src/Login.vue | 6 +-- src/Maj.vue | 58 ++++++++++++++++++++++------ src/Menu.vue | 7 +++- src/components/Consulter_Contenu.vue | 2 + src/components/Volet_Base.vue | 19 ++++++--- src/service/Service.js | 2 +- 8 files changed, 93 insertions(+), 27 deletions(-) diff --git a/src/Contenu.vue b/src/Contenu.vue index 8c896268..6c221388 100644 --- a/src/Contenu.vue +++ b/src/Contenu.vue @@ -1,6 +1,8 @@ <template> <div id="app"> - <Volet_Base @choix_variante="choixVariante" @newContenu="newContenu" v-bind:nvoContenu="nvoContenu" v-bind:auteur="auteur" v-bind:contenuAjoute="contenuAjoute" /> + <Volet_Base @rechercherNouvellesPublications="rechercherNouvellesPublications" @choix_variante="choixVariante" + @newContenu="newContenu" v-bind:nvoContenu="nvoContenu" v-bind:auteur="auteur" + v-bind:contenuAjoute="contenuAjoute" v-bind:majContenus="majContenus" /> </div> </template> @@ -30,6 +32,13 @@ export default { // Evenement à destination de Volet_Base this.$emit("newContenu") + }, + /** + * @vuese + * Signal pour déclencher la recherche de nouvelles publications + */ + rechercherNouvellesPublications: function () { + this.$emit("rechercherNouvellesPublications") } }, props: { @@ -38,7 +47,8 @@ export default { // Variable contenant un contenu ajouté, à destination de Volet_Base contenuAjoute: {}, // Variable contenant un "nouveau contenu", créé à partir d'une demande de publication, à destination de Volet_Base - nvoContenu: {} + nvoContenu: {}, + majContenus: {} } } </script> diff --git a/src/Index.vue b/src/Index.vue index ea25b730..cf56a941 100644 --- a/src/Index.vue +++ b/src/Index.vue @@ -5,10 +5,13 @@ <Menu v-show="etat !== 'unlogged'" v-bind:auteur="auteur" v-bind:etat="etat" v-bind:variante="variante" v-bind:recalculerNotif="recalculerNotif" @menu_choisi="changerPage"></Menu> <Contenu v-show="etat === 'Contenu'" v-bind:auteur="auteur" v-bind:nvoContenu="nvoContenu" v-bind:contenuAjoute="contenuAjoute" - @choix_variante="choixVariante" @newContenu="newContenu"></Contenu> + @choix_variante="choixVariante" @newContenu="newContenu" + @rechercherNouvellesPublications="rechercherPublications = !rechercherPublications" + v-bind:majContenus="majContenus"></Contenu> <Maj v-show="etat === 'Mises à jour'" v-bind:auteur="auteur" v-bind:isRecu="isRecu" v-bind:isPropose="isPropose" v-bind:contenuEnPublication="contenuEnPublication" @recalculerNotif="recalculerNotification" - @majNvoContenu="majNvoContenu" ></Maj> + @majNvoContenu="majNvoContenu" @majContenus="majContenus = !majContenus" + v-bind:rechercherPublications="rechercherPublications"></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> @@ -40,7 +43,9 @@ export default { isPropose: false, contenuAjoute: "", recalculerNotif: false, - nvoContenu: '' + nvoContenu: '', + rechercherPublications: false, + majContenus: false } }, methods: { @@ -66,6 +71,7 @@ export default { changerPage: function (event) { if (event.choix === "Deconnexion"){ this.etat = "unlogged" + localStorage.clear() } else this.etat = event.choix diff --git a/src/Login.vue b/src/Login.vue index 330839c8..f7de7de7 100644 --- a/src/Login.vue +++ b/src/Login.vue @@ -39,11 +39,9 @@ export default { if (response.status === 200){ localStorage.token = response.data.access_token that.$emit("user_logged", {"isLogged" : true, "auteur": that.login}) - } else { - // SI connexion refusée, on emet un booléen a false et le nom de l'auteur connecté - // @arg booléen indiquant que la connexion est pas ok - that.$emit("user_logged", {"isLogged" : false}) } + }).catch(function () { + that.$emit("user_logged", {"isLogged" : false}) }) }, keymonitor: function(event) { diff --git a/src/Maj.vue b/src/Maj.vue index 4d9bc201..3239da2d 100644 --- a/src/Maj.vue +++ b/src/Maj.vue @@ -5,8 +5,8 @@ - <span v-bind:class="['niveau', {'niveau-down' : isRecu}]" id="recues" v-on:click="naviguer">Maj Recues</span><br> - <div id="detailRecues" class="masque" v-bind:class="{'affiche' : isRecu}"> + <span v-bind:class="['niveau', {'niveau-down' : contenusRecu.length > 0}]" id="recues" v-on:click="naviguer">Maj Recues</span><br> + <div id="detailRecues" class="masque" v-bind:class="{'affiche' : contenusRecu.length > 0}"> <table> <thead> <tr> @@ -42,8 +42,8 @@ - <span class="niveau" id="proposees" v-bind:class="{'niveau-down' : isPropose}" v-on:click="naviguer">Maj Proposées</span> - <div id="detailProposees" class="masque" v-bind:class="{'affiche' : isPropose}"> + <span class="niveau" id="proposees" v-bind:class="{'niveau-down' : contenusPropose.length > 0}" v-on:click="naviguer">Maj Proposées</span> + <div id="detailProposees" class="masque" v-bind:class="{'affiche' : contenusPropose.length > 0}"> <table> <thead> <tr> @@ -98,7 +98,7 @@ export default { components: { Consulter_Contenu }, - props: ['contenuEnPublication', 'auteur', 'isRecu', 'isPropose'], + props: ['contenuEnPublication', 'auteur', 'isRecu', 'isPropose', 'rechercherPublications'], methods: { /** * @vuese @@ -119,6 +119,10 @@ export default { Service.creerEnCoursRefuse(data).then( function () { Service.supprimerDemandePublication(JSON.stringify(item._id)).then(function () { that.contenusPropose = that.contenusPropose.filter(contenu => contenu._id !== item._id) + if (that.isContenuMajVide()) + that.$emit("recalculerNotif") + that.$emit("majContenus") + }) } ) @@ -136,6 +140,8 @@ export default { nvoContenu.provenance = "perso" that.$emit("majNvoContenu", {contenu: response.data}) that.contenusPropose = that.contenusPropose.filter(contenu => contenu._id !== item._id) + if (that.isContenuMajVide()) + that.$emit("recalculerNotif") } ) }, @@ -147,6 +153,8 @@ export default { let that = this Service.supprimerDemandePublication(JSON.stringify(item._id)).then(function () { that.contenusPropose = that.contenusPropose.filter(contenu => contenu._id !== item._id) + if (that.isContenuMajVide()) + that.$emit("recalculerNotif") }) }, /** @@ -161,9 +169,17 @@ export default { // auteurContenu -> undefined == nous sommes sur une maj tiers. Le cas contraire = maj d'un contenu perso à faire if (item.auteurContenu === undefined) { - data = {id_tiers: JSON.stringify(item[0]._id), reponse: reponse, auteur: this.auteur} + let test = item._id + console.log("id item") + console.log(test) + data = {id_tiers: JSON.stringify(item._id), reponse: reponse, auteur: this.auteur} Service.gererMajTiers(data).then(function () { - that.contenusRecu = that.contenusRecu.filter(contenu => contenu._id !== item[0]._id) + that.contenusRecu = that.contenusRecu.filter(contenu => contenu._id !== item._id) + if (that.isContenuMajVide() ) + that.$emit("recalculerNotif") + if (reponse === 'o'){ + that.$emit("majContenus") + } }) }else { @@ -173,11 +189,15 @@ export default { this.contenusRecu = [] Service.gererDemandePublication(data).then(function () { that.contenusRecu = that.contenusRecu.filter(contenu => contenu._id !== item._id) + if (that.isContenuMajVide()) + that.$emit("recalculerNotif") + if (reponse === 'o'){ + that.$emit("majContenus") + } }) } // évènement pour recalculer les notifications de l'auteur en cours (et potentiellement faire disparaitre l'icone) - this.$emit("recalculerNotif") }, /** * @vuese @@ -199,8 +219,12 @@ export default { } Service.listeMajTiers(that.auteur).then(function (response){ - if(response.data.length > 0) - that.contenusRecu.push(response.data) + let reception = response.data + if(reception.length > 0) + for (let i = 0; i < reception.length; i++) { + console.log(reception[i]) + that.contenusRecu.push(reception[i]) + } }) }) }, @@ -237,7 +261,7 @@ export default { * @vuese * Récupération et mise en forme du texte associé au contenu */ - rechercherTexte(id){ + rechercherTexte: function (id) { let that = this Service.recupererTexteContenuEnCours(JSON.stringify(id)).then( function (response) { @@ -247,6 +271,14 @@ export default { that.texteDuContenu = converter.makeHtml(response.data) } ) + }, + /** + * @vuese + * Permet de déterminer si il reste encore des contenus maj 'non traités' + * Utile pour le déclenchement du changement d'affichage pour la norification de maj + */ + isContenuMajVide: function () { + return this.contenusPropose.length === 0 && this.contenusRecu.length === 0 } }, data: function () { @@ -272,6 +304,10 @@ export default { auteur: function () { this.publicationsRecues() this.publicationsProposees() + }, + rechercherPublications: function () { + this.publicationsRecues() + this.publicationsProposees() } }, } diff --git a/src/Menu.vue b/src/Menu.vue index 982ce0d2..a43574e9 100644 --- a/src/Menu.vue +++ b/src/Menu.vue @@ -2,7 +2,7 @@ <div id="menuHaut"> <Choix_Mode_Variante class="menuVariante" v-show="variante"></Choix_Mode_Variante> - <div class="notif" v-on:click="choixIconeNotification" v-show="isNotif" v-bind:style="[!variante ? {'margin-left': '90%'} : {'margin-left': '31.78%'}]"></div> + <div class="notif" v-on:click="choixIconeNotification" v-show="isNotif === true" v-bind:style="[!variante ? {'margin-left': '90%'} : {'margin-left': '31.78%'}]"></div> <div class="circle" id="menuAuteur" v-on:click="isAffiche = !isAffiche" v-bind:style="[!isNotif ? {'margin-left': '94.75%'} : {'margin-left': '3%'}]"> {{auteur}} </div> @@ -73,8 +73,11 @@ export default { Service.getPublicationsRecues(this.auteur).then(function (response) { let contenusRecu = response.data + + for (let i = 0; i < contenusRecu.length; i++) { + if (contenusRecu[i].etat === "enCours") { that.isNotif = contenusRecu.length !== 0 that.isRecu = that.isNotif @@ -92,6 +95,7 @@ export default { Service.getPublicationsProposees(this.auteur).then(function (response) { let contenusPropose = response.data + for (let i = 0; i < contenusPropose.length; i++) { if (contenusPropose[i].etat !== "enCours") { @@ -134,6 +138,7 @@ export default { * Recalcul des opportunités de maj et on configure la notification en fonction après action dans le menu maj (fonctionne actuellement pas) */ recalculerNotif: function () { + // alert(this.isNotif) this.isNotif = false this.publicationsRecues() } diff --git a/src/components/Consulter_Contenu.vue b/src/components/Consulter_Contenu.vue index 744b3964..5f017d75 100644 --- a/src/components/Consulter_Contenu.vue +++ b/src/components/Consulter_Contenu.vue @@ -103,6 +103,8 @@ export default { contenuClique: function () { let that = this + this.isContenuRefuse = false + if (Object.prototype.hasOwnProperty.call(this.contenuClique, 'refuse')){ this.isContenuRefuse = true } diff --git a/src/components/Volet_Base.vue b/src/components/Volet_Base.vue index c68e7b43..867b2ae0 100644 --- a/src/components/Volet_Base.vue +++ b/src/components/Volet_Base.vue @@ -22,7 +22,6 @@ </div> <div id="tableau"> - <p>Héhéhé {{token}}</p> <table v-bind:style="panierChoisi ? {'margin-top': '0%'} : {'margin-top': '20px'}"> <thead> <tr> @@ -129,7 +128,8 @@ export default { // Permet de stocker un contenu ajouté contenuAjoute: {}, // Permet de stocker un 'nouveau contenu' ajouté - nvoContenu: {} + nvoContenu: {}, + majContenus: {} }, data: function () { return { @@ -178,6 +178,7 @@ export default { this.contenusDuPanier() this.contenusDeLaBanque() this.token = localStorage.token + this.panierChoisi = true }, /** @@ -194,7 +195,12 @@ export default { nvoContenu: function () { // Fonction retour du menu des maj this.contenus.push(this.nvoContenu) + }, + majContenus: function () { + this.contenusDuPanier() + this.contenusDeLaBanque() } + }, mounted() { /** @@ -250,7 +256,7 @@ export default { * Passer le filtre choisi (pour Volet_Contenu) */ passerFiltre: function(event){ - this.filtre_choisi = event.filtre + this.filtre_choisi = event.filtre }, /** * @vuese @@ -282,9 +288,9 @@ export default { Service.supprimerTiers(this.auteur, JSON.stringify(id)).then( function (response) { let contenuSupprime = that.contenus.filter(contenu => contenu._id === id) - console.log(contenuSupprime[0].auteur) that.contenus = that.contenus.filter(contenu => contenu._id !== id) - if (response.data !== 0) + //console.log("Response Data : " + response.data) + if (response.data !== '0') that.contenusbanque.push(contenuSupprime[0]) } ) @@ -400,6 +406,7 @@ export default { 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, version: event.contenu.version.toString()} + // this.$emit("rechercherNouvellesPublications") Service.creerDemandePublication(data).then( function () { // on réupère le contenu en cours associé à la demande de publication @@ -410,6 +417,7 @@ export default { enCours[0].isPublie = "oui" // et on le réinsère that.contenus.push(enCours[0]) + that.$emit("rechercherNouvellesPublications") } ) @@ -420,6 +428,7 @@ export default { data = {id_contenu_en_cours: JSON.stringify(event.contenu._id), auteur: auteur} Service.majContenu(data).then(function () { that.contenusDuPanier() + that.panierChoisi = true }) break } diff --git a/src/service/Service.js b/src/service/Service.js index 31df39d3..ef6d258a 100644 --- a/src/service/Service.js +++ b/src/service/Service.js @@ -83,7 +83,7 @@ export default { return axios.get(urlBase + contenus + "getTexteContenu/" + idContenu, header) }, recupererTexteVersionContenu(idContenu, version){ - return axios.get(urlBase + "getTexteVersionContenu/" + idContenu + "/" + version, header) + return axios.get(urlBase + contenus + "getTexteVersionContenu/" + idContenu + "/" + version, header) }, // gestion des en-cours -- 2.18.1