From 2ecc185f048a64c75c892c71c131f6504a7398c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Fri, 5 Apr 2019 22:14:37 -0300 Subject: [PATCH 1/5] add dynamic filters --- app/assets/v2/css/search_bar.css | 9 -- app/assets/v2/css/sidebar_search.css | 9 ++ app/assets/v2/js/pages/dashboard.js | 84 +++++++++++++------ app/dashboard/templates/dashboard/index.html | 8 +- .../dashboard/sidebar_search_hackathon.html | 36 ++++++++ 5 files changed, 110 insertions(+), 36 deletions(-) create mode 100644 app/dashboard/templates/dashboard/sidebar_search_hackathon.html diff --git a/app/assets/v2/css/search_bar.css b/app/assets/v2/css/search_bar.css index ee822070bad..e0dca204129 100644 --- a/app/assets/v2/css/search_bar.css +++ b/app/assets/v2/css/search_bar.css @@ -69,15 +69,6 @@ overflow-y: scroll; } -.close-icon { - position: absolute; - top: 13px; - right: 25px; - width: 15px; - display: none; - cursor: pointer; -} - #search_nav li { background-color: #fff; border: 1px solid #d3d6e2; diff --git a/app/assets/v2/css/sidebar_search.css b/app/assets/v2/css/sidebar_search.css index 4bb4b9631ee..64f9c6d4768 100644 --- a/app/assets/v2/css/sidebar_search.css +++ b/app/assets/v2/css/sidebar_search.css @@ -15,6 +15,15 @@ font-size: 0.8rem; } +.close-icon { + position: absolute; + top: 13px; + right: 25px; + width: 15px; + display: none; + cursor: pointer; +} + .sidebar_search .options .option { margin-bottom: 2px; } diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index d997a80aad8..eeb28163845 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -374,13 +374,15 @@ var get_search_URI = function(offset, order) { if (!document.hackathon) { if (typeof order_by !== 'undefined') { uri += '&order_by=' + order_by; + uri += '&offset=' + offset; + uri += '&limit=' + results_limit; } } else { - uri += '&event_tag=' + document.hackathon; + uri += `&event_tag=${document.hackathon}`; + uri += '&offset=' + offset; + uri += '&limit=100'; } - uri += '&offset=' + offset; - uri += '&limit=' + results_limit; return uri; }; @@ -419,6 +421,8 @@ var reset_offset = function() { document.offset = 0; }; +let organizations = []; + var refreshBounties = function(event, offset, append, do_save_search) { // Allow search for freeform text @@ -452,6 +456,9 @@ var refreshBounties = function(event, offset, append, do_save_search) { paint_search_tabs(); window.history.pushState('', '', window.location.pathname + '?' + buildURI()); } + } else { + + } if (!append) { @@ -477,9 +484,32 @@ var refreshBounties = function(event, offset, append, do_save_search) { explorer.bounties_request.abort(); } + const getOrgs = (results) => { + if (organizations.length === 0) { + results.filter((bounty)=>{ + organizations.push(bounty.org_name); + }); + organizations = [...new Set(organizations)]; + + $('#list-orgs').append(` + ${organizations.map((org, index) => ` +
+ + +
+ `).join(' ')} + `); + } + + }; + // console.log(organ) + explorer.bounties_request = $.get(bountiesURI, function(results, x) { results = sanitizeAPIResults(results); - + console.log(results) + getOrgs(results); if (results.length === 0 && !append) { if (localStorage['referrer'] === 'onboard') { $('.no-results').removeClass('hidden'); @@ -529,31 +559,33 @@ var refreshBounties = function(event, offset, append, do_save_search) { $('.loading').css('display', 'none'); }); - explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { - results = sanitizeAPIResults(results); - - if (results.length === 0 && !append) { - $('.featured-bounties').hide(); - if (localStorage['referrer'] === 'onboard') { - $('.no-results').removeClass('hidden'); - $('#dashboard-content').addClass('hidden'); - } else { - $('.nonefound').css('display', 'none'); + if (!document.hackathon) { + explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { + results = sanitizeAPIResults(results); + + if (results.length === 0 && !append) { + $('.featured-bounties').hide(); + if (localStorage['referrer'] === 'onboard') { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'none'); + } } - } - var html = renderFeaturedBountiesFromResults(results, true); + var html = renderFeaturedBountiesFromResults(results, true); - if (html) { - $('.featured-bounties').show(); - $('#featured-card-container').html(html); - } - }).fail(function() { - if (explorer.bounties_request.readyState !== 0) - _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); - }).always(function() { - $('.loading').css('display', 'none'); - }); + if (html) { + $('.featured-bounties').show(); + $('#featured-card-container').html(html); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + }); + } }; window.addEventListener('load', function() { diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 9e30522ccf3..f9ae32f3d1b 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -58,8 +58,14 @@
{% if hackathon %} -
+ +
+
{% trans 'Bounties' %}
diff --git a/app/dashboard/templates/dashboard/sidebar_search_hackathon.html b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html new file mode 100644 index 00000000000..8d4c5c1a9a7 --- /dev/null +++ b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html @@ -0,0 +1,36 @@ +{% comment %} + Copyright (C) 2018 Gitcoin Core + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +{% endcomment %} +{% load i18n static %} + + From 52c0c33bfa69a9e8c5b20dd24981ffd7bb0f8e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Fri, 5 Apr 2019 22:14:37 -0300 Subject: [PATCH 2/5] add dynamic filters --- app/assets/v2/css/search_bar.css | 9 -- app/assets/v2/css/sidebar_search.css | 9 ++ app/assets/v2/js/pages/dashboard.js | 84 +++++++++++++------ app/dashboard/templates/dashboard/index.html | 8 +- .../dashboard/sidebar_search_hackathon.html | 36 ++++++++ 5 files changed, 110 insertions(+), 36 deletions(-) create mode 100644 app/dashboard/templates/dashboard/sidebar_search_hackathon.html diff --git a/app/assets/v2/css/search_bar.css b/app/assets/v2/css/search_bar.css index ee822070bad..e0dca204129 100644 --- a/app/assets/v2/css/search_bar.css +++ b/app/assets/v2/css/search_bar.css @@ -69,15 +69,6 @@ overflow-y: scroll; } -.close-icon { - position: absolute; - top: 13px; - right: 25px; - width: 15px; - display: none; - cursor: pointer; -} - #search_nav li { background-color: #fff; border: 1px solid #d3d6e2; diff --git a/app/assets/v2/css/sidebar_search.css b/app/assets/v2/css/sidebar_search.css index 4bb4b9631ee..64f9c6d4768 100644 --- a/app/assets/v2/css/sidebar_search.css +++ b/app/assets/v2/css/sidebar_search.css @@ -15,6 +15,15 @@ font-size: 0.8rem; } +.close-icon { + position: absolute; + top: 13px; + right: 25px; + width: 15px; + display: none; + cursor: pointer; +} + .sidebar_search .options .option { margin-bottom: 2px; } diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index d997a80aad8..eeb28163845 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -374,13 +374,15 @@ var get_search_URI = function(offset, order) { if (!document.hackathon) { if (typeof order_by !== 'undefined') { uri += '&order_by=' + order_by; + uri += '&offset=' + offset; + uri += '&limit=' + results_limit; } } else { - uri += '&event_tag=' + document.hackathon; + uri += `&event_tag=${document.hackathon}`; + uri += '&offset=' + offset; + uri += '&limit=100'; } - uri += '&offset=' + offset; - uri += '&limit=' + results_limit; return uri; }; @@ -419,6 +421,8 @@ var reset_offset = function() { document.offset = 0; }; +let organizations = []; + var refreshBounties = function(event, offset, append, do_save_search) { // Allow search for freeform text @@ -452,6 +456,9 @@ var refreshBounties = function(event, offset, append, do_save_search) { paint_search_tabs(); window.history.pushState('', '', window.location.pathname + '?' + buildURI()); } + } else { + + } if (!append) { @@ -477,9 +484,32 @@ var refreshBounties = function(event, offset, append, do_save_search) { explorer.bounties_request.abort(); } + const getOrgs = (results) => { + if (organizations.length === 0) { + results.filter((bounty)=>{ + organizations.push(bounty.org_name); + }); + organizations = [...new Set(organizations)]; + + $('#list-orgs').append(` + ${organizations.map((org, index) => ` +
+ + +
+ `).join(' ')} + `); + } + + }; + // console.log(organ) + explorer.bounties_request = $.get(bountiesURI, function(results, x) { results = sanitizeAPIResults(results); - + console.log(results) + getOrgs(results); if (results.length === 0 && !append) { if (localStorage['referrer'] === 'onboard') { $('.no-results').removeClass('hidden'); @@ -529,31 +559,33 @@ var refreshBounties = function(event, offset, append, do_save_search) { $('.loading').css('display', 'none'); }); - explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { - results = sanitizeAPIResults(results); - - if (results.length === 0 && !append) { - $('.featured-bounties').hide(); - if (localStorage['referrer'] === 'onboard') { - $('.no-results').removeClass('hidden'); - $('#dashboard-content').addClass('hidden'); - } else { - $('.nonefound').css('display', 'none'); + if (!document.hackathon) { + explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { + results = sanitizeAPIResults(results); + + if (results.length === 0 && !append) { + $('.featured-bounties').hide(); + if (localStorage['referrer'] === 'onboard') { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'none'); + } } - } - var html = renderFeaturedBountiesFromResults(results, true); + var html = renderFeaturedBountiesFromResults(results, true); - if (html) { - $('.featured-bounties').show(); - $('#featured-card-container').html(html); - } - }).fail(function() { - if (explorer.bounties_request.readyState !== 0) - _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); - }).always(function() { - $('.loading').css('display', 'none'); - }); + if (html) { + $('.featured-bounties').show(); + $('#featured-card-container').html(html); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + }); + } }; window.addEventListener('load', function() { diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 9e30522ccf3..f9ae32f3d1b 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -58,8 +58,14 @@
{% if hackathon %} -
+ +
+
{% trans 'Bounties' %}
diff --git a/app/dashboard/templates/dashboard/sidebar_search_hackathon.html b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html new file mode 100644 index 00000000000..8d4c5c1a9a7 --- /dev/null +++ b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html @@ -0,0 +1,36 @@ +{% comment %} + Copyright (C) 2018 Gitcoin Core + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +{% endcomment %} +{% load i18n static %} + + From bf411c1f346ffdb656c198545c9c815d7c5ad857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Mon, 8 Apr 2019 15:07:53 -0300 Subject: [PATCH 3/5] add filters --- app/assets/v2/js/pages/dashboard.js | 20 +++++----- .../dashboard/sidebar_search_hackathon.html | 39 +++++++++++++++++-- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index eeb28163845..e79450671ad 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -87,6 +87,9 @@ var getActiveFilters = function() { let _filters = filters.slice(); _filters.push('keywords', 'order_by', 'org'); + if (document.hackathon) { + filters.push('org'); + } _filters.forEach(filter => { if (getParam(filter)) { localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, ''); @@ -380,7 +383,7 @@ var get_search_URI = function(offset, order) { } else { uri += `&event_tag=${document.hackathon}`; uri += '&offset=' + offset; - uri += '&limit=100'; + uri += '&limit=51'; } return uri; @@ -457,8 +460,7 @@ var refreshBounties = function(event, offset, append, do_save_search) { window.history.pushState('', '', window.location.pathname + '?' + buildURI()); } } else { - - + toggleAny(event); } if (!append) { @@ -494,21 +496,19 @@ var refreshBounties = function(event, offset, append, do_save_search) { $('#list-orgs').append(` ${organizations.map((org, index) => `
- - + +
`).join(' ')} `); } - }; // console.log(organ) explorer.bounties_request = $.get(bountiesURI, function(results, x) { results = sanitizeAPIResults(results); - console.log(results) getOrgs(results); if (results.length === 0 && !append) { if (localStorage['referrer'] === 'onboard') { @@ -778,7 +778,7 @@ $(document).ready(function() { }); // sidebar filters - $('.sidebar_search input[type=radio], .sidebar_search label').change(function(e) { + $('.sidebar_search , .sidebar_search label').change('input[type=radio]', function(e) { reset_offset(); refreshBounties(null, 0, false, true); e.preventDefault(); diff --git a/app/dashboard/templates/dashboard/sidebar_search_hackathon.html b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html index 8d4c5c1a9a7..52d3ba79628 100644 --- a/app/dashboard/templates/dashboard/sidebar_search_hackathon.html +++ b/app/dashboard/templates/dashboard/sidebar_search_hackathon.html @@ -22,15 +22,48 @@
{% trans "Status" %} -
- - + +
+
+
+
{% trans "Network" %}
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+
From c9ab3d486def4803188d533352029d597a36b05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Mon, 8 Apr 2019 17:04:57 -0300 Subject: [PATCH 4/5] reset filters --- app/assets/v2/js/pages/dashboard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index e79450671ad..dc2228bf8ce 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -88,6 +88,7 @@ var getActiveFilters = function() { _filters.push('keywords', 'order_by', 'org'); if (document.hackathon) { + resetFilters(true); filters.push('org'); } _filters.forEach(filter => { From 7be025c63b4bb21f702ef2526522e33f13d6f3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Thu, 11 Apr 2019 13:30:48 -0300 Subject: [PATCH 5/5] remove comment --- app/assets/v2/js/pages/dashboard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index dc2228bf8ce..776daa03116 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -506,7 +506,6 @@ var refreshBounties = function(event, offset, append, do_save_search) { `); } }; - // console.log(organ) explorer.bounties_request = $.get(bountiesURI, function(results, x) { results = sanitizeAPIResults(results);