From c25a135d98eda0cd4679e763c1a1433b7b2c71ef Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 07:08:37 +0100 Subject: [PATCH 1/6] link in api parameter --- src/class/api-service.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/class/api-service.js b/src/class/api-service.js index 4331a01..aeb118c 100644 --- a/src/class/api-service.js +++ b/src/class/api-service.js @@ -1,7 +1,7 @@ class ApiService{ constructor(){} - async get(id){ - const baseUrl = `https://jsonplaceholder.typicode.com/posts/${id}`;//edit + async get(link){ + const baseUrl = `${link}`;//edit const headers = { method: 'GET' }; @@ -10,8 +10,8 @@ class ApiService{ console.log(responseJson) } - async post(){ - const baseUrl = `https://jsonplaceholder.typicode.com/posts/`;//edit + async post(link){ + const baseUrl = `${link}`;//edit const headers = { method: 'POST', headers: { From ad671bc9dcc2541bc820fc7c4c3ed28116b06030 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 08:13:32 +0100 Subject: [PATCH 2/6] edit completly functional : fill autpo fields --- index.html | 31 +-------------- src/view/nav-bar.js | 91 ++++++++++++++++++++++++++++++--------------- 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/index.html b/index.html index 1895587..33b1f56 100644 --- a/index.html +++ b/index.html @@ -9,13 +9,7 @@

TP-noté

- - - - +
@@ -31,33 +25,12 @@ created(){}, data(){ return{ - teams: [], - edit:false, - newTeam:null } }, methods:{ - addTeam: function(equipe){ - if(!this.edit){//adding a team - this.teams.push(equipe); - } - else{//editing a team - this.teams.forEach((e,idx) => { - if(e.id==this.newTeam.id&&e.name==this.newTeam.name&&e.description==this.newTeam.description){ - this.teams[idx]=equipe; - } - }); - this.edit=false; - this.newTeam=null; - } - }, - editTeam: function (team) { - this.newTeam=team; - this.edit=!this.edit; - } + } }); - app.component('NavBar', NavBar); app.component('TeamCard', TeamCard); diff --git a/src/view/nav-bar.js b/src/view/nav-bar.js index 2d52d1f..3b21efd 100644 --- a/src/view/nav-bar.js +++ b/src/view/nav-bar.js @@ -2,14 +2,14 @@ export default{ emits: ['addTeam'], data : function(){ return { - Home: '', - Teams: '', - Results: '', + teams:[], id:'', name:'', description:'', clicked: false, - errMessage:'' + errMessage:'', + edit:false, + idxEdit:null } }, methods: { @@ -28,7 +28,7 @@ export default{ document.querySelector("#id").setAttribute("style","border: 1px solid #d66"); } if(this.name===""){ - this.errMessage+=" name"; + this.errMessage+=" name"; document.querySelector("#name").setAttribute("style","border: 1px solid #d66"); } if(this.description===""){ @@ -49,16 +49,40 @@ export default{ this.addTeam(); } }, - addTeam: function() { + addTeam: function(){ let team = new Team(this.id, this.name, this.description); console.log(team); - this.$emit("addTeam",team); - this.id=''; - this.name=''; - this.description=''; + if(!this.edit){//adding a team + this.teams.push(team); + this.id=''; + this.name=''; + this.description=''; + } + else{//editing a team + this.teams[this.idxEdit]=team; + this.id=''; + this.name=''; + this.description=''; + this.edit=false; + } }, - myfun: function() { - this.clicked=!this.clicked; + editTeam: function (team) { + 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: @@ -68,25 +92,32 @@ export default{ Teams Results -
-
-
-
-
- -
- -
-
- -
+
+ +
+
+
+
+ +
+ +
+
+ +
-
-
- -
+
+
+ +
- - + + + + +
` } From da8f034983c13d403d8f2a94ce76e498972dcce7 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 08:23:58 +0100 Subject: [PATCH 3/6] export option --- src/view/nav-bar.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/view/nav-bar.js b/src/view/nav-bar.js index 3b21efd..900f30c 100644 --- a/src/view/nav-bar.js +++ b/src/view/nav-bar.js @@ -83,6 +83,9 @@ export default{ this.name=''; this.description=''; } + }, + Export:function(){ + console.log(JSON.stringify(this.teams)) } }, template: @@ -92,7 +95,7 @@ export default{ Teams Results -
+


@@ -118,6 +121,7 @@ export default{ :nom="team.name" :description="team.description"> +
` } From e7696557c5e45d98c617db542dbd9931ca93da7f Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 08:26:49 +0100 Subject: [PATCH 4/6] add constraint if no team, button not display --- src/view/nav-bar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/nav-bar.js b/src/view/nav-bar.js index 900f30c..f77f681 100644 --- a/src/view/nav-bar.js +++ b/src/view/nav-bar.js @@ -121,7 +121,7 @@ export default{ :nom="team.name" :description="team.description"> - +
` } From 232ca3b92851087f3454ba83522f1131a4f81b80 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 08:33:19 +0100 Subject: [PATCH 5/6] change name --- src/view/nav-bar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/view/nav-bar.js b/src/view/nav-bar.js index f77f681..75d3e51 100644 --- a/src/view/nav-bar.js +++ b/src/view/nav-bar.js @@ -6,7 +6,7 @@ export default{ id:'', name:'', description:'', - clicked: false, + teamClicked: false, errMessage:'', edit:false, idxEdit:null @@ -14,7 +14,7 @@ export default{ }, methods: { myfun: function() { - this.clicked=!this.clicked; + this.teamClicked=!this.teamClicked; }, checkFields: function() { this.errMessage=""; @@ -95,7 +95,7 @@ export default{ Teams Results -
+


From 87d30198c78d92679366d0ad0e087af10c658449 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 14 Mar 2023 08:46:45 +0100 Subject: [PATCH 6/6] add div home --- src/view/nav-bar.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/view/nav-bar.js b/src/view/nav-bar.js index 75d3e51..1b02564 100644 --- a/src/view/nav-bar.js +++ b/src/view/nav-bar.js @@ -7,14 +7,30 @@ export default{ name:'', description:'', teamClicked: false, + homeClicked: false, errMessage:'', edit:false, idxEdit:null } }, methods: { - myfun: function() { - this.teamClicked=!this.teamClicked; + clickTeams: function() { + if(!this.teamClicked){ + this.teamClicked=true; + this.homeClicked=false; + } + else{ + this.teamClicked=false; + } + }, + clickHome: function() { + if(!this.homeClicked){ + this.homeClicked=true; + this.teamClicked=false; + } + else{ + this.homeClicked=false; + } }, checkFields: function() { this.errMessage=""; @@ -91,10 +107,14 @@ export default{ template: `
- Home - Teams + Home + Teams Results
+
+

Homeee

+
+