|
|
@ -2,27 +2,26 @@
|
|
|
|
import { REST_API } from '@/assets/const';
|
|
|
|
import { REST_API } from '@/assets/const';
|
|
|
|
|
|
|
|
|
|
|
|
export default{
|
|
|
|
export default{
|
|
|
|
|
|
|
|
props:["donnee", "endpoint"], //format : {"nomColonne":"typeDonnee", ...} => {"nom":"text", "desc":"text", ...}
|
|
|
|
methods:{
|
|
|
|
methods:{
|
|
|
|
envoyerDonnees: function(event){
|
|
|
|
envoyerDonnees: function(event){
|
|
|
|
const donnees=new FormData(formajouter)
|
|
|
|
const donnees=new FormData(formajouter)
|
|
|
|
|
|
|
|
|
|
|
|
//todo mettre lien dans const
|
|
|
|
|
|
|
|
//envoyer le form en JSON
|
|
|
|
//envoyer le form en JSON
|
|
|
|
fetch(REST_API+"/thematiques", {method:"POST", body:JSON.stringify(Object.fromEntries(donnees)), headers: {"Content-Type": "application/json"}})
|
|
|
|
fetch("localhost"+"/"+this.endpoint, {method:"POST", body:JSON.stringify(Object.fromEntries(donnees)), headers: {"Content-Type": "application/json"}})
|
|
|
|
//sans le JSON.stringify et Object.fromEntries ca fait une requete en Content-Disposition
|
|
|
|
//sans le JSON.stringify et Object.fromEntries ca fait une requete en Content-Disposition
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: verifier si on est admin quand on entre dans la partie admin
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<form id="formajouter" @submit.prevent>
|
|
|
|
<form id="formajouter" @submit.prevent>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<label for="libelle">Libelle</label>
|
|
|
|
<fieldset v-for="nomColonne in Object.keys(donnee??{})">
|
|
|
|
<input class="form-control" type="text" id="libelle" name="libelle"/>
|
|
|
|
<label :for="nomColonne+'_temp_add_form'">{{nomColonne}}</label>
|
|
|
|
|
|
|
|
<input class="form-control" :type="donnee[nomColonne]" :id="nomColonne+'_temp_add_form'" :aria-label="nomColonne"/>
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<button v-on:click="envoyerDonnees" class="btn btn-primary">Ajouter</button>
|
|
|
|
<button v-on:click="envoyerDonnees" class="btn btn-primary">Ajouter</button>
|
|
|
|