afficher les champs

front
Gwenael PLANCHON 1 year ago
parent da4a2d9530
commit 40ab493cc9

@ -55,20 +55,18 @@ export default{
<template> <template>
<!-- TODO : remplacer input par select ?--> <!-- TODO : remplacer input par select ?-->
<input v-model="endpoint"> <label for="endpoint">Endpoint API (REST) {{ REST_API }}</label>
<input v-model="endpoint" id="endpoint">
<button>Rafraichir</button> <button>Rafraichir</button>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th scope="col" v-for="nomColonne in Object.keys(scientifiques[0])">{{nomColonne}}</th> <th scope="col" v-for="nomColonne in Object.keys(scientifiques[0]??{})">{{nomColonne}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<LigneScientifique v-for="scientifique in scientifiques" <LigneScientifique v-for="champ in scientifiques"
:prenom="scientifique.prenom" :champs-init="champ"
:nom="scientifique.nom"
:date="scientifique.dateNaissance"
:descriptif="scientifique.descriptif"
></LigneScientifique> ></LigneScientifique>
</tbody> </tbody>
</table> </table>

@ -5,7 +5,7 @@ export default {
return{ return{
modeEdition:false, //vrai = remplacer les champs par des inputs modeEdition:false, //vrai = remplacer les champs par des inputs
champsAffiche:{nom:"Test", prenom:"Test"} //this.champsInit champs:this.champsInit
} }
}, },
methods:{ methods:{
@ -14,7 +14,7 @@ export default {
}, },
annuler: function(){ annuler: function(){
//remettre les valeurs a 0 //remettre les valeurs a 0
this.champsAffiche=this.champsInit, this.champs=this.champsInit
this.changerModeEdition() this.changerModeEdition()
}, },
@ -22,7 +22,7 @@ export default {
//TODO : comme dans ajout //TODO : comme dans ajout
//fetch("localhost/api/v1/scientifiques", {method:"PUT", body:JSON.stringify(donnees)}) //fetch("localhost/api/v1/scientifiques", {method:"PUT", body:JSON.stringify(donnees)})
console.log(this.champsAffiche) console.log(this.champs)
this.changerModeEdition() this.changerModeEdition()
} }
} }
@ -32,14 +32,14 @@ export default {
<template> <template>
<tr v-if="!this.modeEdition"> <tr v-if="!this.modeEdition">
<td v-for="item in champsAffiche"> <td v-for="item in champs">
<p>{{ item }}</p> <p>{{ item }}</p>
</td> </td>
<button class="btn-outline-secondary btn" v-on:click="changerModeEdition()">Modifier</button> <button class="btn-outline-secondary btn" v-on:click="changerModeEdition()">Modifier</button>
</tr> </tr>
<tr v-if="this.modeEdition"> <tr v-if="this.modeEdition">
<td v-for="item in champsAffiche"> <td v-for="item in champs">
<!--input class="form-control" type="text" v-model="item"--> <!--input class="form-control" type="text" v-model="item"-->
</td> </td>

Loading…
Cancel
Save