Commit bcc68db3 authored by Jérémie Passerat's avatar Jérémie Passerat

Sauvegarde 24/09

parent b71a7fe3
<template>
<div>
<div style="text-align: center" v-show="isImportation">
<div style="text-align: center" v-show="isImportation">
Je suis la page pour charger un contenu<br>
Je suis la page pour charger un contenu<br>
<input type="file" name="fichier" @change="onUploadFiles">
<input type="file" name="fichier" @change="onUploadFiles"><br>
<p style="color: red" v-show="fichierError">Aucun fichier uploadé</p>
<div class="markdown">
<br>
<button class="ajouterContenu" v-on:click="choisirTags">créer</button><br><br>
<button class="retourArriere" v-on:click="retourArriere">revenir en arrière</button>
</div>
<div style="margin-top: 3vh" v-if="isNotXml">
<label>Le fichier n'est pas de type xml</label><br>
<label>Entrer le titre du fichier : </label><br>
<input type="text" v-model="titreFichier" required="required" @change="removeError"/><br><br>
<p style="color: red" v-show="titreError">Le descriptif du fichier est vide</p>
<label>Entrer un descriptif associé au fichier : </label><br>
<textarea rows="7" cols="42" v-model="descriptifFichier" aria-required="true"></textarea>
<p style="color: red" v-show="descriptifError">Le descriptif du fichier est vide</p>
</div>
<div class="markdown">
<br>
<button class="ajouterContenu" v-on:click="choisirTags">créer</button><br><br>
<button class="retourArriere" v-on:click="retourArriere">revenir en arrière</button>
</div>
</div>
</div>
<TagsFixes v-show="!isImportation" @tags="ajouterContenu"></TagsFixes>
</div>
......@@ -35,8 +47,15 @@ export default {
data() {
return {
formData: null,
isImportation: true
isImportation: true,
isNotXml: false,
descriptifFichier: '',
typeDocument: '',
titreFichier: '',
titreError: false,
descriptifError: false,
fichierError: false,
nonTouche: true,
}
},
methods: {
......@@ -44,17 +63,35 @@ export default {
* @vuese
* Fonction pour déclencher l'affichage de la page pour choisir les tags fixes
*/
choisirTags: function () {
this.isImportation = false
if (this.isNotXml) {
this.nonTouche = false
this.removeError()
if (!this.descriptifError)
this.descriptifError = this.descriptifFichier.length === 0
}
if (this.formData === null){
this.fichierError = true
} else if (!this.titreError && !this.descriptifError) {
this.isImportation = false
}
},
/**
* @vuese
* permet 'd'enrengistrer' le fichier uploadé via le formulaire
*/
onUploadFiles: function (event) {
this.formData = new FormData()
this.formData.append('file', event.target.files.item(0));
onUploadFiles: function (event) {
this.formData = new FormData()
if (event.target.files.item(0).type !== 'text/xml') {
this.isNotXml = true
this.typeDocument = event.target.files.item(0).type
}
this.formData.append('file', event.target.files.item(0))
this.fichierError = false
},
/**
* @vuese
......@@ -62,6 +99,10 @@ export default {
*/
retourArriere: function () {
// evenement pour retourner vers le volet Contenu_Base
this.formData = ""
this.titreFichier = ""
this.descriptifFichier = ""
this.isNotXml = false
this.$emit("retourArriere")
},
/**
......@@ -70,17 +111,52 @@ export default {
*/
ajouterContenu: function (event) {
let that = this
Service.uploaderContenuPerso(this.formData, this.auteur, JSON.stringify(event.tags)).then(
function (reponse) {
let nouveauContenu = reponse.data
nouveauContenu.provenance = "perso"
nouveauContenu.tags_libres = []
that.$emit("contenuAjoute", {contenu: nouveauContenu})
that.contenuSaisi = ''
that.retourArriere()
that.isImportation = true
}
)
if (!this.isNotXml) {
Service.uploaderContenuPerso(this.formData, this.auteur, JSON.stringify(event.tags)).then(
function (reponse) {
let nouveauContenu = reponse.data
nouveauContenu.provenance = "perso"
nouveauContenu.tags_libres = []
that.$emit("contenuAjoute", {contenu: nouveauContenu})
that.contenuSaisi = ''
that.retourArriere()
that.isImportation = true
}
)
} else {
alert("titre_fichier : " + this.titreFichier)
Service.uploaderContenuPersoNonXml(this.formData, this.auteur, JSON.stringify(event.tags), this.descriptifFichier,
this.typeDocument, this.titreFichier).then(
function (reponse) {
let nouveauContenu = reponse.data
nouveauContenu.provenance = "perso"
nouveauContenu.tags_libres = []
that.$emit("contenuAjoute", {contenu: nouveauContenu})
that.contenuSaisi = ''
that.retourArriere()
that.isImportation = true
}
)
}
},
/**
* @vuese
* Enleve les messages d'erreur d'ajout de contenu non xml (titre)
*/
removeError: function () {
if (!this.nonTouche)
this.titreError = this.titreFichier.length === 0
}
},
watch: {
/**
* @vuese
* Enleve les messages d'erreur d'ajout de contenu non xml (descriptif
*/
descriptifFichier: function () {
if (!this.nonTouche)
this.descriptifError = this.descriptifFichier.length === 0
}
}
}
......
......@@ -35,7 +35,9 @@ export default {
// texte du contenu survolé
id: {},
// provenance du contenu survolé
provenance: {}
provenance: {},
// source du contenu survole
source: {}
},
mounted() {
/**
......@@ -45,14 +47,16 @@ export default {
let that = this
// alert(this.provenance)
if (this.provenance !== 'en-cours' && this.provenance !== 'maj') {
Service.parserTexte(JSON.stringify(this.id)).then(function (response) {
that.questionParsee = response.data
})
} else {
Service.parserTexteEnCours(JSON.stringify(this.id)).then(function (response) {
that.questionParsee = response.data
})
if (this.source === 'moodle') {
if (this.provenance !== 'en-cours' && this.provenance !== 'maj') {
Service.parserTexte(JSON.stringify(this.id)).then(function (response) {
that.questionParsee = response.data
})
} else {
Service.parserTexteEnCours(JSON.stringify(this.id)).then(function (response) {
that.questionParsee = response.data
})
}
}
},
......
......@@ -66,7 +66,7 @@
style="position: static; height: 78vh; margin-top: -0.77%" v-bind:darktheme="darktheme" @chargerTagsLibres="chargerTagsLibres" v-bind:tagLibreAssocie="tagLibreAssocie"></TagsLibres>
<Edit_Contenus @actionMoodle="actionMoodle" v-show="!isModeTag && sourceContenu === 'moodle'" v-bind:darktheme="darktheme"
v-bind:idContenu="idContenu" v-bind:provenance="contenuCliqueProvenance"></Edit_Contenus>
v-bind:idContenu="idContenu" v-bind:source="sourceContenu" v-bind:provenance="contenuCliqueProvenance"></Edit_Contenus>
<div class="markdown" v-show="sourceContenu !== 'moodle'">
<br>
......@@ -251,7 +251,7 @@ export default {
*/
calculerNoteContenu: function() {
if (this.contenuCliqueProvenance !== "moodle" && this.contenuCliqueProvenance !== "") {
if (this.sourceContenu !== "moodle" && this.contenuCliqueProvenance !== "") {
if (parseInt(this.versionChoisie) !== this.versionMax) {
for (let it in this.contenuClique.historique) {
if (this.contenuClique.historique[it].numero === parseInt(this.versionChoisie)) {
......@@ -268,7 +268,9 @@ export default {
}
return (this.contenuClique.versionEnCours.note / this.contenuClique.versionEnCours.nbreNotes).toFixed(2)
}
} return 0
} else {
return this.contenuClique.moyenne
}
}
},
watch: {
......
......@@ -70,10 +70,12 @@ isActif ? {'margin-left': '1vw', 'margin-right': '1vw'} : {'margin-left': '0.6vw
}">
<td :id="JSON.stringify(item._id)" v-on:click="chargerContenu(item, item.provenance)">{{item.titre}}<div style="display:none;">
{{ item._id }}</div></td>
<b-popover style="height: 700px; width: 700px" class="non" v-on:show="rechercherTexte(item._id, item.provenance, item.source)" :target="JSON.stringify(item._id)"
<b-popover style="height: 700px; width: 700px" class="non" v-on:show="rechercherTexte(item._id, item.provenance, item.source, item.descriptif)" :target="JSON.stringify(item._id)"
triggers="hover" placement="bottom">
<p id="beautiful" v-html="texteDuContenu" v-if="!isMoodle"></p>
<Previsualiser_Moodle v-bind:id="item._id" v-bind:provenance="item.provenance" v-else></Previsualiser_Moodle>
<p v-if="isAutre">{{ descriptifContenu }}</p>
<Previsualiser_Moodle v-bind:id="item._id" v-bind:provenance="item.provenance" v-bind:source="item.source"
v-if="isMoodle && !isAutre"></Previsualiser_Moodle>
</b-popover>
<!-- auteur -->
<td>{{item.auteur}}</td>
......@@ -87,9 +89,10 @@ isActif ? {'margin-left': '1vw', 'margin-right': '1vw'} : {'margin-left': '0.6vw
<td v-if="item.provenance === 'en-cours'"> - </td>
<td v-else>{{ item.popularite }}</td>
<!-- note -->
<td v-if="item.provenance === 'en-cours'"> - </td>
<td v-if="item.provenance === 'en-cours'"> {{ item.moyenne }} </td>
<td v-else>{{ calculerNote(item) }}</td>
<td>{{ item.note_perso }}</td>
<td v-if="item.provenance !== 'tiers'"> - </td>
<td v-else>{{ item.note_perso }}</td>
<td v-show="!isActif" v-if="item.provenance !== 'en-cours'" v-b-popover.hover.bottom="tagsFixesContenu(item.tags_fixes)">
{{ tagsFixesContenu(item.tags_fixes) }}</td>
<td v-show="!isActif" v-else v-b-popover.hover.bottom="'tags non disponibles'">tags non disponibles</td>
......@@ -207,11 +210,13 @@ export default {
checkes: [],
nouveauContenu: false,
texteDuContenu: '',
descriptifContenu: '',
titreContenu: '',
token: '',
razModeVariante: false,
//modeFiltre: false,
isMoodle: false,
isAutre: true,
texteBoutonvariante: "changer",
// booléens pour le tri des colonnes du tableau
titreTrie: false,
......@@ -528,16 +533,18 @@ export default {
converter = new showdown.Converter()
this.texteDuContenu = converter.makeMarkdown(this.texteDuContenu)
// Si Moodle, on en a pas besoin, car géré via Prévisualiser_Moodle et consorts
} /*else if (item.source === "moodle"){
} else if (item.source === "autre"){
let that = this
Service.recupererTexteContenu(JSON.stringify(item._id)).then(
function (response) {
that.texteDuContenu = response.data
// alert(response.data)
}
)
}*/
if (item.provenance !== 'en-cours')
Service.recupererTexteContenu(JSON.stringify(item._id)).then(function (reponse) {
that.texteDuContenu = reponse.data
})
else{
Service.recupererTexteContenuEnCours(JSON.stringify(item._id)).then(function (reponse) {
that.texteDuContenu = reponse.data
})
}
}
}
},
/**
......@@ -720,20 +727,24 @@ export default {
* @vuese
* Récupération du texte d'un contenu
*/
rechercherTexte: function (id, provenance, source) {
rechercherTexte: function (id, provenance, source, description) {
if (id === undefined)
return
let that = this
if (source === "moodle"){
this.isMoodle = true
}
else {
this.isAutre = false
} else if (source === "autre"){
this.isMoodle = false
this.isAutre = true
this.descriptifContenu = description
} else {
this.isMoodle = false
this.isAutre = false
if (provenance === 'en-cours') {
Service.recupererTexteContenuEnCours(JSON.stringify(id)).then(
......
......@@ -26,7 +26,9 @@ export default {
//l'id du contenu clique
idContenu: {},
//la provenance du contenu
provenance: {}
provenance: {},
// la source du contenu
source: {}
},
methods: {
passerMoodle: function (event) {
......@@ -48,18 +50,21 @@ export default {
//alert(that.provenance)
if (this.provenance !== 'en-cours') {
Service.parserTexte(JSON.stringify(this.idContenu)).then(function (response) {
that.questionParsee = response.data
that.type_question = that.questionParsee.type_question
if (this.source === 'moodle') {
if (this.provenance !== 'en-cours') {
alert("Puuuu")
Service.parserTexte(JSON.stringify(this.idContenu)).then(function (response) {
that.questionParsee = response.data
that.type_question = that.questionParsee.type_question
})
} else {
Service.parserTexteEnCours(JSON.stringify(this.idContenu)).then(function (response) {
that.questionParsee = response.data
that.type_question = that.questionParsee.type_question
})
} else {
Service.parserTexteEnCours(JSON.stringify(this.idContenu)).then(function (response) {
that.questionParsee = response.data
that.type_question = that.questionParsee.type_question
})
})
}
}
}
}
......
......@@ -102,6 +102,15 @@ export default {
}
})
},
uploaderContenuPersoNonXml(data, auteur, tags, descriptif, type, titre){
return axios.post(urlBase + contenus + "uploadContenuNonXml/" + auteur + "?tags=" + tags +
"&descriptif="+ descriptif + "&type=" + type + "&titre=" + titre, data, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: "Bearer " + localStorage.token,
}
})
},
creerContenuTiers(data) {
return axios.patch(urlBase + contenus + "ajouterTiers", data, this.getHeader())
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment