Merge remote-tracking branch 'origin/RaphouBranche' into dorian

# Conflicts:
#	index.html
#	src/view/navbar.js
#	src/view/team_add.js
master
dorian.hodin 2 years ago
commit a166676ac3

@ -1,2 +1,3 @@
# TP_JavaScript
Développeurs: HODIN Dorian , LACOTE Raphaël

@ -22,7 +22,9 @@
</teamcard>
</div>
<script src="/src/misc/constant.js"></script>
<script src="./src/misc/constant.js"></script>
<script src="./src/error/required_field_error.js"></script>
<script type="module">
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
@ -48,7 +50,7 @@
.component('TeamAdd', TeamAdd)
.component('Teamcard',Teamcard);
app.mount('#app');
</script>
</script>
</body>
</html>

@ -0,0 +1,5 @@
class RequiredFieldError extends Error {
constructor(field) {
super('Le champ '+field+' est obligatoire !');
}
}

@ -9,27 +9,42 @@ export default {
}
},
methods: {
addTeam: function() {
this.errorMessage = '';
if (!this.id ){
this.errorMessage = 'ID is required !';
return;
}else if (!this.name){
this.errorMessage = 'Name is required !';
return
}else if(!this.description) {
this.errorMessage = 'Description is required !';
return;
}
addTeam: function () {
try {
this.errorMessage = '';
if (!this.id) {
this.name = '';
this.description= '';
throw new RequiredFieldError("ID");
return;
}
if (!this.name) {
this.id = '';
this.description= '';
throw new RequiredFieldError("Name");
return;
}
if (!this.description){
this.id = '';
this.name = '';
throw new RequiredFieldError("Description");
return;
}
const team = { id: this.id, name: this.name, description: this.description};
console.log('form.addTeam', team);
const team = { id: this.id, name: this.name, description: this.description};
console.log('form.addTeam', team);
this.$emit('addTeam', team);
this.$emit('addTeam', team);
this.id = '';
this.name = '';
this.description = '';
this.id = '';
this.name = '';
this.description = '';
} catch (error) {
if (error instanceof RequiredFieldError) {
this.errorMessage=error
}
return null;
}
}
},
template: `<section>

Loading…
Cancel
Save