-
+
\ No newline at end of file
diff --git a/src/error/string_size.js b/src/error/string_size.js
new file mode 100644
index 0000000..96f207e
--- /dev/null
+++ b/src/error/string_size.js
@@ -0,0 +1,5 @@
+class StringSize extends Error {
+ constructor(field,sSize) {
+ super('Le champ ' + field + ' doit avoir une taille superieur à '+sSize);
+ }
+}
\ No newline at end of file
diff --git a/src/misc/constant.js b/src/misc/constant.js
index 322ba48..fd5147e 100644
--- a/src/misc/constant.js
+++ b/src/misc/constant.js
@@ -1 +1,3 @@
-const ERROR_COLOR = 'red';
\ No newline at end of file
+const ERROR_COLOR = 'red';
+const DESCRIPTION_MINIMAL_SIZE = 1;
+const NAME_MINIMAL_SIZE = 1;
\ No newline at end of file
diff --git a/src/view/navbar.js b/src/view/navbar.js
index 2b8dbe3..5a86813 100644
--- a/src/view/navbar.js
+++ b/src/view/navbar.js
@@ -20,5 +20,4 @@ export default {
Results
`
-
};
\ No newline at end of file
diff --git a/src/view/team_add.js b/src/view/team-add.js
similarity index 69%
rename from src/view/team_add.js
rename to src/view/team-add.js
index 44ac427..abee04c 100644
--- a/src/view/team_add.js
+++ b/src/view/team-add.js
@@ -1,7 +1,13 @@
export default {
+ props: {
+ teamAEdit: {
+ type: String,
+ require: true
+ },
+ },
data: function() {
return {
- id: '',
+ id:'',
name: '',
description: '',
errorMessage: '',
@@ -11,25 +17,31 @@ export default {
methods: {
addTeam: function () {
try {
+
this.errorMessage = '';
if (!this.id) {
- this.name = '';
- this.description= '';
throw new RequiredFieldError("ID");
}
if (!this.name) {
- this.id = '';
- this.description= '';
throw new RequiredFieldError("Name");
}
if (!this.description){
- this.id = '';
- this.name = '';
throw new RequiredFieldError("Description");
}
+ if (this.description.length < DESCRIPTION_MINIMAL_SIZE) {
+ throw new StringSize("Description", DESCRIPTION_MINIMAL_SIZE)
+ }
+ if (this.name.length < NAME_MINIMAL_SIZE) {
+ throw new StringSize("Name", NAME_MINIMAL_SIZE)
+ }
+
const team = { id: this.id, name: this.name, description: this.description};
- this.$emit('addTeam', team);
+ if (this.teamAEdit != null) {
+ this.$emit('teamModifie', team);
+ } else {
+ this.$emit('teamAjoute', team);
+ }
this.id = '';
this.name = '';
@@ -39,17 +51,20 @@ export default {
if (error instanceof RequiredFieldError) {
this.errorMessage=error
}
+ if (error instanceof StringSize) {
+ this.errorMessage = error
+ }
return null;
}
},
},
template: `