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

AAC Additional Filters - Course Type and Sector #851

Open
wants to merge 10 commits into
base: AD-168132
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$(document).ready(function () {

showHideSectorsFilter();

$(".find-a-course-page:first").each(function () {
var urlParams = new URLSearchParams(window.location.search);
var distance = urlParams.get('D');
Expand Down Expand Up @@ -60,13 +63,25 @@ $(document).ready(function () {
return false;
});


$('.find-a-course-page #courseType input[type=checkbox]').change(function (e) {
showHideSectorsFilter();
makeAjaxCall(getParams(true));
e.preventDefault();
return false;
});

$('.find-a-course-page #sectors input[type=checkbox]').change(function (e) {
makeAjaxCall(getParams(true));
e.preventDefault();
return false;
});

$('.find-a-course-page #learningMethod input[type=checkbox]').change(function (e) {
makeAjaxCall(getParams(true));
e.preventDefault();
return false;
});

$('#courseHours input[type=checkbox]').change(function (e) {
makeAjaxCall(getParams(true));
e.preventDefault();
Expand Down Expand Up @@ -104,11 +119,21 @@ function addCommas(nStr) {
}

function clearFilters(paramValues) {
paramValues.CourseType = '';
paramValues.Sectors = '';
paramValues.LearningMethod = '';
paramValues.CourseHours = '';
paramValues.CourseStudyTime = '';
paramValues.QualificationLevels = '';

$('.find-a-course-page #courseType input[type=checkbox]').each(function () {
$(this).prop('checked', false)
});

$('.find-a-course-page #sectors input[type=checkbox]').each(function () {
$(this).prop('checked', false)
});

$('.find-a-course-page #learningMethod input[type=checkbox]').each(function () {
$(this).prop('checked', false)
});
Expand Down Expand Up @@ -161,6 +186,21 @@ function showHideDistanceInput(show, orderBy) {
}
}

function showHideSectorsFilter() {
var isChecked = $(document.getElementById("SideBar.CourseType.SelectedIds[5]")).is(":checked");

if (isChecked === true) {
$("#sectors-block").show();
}
else {
$("#sectors-block").hide();

$('.find-a-course-page #sectors input[type=checkbox]').each(function () {
$(this).prop('checked', false)
});
}
}

function showHideClearFilters(show, searchTerm, town, coordinates) {
if (show === true) {
var D = 0;
Expand All @@ -184,6 +224,8 @@ function showHideClearFilters(show, searchTerm, town, coordinates) {
function anyFiltersSelected(paramValues) {
if (paramValues.Town != '' ||
paramValues.StartDate != 'Anytime' ||
paramValues.CourseType.length > 1 ||
paramValues.Sectors.length > 1 ||
paramValues.LearningMethod.length > 1 ||
paramValues.CourseHours.length > 1 ||
paramValues.CourseStudyTime.length > 1 ||
Expand Down Expand Up @@ -224,7 +266,7 @@ function makeAjaxCall(paramValues) {
$('#fac-result-list').html(replacementMarkup);
$('.fac-result-count').html("");
$('.fac-result-count').html(addCommas(resultCount));
(resultCount > 0) ? $('.no-count-block').show() : $('.no-count-block').hide();
(resultCount > 0) ? $('.no-count-block').show() : $('.no-count-block').hide();

showHideClearFilters(anyFiltersSelected(paramValues), paramValues.SearchTerm, paramValues.Town, paramValues.Coordinates);
paramValues.D = showDistanceSelector === true ? 1 : 0;
Expand Down Expand Up @@ -265,6 +307,8 @@ function getUpdatedUrl(paramValues) {
"town=" + paramValues.Town + "&" +
"orderByValue=" + paramValues.OrderByValue + "&" +
"startDate=" + paramValues.StartDate + "&" +
"courseType=" + paramValues.CourseType + "&" +
"sectors=" + paramValues.Sectors + "&" +
"learningMethod=" + paramValues.LearningMethod + "&" +
"courseHours=" + paramValues.CourseHours + "&" +
"courseStudyTime=" + paramValues.CourseStudyTime + "&" +
Expand Down Expand Up @@ -295,11 +339,22 @@ function getParams(sortByLocation = false) {
}
var page = $('.find-a-course-page #RequestPage').val();
var startDate = $('.find-a-course-page #startdate-select').val();
var courseType = [];
var sectors = [];
var learningMethod = [];
var courseHours = [];
var courseStudyTime = [];
var qualificationLevels = [];
var coordinates = $('.find-a-course-page #coordinates').val();

$('.find-a-course-page #courseType input[type=checkbox]:checked').each(function () {
courseType.push(this.value);
});

$('.find-a-course-page #sectors input[type=checkbox]:checked').each(function () {
sectors.push(this.value);
});

$('.find-a-course-page #learningMethod input[type=checkbox]:checked').each(function () {
learningMethod.push(this.value);
});
Expand All @@ -322,6 +377,8 @@ function getParams(sortByLocation = false) {
Town: town,
OrderByValue: (orderByValue == null) ? 'Relevance' : orderByValue,
StartDate: (startDate == null) ? 'Anytime' : startDate,
CourseType: courseType.toString(),
Sectors: sectors.toString(),
LearningMethod: learningMethod.toString(),
CourseHours: courseHours.toString(),
CourseStudyTime: courseStudyTime.toString(),
Expand Down