|
|
@ -2,14 +2,14 @@ export default{
|
|
|
|
emits: ['addTeam'],
|
|
|
|
emits: ['addTeam'],
|
|
|
|
data : function(){
|
|
|
|
data : function(){
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
Home: '',
|
|
|
|
teams:[],
|
|
|
|
Teams: '',
|
|
|
|
|
|
|
|
Results: '',
|
|
|
|
|
|
|
|
id:'',
|
|
|
|
id:'',
|
|
|
|
name:'',
|
|
|
|
name:'',
|
|
|
|
description:'',
|
|
|
|
description:'',
|
|
|
|
clicked: false,
|
|
|
|
clicked: false,
|
|
|
|
errMessage:''
|
|
|
|
errMessage:'',
|
|
|
|
|
|
|
|
edit:false,
|
|
|
|
|
|
|
|
idxEdit:null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
@ -49,16 +49,40 @@ export default{
|
|
|
|
this.addTeam();
|
|
|
|
this.addTeam();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addTeam: function() {
|
|
|
|
addTeam: function(){
|
|
|
|
let team = new Team(this.id, this.name, this.description);
|
|
|
|
let team = new Team(this.id, this.name, this.description);
|
|
|
|
console.log(team);
|
|
|
|
console.log(team);
|
|
|
|
this.$emit("addTeam",team);
|
|
|
|
if(!this.edit){//adding a team
|
|
|
|
|
|
|
|
this.teams.push(team);
|
|
|
|
this.id='';
|
|
|
|
this.id='';
|
|
|
|
this.name='';
|
|
|
|
this.name='';
|
|
|
|
this.description='';
|
|
|
|
this.description='';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{//editing a team
|
|
|
|
|
|
|
|
this.teams[this.idxEdit]=team;
|
|
|
|
|
|
|
|
this.id='';
|
|
|
|
|
|
|
|
this.name='';
|
|
|
|
|
|
|
|
this.description='';
|
|
|
|
|
|
|
|
this.edit=false;
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
myfun: function() {
|
|
|
|
editTeam: function (team) {
|
|
|
|
this.clicked=!this.clicked;
|
|
|
|
this.edit=!this.edit;
|
|
|
|
|
|
|
|
this.teams.forEach((e,idx) => {
|
|
|
|
|
|
|
|
if(e.id==team.id&&e.name==team.name&&e.description==team.description){
|
|
|
|
|
|
|
|
this.idxEdit=idx;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if(this.edit){
|
|
|
|
|
|
|
|
this.id=team.id;
|
|
|
|
|
|
|
|
this.name=team.name ;
|
|
|
|
|
|
|
|
this.description=team.description;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
this.id='';
|
|
|
|
|
|
|
|
this.name='';
|
|
|
|
|
|
|
|
this.description='';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
template:
|
|
|
|
template:
|
|
|
@ -68,7 +92,8 @@ export default{
|
|
|
|
<span @click="myfun" style="cursor: pointer">Teams</span>
|
|
|
|
<span @click="myfun" style="cursor: pointer">Teams</span>
|
|
|
|
<span>Results</span>
|
|
|
|
<span>Results</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<form @submit.prevent v-if="clicked">
|
|
|
|
<div v-if="clicked">
|
|
|
|
|
|
|
|
<form @submit.prevent>
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
<label>{{errMessage}}</label><br/>
|
|
|
|
<label>{{errMessage}}</label><br/>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
@ -88,5 +113,11 @@ export default{
|
|
|
|
|
|
|
|
|
|
|
|
<input type="submit" value="Submit" v-on:click="checkFields"/>
|
|
|
|
<input type="submit" value="Submit" v-on:click="checkFields"/>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<team-card @edit-team="editTeam" v-for="team in teams"
|
|
|
|
|
|
|
|
:id="team.id"
|
|
|
|
|
|
|
|
:nom="team.name"
|
|
|
|
|
|
|
|
:description="team.description">
|
|
|
|
|
|
|
|
</team-card>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
`
|
|
|
|
}
|
|
|
|
}
|
|
|
|