Ajout description

pull/1/head
Aurian JAULT 2 years ago
commit 5f9c2fb1f6

@ -9,11 +9,12 @@
<body> <body>
<div id="app"> <div id="app">
<h1>TP-noté</h1> <h1>TP-noté</h1>
<nav-bar @add-teams="addTeam"></nav-bar> <nav-bar @add-team="addTeam"></nav-bar>
<team-card v-for="team in teams" <team-card v-for="team in teams"
:id="team.id" :id="team.id"
:nom="team.name"> :nom="team.name"
:description="team.description">
</team-card> </team-card>
</div> </div>

@ -1,5 +1,5 @@
export default{ export default{
emits: ['addTeams'], emits: ['addTeam'],
data : function(){ data : function(){
return { return {
Home: '', Home: '',
@ -8,22 +8,48 @@ export default{
id:'', id:'',
name:'', name:'',
description:'', description:'',
clicked: false clicked: false,
errMessage:''
} }
}, },
methods: { methods: {
pushTeam: function() { myfun: function() {
let team = new Team(this.id, this.name); this.clicked=!this.clicked;
this.$emit('addTeams',team); },
checkFields: function() {
if(this.id===""){
this.errMessage+="The id field must be required "
}
else if(this.name===""){
this.errMessage+="The name field must be required "
}
else if(this.description===""){
this.errMessage+="The description field must be required "
}
else{
if(this.name.lenght<5){
this.errMessage+="The name must have at least 5 caracters "
}
if(this.description.lenght<20){
this.description+="The description must have at least 20 caracters "
}
}
if(this.errMessage.length===0){
console.log("jappelle la fonction")
this.addTeam();
}
},
addTeam: function() {
let team = new Team(this.id, this.name, this.description);
console.log(team);
this.$emit("addTeam",team);
this.id=''; this.id='';
this.name=''; this.name='';
}, },
myfun: function() { myfun: function() {
console.log("gngn"); console.log("gngn");
this.clicked=!this.clicked; this.clicked=!this.clicked;
} }
}, },
template: template:
` `
@ -34,6 +60,7 @@ export default{
</div> </div>
<form @submit.prevent v-if="clicked"> <form @submit.prevent v-if="clicked">
<br> <br>
<label>{{errMessage}}</label><br/>
<div> <div>
<label>id</label><br/> <label>id</label><br/>
<input type="number" v-model="id"/> <input type="number" v-model="id"/>
@ -44,7 +71,12 @@ export default{
<input type="text" v-model="name"/> <input type="text" v-model="name"/>
</div> </div>
<input type="submit" value="Submit" @click="pushTeam"/> <div>
<label>Description</label><br/>
<textarea v-model="description"></textarea>
</div>
<input type="submit" value="Submit" v-on:click="checkFields"/>
</form> </form>
` `
} }

@ -1,13 +1,14 @@
export default{ export default{
props: { props: {
id: Number, id: Number,
nom: String nom: String,
description: String
}, },
methods: { methods: {
}, },
template: ` template: `
<div id="teamCard"> <div id="teamCard">
<span>{{id}} {{nom}}</span> <span>{{id}} {{nom}} description: {{description}}</span>
</div> </div>
` `
} }

Loading…
Cancel
Save