Add filters for number of rating votes, and release year
Added support for filtering: * number of rating votes(closes #144) * release year (closes #146)
This commit is contained in:
@@ -141,6 +141,8 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
public List<string> GameMode { get; set; }
|
public List<string> GameMode { get; set; }
|
||||||
public List<string> PlayerPerspective { get; set; }
|
public List<string> PlayerPerspective { get; set; }
|
||||||
public List<string> Theme { get; set; }
|
public List<string> Theme { get; set; }
|
||||||
|
public int MinimumReleaseYear { get; set; } = -1;
|
||||||
|
public int MaximumReleaseYear { get; set; } = -1;
|
||||||
public GameRatingItem GameRating { get; set; } = new GameRatingItem();
|
public GameRatingItem GameRating { get; set; } = new GameRatingItem();
|
||||||
public GameAgeRatingItem GameAgeRating { get; set; } = new GameAgeRatingItem();
|
public GameAgeRatingItem GameAgeRating { get; set; } = new GameAgeRatingItem();
|
||||||
public GameSortingItem Sorting { get; set; } = new GameSortingItem();
|
public GameSortingItem Sorting { get; set; } = new GameSortingItem();
|
||||||
@@ -210,6 +212,20 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
whereClauses.Add(hasSavesTemp);
|
whereClauses.Add(hasSavesTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.MinimumReleaseYear != -1)
|
||||||
|
{
|
||||||
|
string releaseTempMinVal = "FirstReleaseDate >= @minreleasedate";
|
||||||
|
whereParams.Add("minreleasedate", new DateTime(model.MinimumReleaseYear, 1, 1));
|
||||||
|
havingClauses.Add(releaseTempMinVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.MaximumReleaseYear != -1)
|
||||||
|
{
|
||||||
|
string releaseTempMaxVal = "FirstReleaseDate <= @maxreleasedate";
|
||||||
|
whereParams.Add("maxreleasedate", new DateTime(model.MaximumReleaseYear, 12, 31, 23, 59, 59));
|
||||||
|
havingClauses.Add(releaseTempMaxVal);
|
||||||
|
}
|
||||||
|
|
||||||
if (model.GameRating != null)
|
if (model.GameRating != null)
|
||||||
{
|
{
|
||||||
List<string> ratingClauses = new List<string>();
|
List<string> ratingClauses = new List<string>();
|
||||||
|
@@ -11,6 +11,7 @@ function formatFilterPanel(containerElement, result) {
|
|||||||
|
|
||||||
panel.appendChild(buildFilterPanelHeader('filter', 'Filter'));
|
panel.appendChild(buildFilterPanelHeader('filter', 'Filter'));
|
||||||
|
|
||||||
|
// free text search
|
||||||
var containerPanelSearch = document.createElement('div');
|
var containerPanelSearch = document.createElement('div');
|
||||||
containerPanelSearch.className = 'filter_panel_box';
|
containerPanelSearch.className = 'filter_panel_box';
|
||||||
var containerPanelSearchField = document.createElement('input');
|
var containerPanelSearchField = document.createElement('input');
|
||||||
@@ -33,56 +34,31 @@ function formatFilterPanel(containerElement, result) {
|
|||||||
|
|
||||||
panel.appendChild(containerPanelSearch);
|
panel.appendChild(containerPanelSearch);
|
||||||
|
|
||||||
|
// user rating
|
||||||
panel.appendChild(buildFilterPanelHeader('userrating', 'User Rating', true, false));
|
panel.appendChild(buildFilterPanelHeader('userrating', 'User Rating', true, false));
|
||||||
var containerPanelUserRating = document.createElement('div');
|
var containerPanelUserRating = buildFilterRange('userrating', 0, 100);
|
||||||
containerPanelUserRating.id = 'filter_panel_box_userrating';
|
|
||||||
containerPanelUserRating.className = 'filter_panel_box';
|
|
||||||
|
|
||||||
var containerPanelUserRatingCheckBox = document.createElement('input');
|
|
||||||
containerPanelUserRatingCheckBox.id = 'filter_panel_userrating_enabled';
|
|
||||||
containerPanelUserRatingCheckBox.type = 'checkbox';
|
|
||||||
containerPanelUserRatingCheckBox.className = 'filter_panel_item_checkbox';
|
|
||||||
containerPanelUserRatingCheckBox.setAttribute('onclick', 'filter_panel_userrating_enabled_check();');
|
|
||||||
var ratingEnabledCookie = getCookie('filter_panel_userrating_enabled');
|
|
||||||
if (ratingEnabledCookie) {
|
|
||||||
if (ratingEnabledCookie == "true") {
|
|
||||||
containerPanelUserRatingCheckBox.checked = true;
|
|
||||||
} else {
|
|
||||||
containerPanelUserRatingCheckBox.checked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
containerPanelUserRating.appendChild(containerPanelUserRatingCheckBox);
|
|
||||||
|
|
||||||
var containerPanelUserRatingMinField = document.createElement('input');
|
|
||||||
var minRatingCookie = getCookie('filter_panel_userrating_min');
|
|
||||||
if (minRatingCookie) {
|
|
||||||
containerPanelUserRatingMinField.value = minRatingCookie;
|
|
||||||
}
|
|
||||||
containerPanelUserRatingMinField.id = 'filter_panel_userrating_min';
|
|
||||||
containerPanelUserRatingMinField.type = 'number';
|
|
||||||
containerPanelUserRatingMinField.placeholder = '0';
|
|
||||||
containerPanelUserRatingMinField.setAttribute('min', '0');
|
|
||||||
containerPanelUserRatingMinField.setAttribute('max', '100');
|
|
||||||
containerPanelUserRatingMinField.setAttribute('oninput', 'filter_panel_userrating_value();');
|
|
||||||
containerPanelUserRating.appendChild(containerPanelUserRatingMinField);
|
|
||||||
|
|
||||||
var containerPanelUserRatingMaxField = document.createElement('input');
|
|
||||||
var maxRatingCookie = getCookie('filter_panel_userrating_max');
|
|
||||||
if (maxRatingCookie) {
|
|
||||||
containerPanelUserRatingMaxField.value = maxRatingCookie;
|
|
||||||
}
|
|
||||||
containerPanelUserRatingMaxField.id = 'filter_panel_userrating_max';
|
|
||||||
containerPanelUserRatingMaxField.type = 'number';
|
|
||||||
containerPanelUserRatingMaxField.placeholder = '100';
|
|
||||||
containerPanelUserRatingMaxField.setAttribute('min', '0');
|
|
||||||
containerPanelUserRatingMaxField.setAttribute('max', '100');
|
|
||||||
containerPanelUserRatingMaxField.setAttribute('oninput', 'filter_panel_userrating_value();');
|
|
||||||
containerPanelUserRating.appendChild(containerPanelUserRatingMaxField);
|
|
||||||
|
|
||||||
panel.appendChild(containerPanelUserRating);
|
panel.appendChild(containerPanelUserRating);
|
||||||
|
|
||||||
buildFilterPanel(panel, 'settings', 'Settings', [{ "id": "savestatesavailable", "name": "Game has save states avaialble", "gameCount": 0 }], true, true);
|
// user vote count
|
||||||
|
panel.appendChild(buildFilterPanelHeader('uservotes', 'User Votes', true, false));
|
||||||
|
var containerPanelUserVotes = buildFilterRange('uservotes', 0, 1000000);
|
||||||
|
panel.appendChild(containerPanelUserVotes);
|
||||||
|
|
||||||
|
// release year
|
||||||
|
panel.appendChild(buildFilterPanelHeader('releaseyear', 'Release Year', true, false));
|
||||||
|
var containerPanelReleaseYear = buildFilterRange('releaseyear', 1960, (new Date()).getFullYear());
|
||||||
|
panel.appendChild(containerPanelReleaseYear);
|
||||||
|
|
||||||
|
// settings
|
||||||
|
buildFilterPanel(panel, 'settings', 'Settings', [
|
||||||
|
{
|
||||||
|
"id": "savestatesavailable",
|
||||||
|
"name": "Game has save states avaialble",
|
||||||
|
"gameCount": 0
|
||||||
|
}
|
||||||
|
], true, true);
|
||||||
|
|
||||||
|
// server provided filters
|
||||||
if (result.platforms) {
|
if (result.platforms) {
|
||||||
buildFilterPanel(panel, 'platform', 'Platforms', result.platforms, true, true);
|
buildFilterPanel(panel, 'platform', 'Platforms', result.platforms, true, true);
|
||||||
}
|
}
|
||||||
@@ -111,6 +87,7 @@ function formatFilterPanel(containerElement, result) {
|
|||||||
|
|
||||||
targetElement.appendChild(panel);
|
targetElement.appendChild(panel);
|
||||||
|
|
||||||
|
// filter controls
|
||||||
var buttonsDiv = document.createElement('div');
|
var buttonsDiv = document.createElement('div');
|
||||||
buttonsDiv.id = 'games_library_searchbuttons'
|
buttonsDiv.id = 'games_library_searchbuttons'
|
||||||
|
|
||||||
@@ -260,6 +237,59 @@ function buildFilterPanelItem(filterType, itemString, friendlyItemString, tags)
|
|||||||
return filterPanelItem;
|
return filterPanelItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildFilterRange(name, min, max) {
|
||||||
|
var containerPanelUserRating = document.createElement('div');
|
||||||
|
containerPanelUserRating.id = 'filter_panel_box_' + name + '';
|
||||||
|
containerPanelUserRating.className = 'filter_panel_box';
|
||||||
|
|
||||||
|
var containerPanelUserRatingCheckBox = document.createElement('input');
|
||||||
|
containerPanelUserRatingCheckBox.id = 'filter_panel_' + name + '_enabled';
|
||||||
|
containerPanelUserRatingCheckBox.name = 'filter_panel_range_enabled_check';
|
||||||
|
containerPanelUserRatingCheckBox.setAttribute('data-name', name);
|
||||||
|
containerPanelUserRatingCheckBox.type = 'checkbox';
|
||||||
|
containerPanelUserRatingCheckBox.className = 'filter_panel_item_checkbox';
|
||||||
|
containerPanelUserRatingCheckBox.setAttribute('onclick', 'filter_panel_range_enabled_check("' + name + '");');
|
||||||
|
var ratingEnabledCookie = getCookie('filter_panel_' + name + '_enabled');
|
||||||
|
if (ratingEnabledCookie) {
|
||||||
|
if (ratingEnabledCookie == "true") {
|
||||||
|
containerPanelUserRatingCheckBox.checked = true;
|
||||||
|
} else {
|
||||||
|
containerPanelUserRatingCheckBox.checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
containerPanelUserRating.appendChild(containerPanelUserRatingCheckBox);
|
||||||
|
|
||||||
|
var containerPanelUserRatingMinField = document.createElement('input');
|
||||||
|
var minRatingCookie = getCookie('filter_panel_' + name + '_min');
|
||||||
|
if (minRatingCookie) {
|
||||||
|
containerPanelUserRatingMinField.value = minRatingCookie;
|
||||||
|
}
|
||||||
|
containerPanelUserRatingMinField.id = 'filter_panel_' + name + '_min';
|
||||||
|
containerPanelUserRatingMinField.name = 'filter_panel_range_min';
|
||||||
|
containerPanelUserRatingMinField.type = 'number';
|
||||||
|
containerPanelUserRatingMinField.placeholder = min;
|
||||||
|
containerPanelUserRatingMinField.setAttribute('min', min);
|
||||||
|
containerPanelUserRatingMinField.setAttribute('max', max);
|
||||||
|
containerPanelUserRatingMinField.setAttribute('oninput', 'filter_panel_range_value("' + name + '");');
|
||||||
|
containerPanelUserRating.appendChild(containerPanelUserRatingMinField);
|
||||||
|
|
||||||
|
var containerPanelUserRatingMaxField = document.createElement('input');
|
||||||
|
var maxRatingCookie = getCookie('filter_panel_' + name + '_max');
|
||||||
|
if (maxRatingCookie) {
|
||||||
|
containerPanelUserRatingMaxField.value = maxRatingCookie;
|
||||||
|
}
|
||||||
|
containerPanelUserRatingMaxField.id = 'filter_panel_' + name + '_max';
|
||||||
|
containerPanelUserRatingMaxField.name = 'filter_panel_range_max';
|
||||||
|
containerPanelUserRatingMaxField.type = 'number';
|
||||||
|
containerPanelUserRatingMaxField.placeholder = max;
|
||||||
|
containerPanelUserRatingMaxField.setAttribute('min', min);
|
||||||
|
containerPanelUserRatingMaxField.setAttribute('max', max);
|
||||||
|
containerPanelUserRatingMaxField.setAttribute('oninput', 'filter_panel_range_value("' + name + '");');
|
||||||
|
containerPanelUserRating.appendChild(containerPanelUserRatingMaxField);
|
||||||
|
|
||||||
|
return containerPanelUserRating;
|
||||||
|
}
|
||||||
|
|
||||||
var filterExecutor = null;
|
var filterExecutor = null;
|
||||||
function executeFilterDelayed() {
|
function executeFilterDelayed() {
|
||||||
if (filterExecutor) {
|
if (filterExecutor) {
|
||||||
@@ -290,24 +320,24 @@ function buildFilterTag(tags) {
|
|||||||
return boundingDiv;
|
return boundingDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_panel_userrating_enabled_check() {
|
function filter_panel_range_enabled_check(name) {
|
||||||
var ratingCheck = document.getElementById('filter_panel_userrating_enabled');
|
var ratingCheck = document.getElementById('filter_panel_' + name + '_enabled');
|
||||||
var minRatingValue = document.getElementById('filter_panel_userrating_min');
|
var minRatingValue = document.getElementById('filter_panel_' + name + '_min');
|
||||||
var maxRatingValue = document.getElementById('filter_panel_userrating_max');
|
var maxRatingValue = document.getElementById('filter_panel_' + name + '_max');
|
||||||
|
|
||||||
if (ratingCheck.checked == false) {
|
if (ratingCheck.checked == false) {
|
||||||
minRatingValue.value = '';
|
minRatingValue.value = '';
|
||||||
maxRatingValue.value = '';
|
maxRatingValue.value = '';
|
||||||
} else {
|
} else {
|
||||||
minRatingValue.value = 0;
|
minRatingValue.value = minRatingValue.min;
|
||||||
maxRatingValue.value = 100;
|
maxRatingValue.value = maxRatingValue.max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_panel_userrating_value() {
|
function filter_panel_range_value(name) {
|
||||||
var ratingCheck = document.getElementById('filter_panel_userrating_enabled');
|
var ratingCheck = document.getElementById('filter_panel_' + name + '_enabled');
|
||||||
var minRatingValue = document.getElementById('filter_panel_userrating_min');
|
var minRatingValue = document.getElementById('filter_panel_' + name + '_min');
|
||||||
var maxRatingValue = document.getElementById('filter_panel_userrating_max');
|
var maxRatingValue = document.getElementById('filter_panel_' + name + '_max');
|
||||||
|
|
||||||
if (minRatingValue.value || maxRatingValue.value) {
|
if (minRatingValue.value || maxRatingValue.value) {
|
||||||
ratingCheck.checked = true;
|
ratingCheck.checked = true;
|
||||||
@@ -327,7 +357,10 @@ function resetFilters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fire checkbox specific scripts
|
// fire checkbox specific scripts
|
||||||
filter_panel_userrating_enabled_check();
|
var rangeCheckboxes = document.getElementsByName('filter_panel_range_enabled_check');
|
||||||
|
for (var i = 0; i < rangeCheckboxes.length; i++) {
|
||||||
|
filter_panel_range_enabled_check(rangeCheckboxes[i].getAttribute('data-name'));
|
||||||
|
}
|
||||||
|
|
||||||
executeFilter1_1();
|
executeFilter1_1();
|
||||||
}
|
}
|
||||||
@@ -399,6 +432,78 @@ function executeFilter1_1(pageNumber, pageSize) {
|
|||||||
setCookie("filter_panel_userrating_enabled", true);
|
setCookie("filter_panel_userrating_enabled", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// user votes
|
||||||
|
var userVotesEnabled = document.getElementById('filter_panel_uservotes_enabled');
|
||||||
|
|
||||||
|
var minUserVotes = -1;
|
||||||
|
var minUserVotesInput = document.getElementById('filter_panel_uservotes_min');
|
||||||
|
if (minUserVotesInput.value) {
|
||||||
|
minUserVotes = minUserVotesInput.value;
|
||||||
|
userVotesEnabled.checked = true;
|
||||||
|
}
|
||||||
|
setCookie(minUserVotesInput.id, minUserVotesInput.value);
|
||||||
|
|
||||||
|
var maxUserVotes = -1;
|
||||||
|
var maxUserVotesInput = document.getElementById('filter_panel_uservotes_max');
|
||||||
|
if (maxUserVotesInput.value) {
|
||||||
|
maxUserVotes = maxUserVotesInput.value;
|
||||||
|
userVotesEnabled.checked = true;
|
||||||
|
}
|
||||||
|
setCookie(maxUserVotesInput.id, maxUserVotesInput.value);
|
||||||
|
|
||||||
|
if (minUserVotes == -1 && maxUserVotes == -1) {
|
||||||
|
userVotesEnabled.checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userVotesEnabled.checked == false) {
|
||||||
|
setCookie("filter_panel_uservotes_enabled", false);
|
||||||
|
|
||||||
|
minUserVotes = -1;
|
||||||
|
minUserVotesInput.value = "";
|
||||||
|
setCookie(minUserVotesInput.id, minUserVotesInput.value);
|
||||||
|
maxUserVotes = -1;
|
||||||
|
maxUserVotesInput.value = "";
|
||||||
|
setCookie(maxUserVotesInput.id, maxUserVotesInput.value);
|
||||||
|
} else {
|
||||||
|
setCookie("filter_panel_uservotes_enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// release year
|
||||||
|
var releaseYearEnabled = document.getElementById('filter_panel_releaseyear_enabled');
|
||||||
|
|
||||||
|
var minReleaseYear = -1;
|
||||||
|
var minReleaseYearInput = document.getElementById('filter_panel_releaseyear_min');
|
||||||
|
if (minReleaseYearInput.value) {
|
||||||
|
minReleaseYear = minReleaseYearInput.value;
|
||||||
|
releaseYearEnabled.checked = true;
|
||||||
|
}
|
||||||
|
setCookie(minReleaseYearInput.id, minReleaseYearInput.value);
|
||||||
|
|
||||||
|
var maxReleaseYear = -1;
|
||||||
|
var maxReleaseYearInput = document.getElementById('filter_panel_releaseyear_max');
|
||||||
|
if (maxReleaseYearInput.value) {
|
||||||
|
maxReleaseYear = maxReleaseYearInput.value;
|
||||||
|
releaseYearEnabled.checked = true;
|
||||||
|
}
|
||||||
|
setCookie(maxReleaseYearInput.id, maxReleaseYearInput.value);
|
||||||
|
|
||||||
|
if (minReleaseYear == -1 && maxReleaseYear == -1) {
|
||||||
|
releaseYearEnabled.checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseYearEnabled.checked == false) {
|
||||||
|
setCookie("filter_panel_releaseyear_enabled", false);
|
||||||
|
|
||||||
|
minReleaseYear = -1;
|
||||||
|
minReleaseYearInput.value = "";
|
||||||
|
setCookie(minReleaseYearInput.id, minReleaseYearInput.value);
|
||||||
|
maxReleaseYear = -1;
|
||||||
|
maxReleaseYearInput.value = "";
|
||||||
|
setCookie(maxReleaseYearInput.id, maxReleaseYearInput.value);
|
||||||
|
} else {
|
||||||
|
setCookie("filter_panel_releaseyear_enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
// save cookies for settings
|
// save cookies for settings
|
||||||
GetFilterQuery1_1('settings');
|
GetFilterQuery1_1('settings');
|
||||||
|
|
||||||
@@ -417,11 +522,13 @@ function executeFilter1_1(pageNumber, pageSize) {
|
|||||||
"GameMode": GetFilterQuery1_1('gamemode'),
|
"GameMode": GetFilterQuery1_1('gamemode'),
|
||||||
"PlayerPerspective": GetFilterQuery1_1('playerperspective'),
|
"PlayerPerspective": GetFilterQuery1_1('playerperspective'),
|
||||||
"Theme": GetFilterQuery1_1('theme'),
|
"Theme": GetFilterQuery1_1('theme'),
|
||||||
|
"MinimumReleaseYear": minReleaseYear,
|
||||||
|
"MaximumReleaseYear": maxReleaseYear,
|
||||||
"GameRating": {
|
"GameRating": {
|
||||||
"MinimumRating": minUserRating,
|
"MinimumRating": minUserRating,
|
||||||
"MinimumRatingCount": -1,
|
"MinimumRatingCount": minUserVotes,
|
||||||
"MaximumRating": maxUserRating,
|
"MaximumRating": maxUserRating,
|
||||||
"MaximumRatingCount": -1,
|
"MaximumRatingCount": maxUserVotes,
|
||||||
"IncludeUnrated": !userRatingEnabled
|
"IncludeUnrated": !userRatingEnabled
|
||||||
},
|
},
|
||||||
"GameAgeRating": {
|
"GameAgeRating": {
|
||||||
|
@@ -300,12 +300,12 @@ input[id='filter_panel_search'] {
|
|||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[id='filter_panel_userrating_min'] {
|
input[name='filter_panel_range_min'] {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[id='filter_panel_userrating_max'] {
|
input[name='filter_panel_range_max'] {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user