From 6f7359294e3da8097b5d685bf3adbe0c2ae9e4fd Mon Sep 17 00:00:00 2001 From: Sk Imtiaz Ahmed Date: Mon, 25 May 2020 05:08:24 +0600 Subject: [PATCH] Added 'My Project' section in hackathon projects - filtered existing data with user id - refactored card markup into component - added edit button to cards --- app/assets/v2/js/vue-components.js | 79 ++++++++++++++++++- .../templates/dashboard/index-vue.html | 69 ++++------------ 2 files changed, 93 insertions(+), 55 deletions(-) diff --git a/app/assets/v2/js/vue-components.js b/app/assets/v2/js/vue-components.js index 7a1c8a25d93..e0e4af7820a 100644 --- a/app/assets/v2/js/vue-components.js +++ b/app/assets/v2/js/vue-components.js @@ -1,4 +1,3 @@ - Vue.mixin({ data: function() { const isMobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent); @@ -188,7 +187,7 @@ Vue.component('tribes-settings', { Vue.component('project-directory', { delimiters: [ '[[', ']]' ], - props: ['tribe'], + props: [ 'tribe', 'userId' ], methods: { fetchProjects: function(newPage) { let vm = this; @@ -228,6 +227,16 @@ Vue.component('project-directory', { vm.hackathonProjects.push(item); }); + vm.userProjects = []; + if (vm.userId) { + vm.userProjects = vm.hackathonProjects.filter( + ({ profiles }) => profiles.some( + ({ id }) => id === parseInt(vm.userId, 10) + ) + ); + } + + vm.projectsNumPages = response.num_pages; vm.projectsHasNext = response.has_next; vm.numProjects = response.count; @@ -261,6 +270,7 @@ Vue.component('project-directory', { sponsor: this.tribe || null, hackathonSponsors: document.hackathonSponsors || [], hackathonProjects: document.hackathonProjects || [], + userProjects: document.userProjects || [], projectsPage: 1, hackathonId: document.hackathon_id || null, projectsNumPages: 0, @@ -306,6 +316,71 @@ Vue.component('project-directory', { } }); +Vue.component('project-card', { + delimiters: [ '[[', ']]' ], + props: [ 'project', 'edit' ], + methods: { + projectModal() { + let project = this.$props.project; + + projectModal(project.bounty.pk, project.pk); + } + }, + template: `
+
+ + badge + +
+ + +
+
+
[[ project.name ]]
+
+

+ [[ project.summary | truncate(500) ]] +

+
+ View Project + View Bounty + + + + @ [[ profile.handle ]] + + +
+
+ +
+ Team Members +
+ + + +
+
+ +
+
Looking for team members
+

+ [[ project.message ]] +

+
+ +
+ Sponsored by + + [[ project.bounty.org_name ]] +
+
+
+
` +}); + Vue.component('suggested-profiles', { props: ['profiles'], diff --git a/app/dashboard/templates/dashboard/index-vue.html b/app/dashboard/templates/dashboard/index-vue.html index d9bacb47e3b..3a51615c2aa 100644 --- a/app/dashboard/templates/dashboard/index-vue.html +++ b/app/dashboard/templates/dashboard/index-vue.html @@ -392,7 +392,7 @@

Hackathon Coming Soon!

({{projects_count}}) - +
-
-
-
- badge - -
- - -
-
-
[[ project.name ]]
-
-

- [[ project.summary | truncate(500) ]] -

-
- View Project - View Bounty - - - - @ [[ profile.handle ]] - - -
-
- -
- Team Members -
- - - -
-
- -
-
Looking for team members
-

- [[ project.message ]] -

-
- -
- Sponsored by - - [[ project.bounty.org_name ]] -
-
-
+
+

+ My Projects +

+
+
+

+ All Projects +

+
+
+
@@ -922,5 +882,8 @@
Invite [[numUsers]] Users to the Bounty
+ + {% include 'shared/current_profile.html' %} +