Skip to content

Commit fcbedf8

Browse files
Merge pull request #1159 from GSA/staging
Staging
2 parents 10482fb + 3531ad0 commit fcbedf8

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

_includes/training-resources/filter.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<button type="button" aria-label="Price Band 500" data-min="500" data-max="1000" data-column-num="{{ columns.price }}" class="filterBtn usa-button padding-1 margin-bottom-2 margin-right-0 text-bold text-color border-1px bg-button radius-lg button-border">$500 - $1,000</button>
212212
<button type="button" aria-label="Price Band 1000" data-min="1000" data-max="2000" data-column-num="{{ columns.price }}" class="filterBtn usa-button padding-1 margin-bottom-2 margin-right-0 text-bold text-color border-1px bg-button radius-lg button-border">$1,000 - $2,000</button>
213213
<button type="button" aria-label="Price Band 2000" data-min="2000" data-max="10000" data-column-num="{{ columns.price }}" class="filterBtn usa-button padding-1 margin-bottom-2 margin-right-0 text-bold text-color border-1px bg-button radius-lg button-border">$2,000 - $10,000</button>
214+
<button type="button" aria-label="Price Band 10000" data-min="10000" data-max="15000" data-column-num="{{ columns.price }}" class="filterBtn usa-button padding-1 margin-bottom-2 margin-right-0 text-bold text-color border-1px bg-button radius-lg button-border">$10,000 - $15,000</button>
214215
</div>
215216

216217
<label class="margin-top-0 text-color font-sans-xs text-bold">Training Providers<i class="fa fa-info-circle usa-tooltip margin-left-1 font-size-16" data-position="right" title="Filter your search by training providers" aria-label="Information about filtering your search"></i></label>

_includes/training-resources/results.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div id="career-advancement-results-container" class="tablet:grid-col-7 desktop:grid-col-8 padding-right-4 padding-top-8">
22
<section class="margin-bottom-1">
3-
<div id="career-search-results-filter-remove-all-button" class="margin-y-1">
4-
<a href="javascript:void(0)" class="text-color" id="career-facet-remove-all-filters-button"><strong>Clear All</strong></a>
3+
<div id="career-search-results-filter-remove-all-button-training" class="margin-y-1">
4+
<a href="javascript:void(0)" class="text-color" id="career-facet-remove-all-filters-button-training" style="display: none;"><strong>Clear All</strong></a>
55
</div>
66
</section>
77
<section>

assets/js/training-courses.js

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ $(document).ready(function () {
135135
updateButtonState();
136136
});
137137

138-
$('#per-page-top').change(function () {
138+
$('#per-page-top, #per-page-bot').change(function () {
139139
var length = $(this).val();
140140
table.page.len(length).draw();
141141
updateButtonState();
@@ -144,6 +144,32 @@ $(document).ready(function () {
144144
// Draw the table
145145
table.draw();
146146

147+
function countNonEmptyCollections(obj) {
148+
let count = 0;
149+
Object.keys(obj).forEach(key => {
150+
const value = obj[key];
151+
if (Array.isArray(value) && value.length > 0) {
152+
// Count non-empty arrays
153+
count++;
154+
} else if (value instanceof Set && value.size > 0) {
155+
// Count non-empty sets
156+
count++;
157+
}
158+
});
159+
160+
const selectedGsLevels = $('.gs-level-filter.active').map(function() { return $(this).data('gs-level'); }).get();
161+
const selectedJobSeries = $('.job-series-filter.active').map(function() { return $(this).data('job-series'); }).get();
162+
const selectedCompetencies = $('.competency-filter:checked').map(function() { return $(this).data('competency'); }).get();
163+
const filterCount = selectedGsLevels.length + selectedJobSeries.length + selectedCompetencies.length;
164+
count += filterCount;
165+
166+
if (count == 0) {
167+
$("#career-facet-remove-all-filters-button-training").css('display', 'none');
168+
} else {
169+
$("#career-facet-remove-all-filters-button-training").css('display', 'block');
170+
}
171+
}
172+
147173
function filterTable() {
148174
const selectedGsLevels = $('.gs-level-filter.active').map(function() { return $(this).data('gs-level'); }).get();
149175
const selectedJobSeries = $('.job-series-filter.active').map(function() { return $(this).data('job-series'); }).get();
@@ -163,6 +189,8 @@ $(document).ready(function () {
163189
}).flat().join('|');
164190

165191
table.column(8).search(filterRegex, true, false).draw();
192+
193+
countNonEmptyCollections(activeFilters);
166194
}
167195

168196
$('.gs-level-filter, .job-series-filter').on('click', function() {
@@ -213,7 +241,7 @@ $(document).ready(function () {
213241
activeFilters[columnIndex].clear();
214242
activeFilters[columnIndex].add('all');
215243
}
216-
244+
countNonEmptyCollections(activeFilters);
217245
// Apply the filters
218246
table.draw();
219247
window.history.replaceState({}, "", location.pathname);
@@ -252,6 +280,20 @@ $(document).ready(function () {
252280
}
253281
});
254282

283+
// Event handler for clear all
284+
$("#career-facet-remove-all-filters-button-training").on('click', function () {
285+
activeFilters = {};
286+
$('.filterBtn').removeClass('active');
287+
$('input[type="checkbox"]').prop('checked', false);
288+
$("#career-facet-remove-all-filters-button-training").css('display', 'none');
289+
$('.gs-level-filter').removeClass('active');
290+
$('.job-series-filter').removeClass('active');
291+
updateSelectAllState('job-career-competency-select-training');
292+
updateSelectAllState('general-career-competency-select-training');
293+
filterTable();
294+
$(this).hide();
295+
});
296+
255297
// Event handler for "Select All" / "Deselect All" button
256298
$('#training-download-button-1').on('click', function () {
257299
var $button = $(this);
@@ -303,7 +345,8 @@ $(document).ready(function () {
303345
0: [0, 500],
304346
500: [500, 1000],
305347
1000: [1000, 2000],
306-
2000: [2000, 10000]
348+
2000: [2000, 10000],
349+
10000: [10000, 15000]
307350
};
308351
var isInRange = filterValues.some(filterValue => {
309352
if (rangeMappings[filterValue]) {

0 commit comments

Comments
 (0)