Fix issue with "exist" in photos that was not filtering

This commit is contained in:
Théo Marchal 2021-03-05 01:18:52 +01:00
parent 5b79f924cb
commit 44a5f52e94
2 changed files with 21 additions and 19 deletions

View File

@ -213,13 +213,6 @@ jQuery(document).ready(function($)
if (p == "90") for (i = 90; i <= 99; i++) selectedDimensions.push(i);
if (p == "100") for (i = 100; i <= 109; i++) selectedDimensions.push(i);
}
// special case of a multi selector
if (selectedPhotos.includes("exist"))
{
selectedPhotos.push("bad");
selectedPhotos.push("ok");
selectedPhotos.push("good");
}
return {"photos": selectedPhotos, "years": selectedYears, "months": selectedMonths, "genres": selectedGenres, "themes": selectedThemes,
"places": selectedPlaces, "tags": selectedTags, "dimensions": selectedDimensions, "helps": selectedHelps};
}
@ -291,9 +284,25 @@ jQuery(document).ready(function($)
$('input[name="' + name + '"]').change(function()
{
if (this.checked)
{
if (this.id == "exist") // photos special case
{
param.push("bad");
param.push("ok");
param.push("good");
}
param.push(this.id);
}
else
{
if (this.id == "exist") // photos special case
{
removeFromArray(param, "bad");
removeFromArray(param, "ok");
removeFromArray(param, "good");
}
removeFromArray(param, this.id);
}
selectedOptions = gatherURLdata();
data = originalData;

View File

@ -96,11 +96,11 @@ function generateMenu(availableOptions)
$(".box.help .item-cont .generated").append(html);
}
$(".box.places select").append('<option value="">Aucun</option');
$(".box.places select").append('<option value="">Aucun filtre</option');
for (place of availableOptions.places)
$(".box.places select").append('<option value="' + place + '">' + place + '</option');
$(".box.tags select").append('<option value="">Aucun</option');
$(".box.tags select").append('<option value="">Aucun filtre</option');
for (tag of availableOptions.tags)
$(".box.tags select").append('<option value="' + tag + '">' + tag + '</option');
}
@ -119,14 +119,7 @@ function updateMenu(availableOptions)
// special case for "exist" in photos
if ($(this).prop("value") == "exist")
{
if (array.includes("none") && ! (array.includes("bad") || array.includes("ok") || array.includes("good")))
$(this).parent().addClass("filter");
else
$(this).parent().removeClass("filter");
if (array.length == 0)
$(this).parent().addClass("filter");
}
$(this).parent().removeClass("filter");
}
else
$(this).parent().removeClass("filter");
@ -188,7 +181,7 @@ function URLGeneration(availableOptions)
for (a of param)
{
html = '<span><span class="inline">&#x203B;&nbsp;</span><select name="' + name + '">';
html += '<option value="">Aucun</option>';
html += '<option value="">Aucun filtre</option>';
for (i of names)
{
if (i == a)
@ -202,7 +195,7 @@ function URLGeneration(availableOptions)
if (!param.includes("all") && param.length >= 1 && name != "place")
{
html = '<span><span class="inline">&#x203B;&nbsp;</span><select name="' + name + '">';
html += '<option value="">Aucun</option>';
html += '<option value="">Aucun filtre</option>';
for (i of names)
html += '<option value="' + i + '">' + i + '</option>';
html += '</select></span>';