Skip to content

Commit

Permalink
fix applicants filter (#4810)
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored and danlipert committed Jul 18, 2019
1 parent 7ad0e61 commit 313da87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 13 additions & 17 deletions app/assets/v2/js/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ var save_sidebar_latest = function() {
const set_sidebar_defaults = () => {
const q = getParam('q');
const org = getParam('org');
const applicants = getParam('applicants');

if (q) {
const keywords = decodeURIComponent(q).replace(/^,|\s|,\s*$/g, '');
Expand Down Expand Up @@ -173,6 +174,11 @@ const set_sidebar_defaults = () => {
}
}

if (applicants) {
if (localStorage['applicants']) {
localStorage['applicants'] = applicants;
}
}
getActiveFilters();

if (localStorage['order_by']) {
Expand All @@ -183,7 +189,7 @@ const set_sidebar_defaults = () => {
filters.forEach((filter) => {
if (localStorage[filter]) {
if (filter === 'applicants') {
$('#applicants_box').val(localStorage[filter]).trigger('change');
$('#applicants_box').val(localStorage[filter]).trigger('change.select2');
}

localStorage[filter].split(',').forEach(function(val) {
Expand Down Expand Up @@ -602,8 +608,8 @@ var resetFilters = function(resetKeyword) {
$('input[name="' + filter + '"][value="' + tag[j].value + '"]').prop('checked', false);
}

if (filter === 'applicants' && !document.hackathon) {
$('#applicants_box').val('0').trigger('change');
if (resetKeyword && filter === 'applicants' && !document.hackathon) {
$('#applicants_box').val('ALL').trigger('change.select2');
} else if (resetKeyword && filter === 'applicants' && document.hackathon) {
localStorage.setItem(filter, '');
}
Expand Down Expand Up @@ -801,20 +807,10 @@ $(document).ready(function() {
});

// sidebar filters
$('.sidebar_search , .sidebar_search label').change('input[type=radio]', function(e) {
reset_offset();
refreshBounties(null, 0, false, true);
e.preventDefault();
});

// sidebar filters
$('.sidebar_search input[type=checkbox], .sidebar_search label').change(function(e) {
reset_offset();
// refreshBounties(null, 0, false, true);
e.preventDefault();
});

$('#org').change(function(e) {
$(`.sidebar_search input[type=radio],
.sidebar_search input[type=checkbox],
.sidebar_search .js-select2,
#org`).change(function(e) {
reset_offset();
refreshBounties(null, 0, false, true);
e.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/dashboard/sidebar_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@
</div>
<div class="col-12 options">
<select class="w-100 js-select2" name="applicants" id="applicants_box">
<option value="ALL">ALL</option>
<option value="0">0</option>
<option value="1-5">1-5</option>
<option value="ALL">ALL</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 313da87

Please sign in to comment.