diff --git a/science-quest/src/components/admin/gestion/Ajout.vue b/science-quest/src/components/admin/gestion/Ajout.vue index f0a2213..3e1f935 100644 --- a/science-quest/src/components/admin/gestion/Ajout.vue +++ b/science-quest/src/components/admin/gestion/Ajout.vue @@ -10,7 +10,26 @@ export default{ //envoyer le form en 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 - } + }, + typeDeChamp: function(champ){ //TODO mettre cette fonction dans un fichier commun + switch(typeof champ){ + case 'number': + case 'bigint': + return "number" + case 'string': + return this.estUneDate(champ) ? "date" : "text" + case 'boolean': + return "checkbox" + case 'symbol': + case 'undefined': + case 'object': + case 'function': + return "hidden" //TODO : implementer le reste + } + }, + estUneDate: function(date) { //TODO mettre cette fonction dans un fichier commun + return new Date(date) != "Invalid Date"; + }, } } @@ -19,8 +38,8 @@ export default{