|
|
|
@ -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>
|
|
|
|
|