Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon filter #4145

Merged
merged 9 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions app/assets/v2/css/search_bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions app/assets/v2/css/sidebar_search.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
86 changes: 59 additions & 27 deletions app/assets/v2/js/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ var getActiveFilters = function() {
let _filters = filters.slice();

_filters.push('keywords', 'order_by', 'org');
if (document.hackathon) {
resetFilters(true);
filters.push('org');
}
_filters.forEach(filter => {
if (getParam(filter)) {
localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, '');
Expand Down Expand Up @@ -374,13 +378,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}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the backticks here instead of single quotes?

Copy link
Contributor Author

@octavioamu octavioamu Apr 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah my bad! thanks!

uri += '&offset=' + offset;
uri += '&limit=51';
}

uri += '&offset=' + offset;
uri += '&limit=' + results_limit;
return uri;
};

Expand Down Expand Up @@ -419,6 +425,8 @@ var reset_offset = function() {
document.offset = 0;
};

let organizations = [];

var refreshBounties = function(event, offset, append, do_save_search) {

// Allow search for freeform text
Expand Down Expand Up @@ -452,6 +460,8 @@ var refreshBounties = function(event, offset, append, do_save_search) {
paint_search_tabs();
window.history.pushState('', '', window.location.pathname + '?' + buildURI());
}
} else {
toggleAny(event);
}

if (!append) {
Expand All @@ -477,9 +487,29 @@ 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) => `
<div class="form__radio option">
<input name="org" id="${org}" type="radio" value="${org}" val-ui="${org}" />
<label class="filter-label" for=${org}>
<img src="/dynamic/avatar/${org}" class="rounded-circle" width="24" height="24"> ${org}
</label>
</div>
`).join(' ')}
`);
}
};

explorer.bounties_request = $.get(bountiesURI, function(results, x) {
results = sanitizeAPIResults(results);

getOrgs(results);
if (results.length === 0 && !append) {
if (localStorage['referrer'] === 'onboard') {
$('.no-results').removeClass('hidden');
Expand Down Expand Up @@ -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 [email protected]') }, '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 [email protected]') }, 'error');
}).always(function() {
$('.loading').css('display', 'none');
});
}
};

window.addEventListener('load', function() {
Expand Down Expand Up @@ -746,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();
Expand Down
8 changes: 7 additions & 1 deletion app/dashboard/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@
<div id="dashboard-content" class="container-fluid no-gutter">
<div class="row">
{% if hackathon %}
<div class="col-12 col-lg-12 col-xl-12 body">
<div class="col-12 col-lg-3 col-xl-2 invisible" id="sidebar_container" style="background: #F2F6F9;">
{% include 'dashboard/sidebar_search_hackathon.html' %}
</div>
<div class="col-12 col-lg-9 col-xl-10 body">
<div class="container p-2" id="bounties">
<div id="dashboard-title" class="hidden">
{% include 'shared/search_bar.html' %}
</div>
<div class="col-12 col-lg-12 pl-2 pb-1 title-row">
<span class="font-title ml-1 text-highlight-gc-blue">{% trans 'Bounties' %}</span>
</div>
Expand Down
69 changes: 69 additions & 0 deletions app/dashboard/templates/dashboard/sidebar_search_hackathon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{% 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 <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n static %}
<link rel="stylesheet" href={% static "v2/css/sidebar_search.css" %}>
<div class="sidebar_search font-body">

<form>
<div class="col">
<div class="col-12 subheading">
{% trans "Status" %}
</div>
<div class="col-12 options" id="list-orgs">

<div class="form__radio option mb-2">
<input name="org" id="any_org" type="radio" value="any" checked/>
<label class="filter-label" for=any_org>{% trans "All" %}</label>
</div>

</div>
</div>
<div class="col">
<div class="col-12 subheading">{% trans "Network" %}</div>
<div class="col-12 options">
<div class="checkbox_container">
<input name="network" id="local" type="checkbox" value="local" val-ui='Custom Network' />
<span class="checkbox"></span>
<div class="filter-label">
<label for=local>{% trans "Custom" %}</label>
</div>
</div>
<div class="checkbox_container">
<input name="network" id="ropsten" type="checkbox" value="ropsten" val-ui='Ropsten' />
<span class="checkbox"></span>
<div class="filter-label">
<label for=ropsten>{% trans "Ropsten" %}</label>
</div>
</div>
<div class="checkbox_container">
<input name="network" id="rinkeby" type="checkbox" value="rinkeby" val-ui='Rinkeby' />
<span class="checkbox"></span>
<div class="filter-label">
<label for=rinkeby>{% trans "Rinkeby" %}</label>
</div>
</div>
<div class="checkbox_container">
<input name="network" id="mainnet" type="checkbox" value="mainnet" val-ui='Mainnet' checked />
<span class="checkbox"></span>
<div class="filter-label">
<label for=mainnet>{% trans "Mainnet" %}</label>
</div>
</div>
</div>
</div>
</form>
</div>