master
dohodin 2 years ago
parent 993a0815ae
commit 9a05a188f7

@ -1,8 +1,8 @@
export default {
props: {
teamAEdit: {
type: String,
require: true
require: true,
default: ""
},
},
data: function() {
@ -18,6 +18,12 @@ export default {
addTeam: function () {
try {
if (this.teamAEdit != null) {
this.id = this.teamAEdit.id
this.name = this.teamAEdit.name
this.description = this.teamAEdit.description
}
this.errorMessage = '';
if (!this.id) {
throw new RequiredFieldError("ID");
@ -35,11 +41,13 @@ export default {
throw new StringSize("Name", NAME_MINIMAL_SIZE)
}
const team = { id: this.id, name: this.name, description: this.description};
const team = { id: this.id, name: this.name, description: this.description };
if (this.teamAEdit != null) {
this.$emit('teamModifie', team);
} else {
this.$emit('teamAjoute', team);
}
@ -47,7 +55,7 @@ export default {
this.name = '';
this.description = '';
}catch (error) {
} catch (error) {
if (error instanceof RequiredFieldError) {
this.errorMessage=error
}
@ -56,22 +64,25 @@ export default {
}
return null;
}
},
}
},
template: `<section>
<form @submit.prevent>
<div v-bind:style="{ color: errorColor}">{{ errorMessage }}</div>
<div>
<label>ID</label><br/>
<input type="text" v-model="id"/>
<p v-if=this.teamAEdit><input type="text" v-model="this.teamAEdit.id" /></p>
<p v-else><input type="text" v-model="this.id" /></p>
</div>
<div>
<label>Name</label><br/>
<input type="text" v-model="name"/>
<p v-if=this.teamAEdit><input type="text" v-model="this.teamAEdit.name" /></p>
<p v-else><input type="text" v-model="this.name" /></p>
</div>
<div>
<label>Description</label><br/>
<textarea v-model="description"></textarea>
<p v-if=this.teamAEdit><textarea v-model="this.teamAEdit.description"/></p>
<p v-else><textarea v-model="this.description" /></p>
</div>
<input type="submit" value="Create Team" @click="addTeam"/>
</form>

@ -17,14 +17,11 @@ export default {
editParam: function (team) {
this.teamAEdit=team
console.log('lanceEdit')
},
updateTeam: function (team) {
console.log('update')
for (var i = 0; i < this.allTeam.length; i++) {
if (this.allTeam[i].id == this.teamAEdit.id) {
console.log('update + +')
this.allTeam[i].name = team.name
this.allTeam[i].description=team.description
}

Loading…
Cancel
Save