Fix tags handling that was broken with filter
This commit is contained in:
parent
ab5710e69e
commit
f37a2fde6e
@ -235,10 +235,56 @@ jQuery(document).ready(function($)
|
|||||||
{
|
{
|
||||||
generateMenu(originalAvailableOptions);
|
generateMenu(originalAvailableOptions);
|
||||||
availableOptions = gatherData();
|
availableOptions = gatherData();
|
||||||
updateMenu(availableOptions);
|
|
||||||
|
|
||||||
userActionHandle(availableOptions);
|
userActionHandle(availableOptions);
|
||||||
URLGeneration(availableOptions);
|
URLGeneration(originalAvailableOptions);
|
||||||
|
updateMenu(availableOptions);
|
||||||
|
|
||||||
|
// handle tags
|
||||||
|
function handleTags()
|
||||||
|
{
|
||||||
|
$('.box.tags .item-cont').delegate('select[name="tag"]', 'change', function()
|
||||||
|
{
|
||||||
|
paramTag = []; // collect all tags from all dropdowns
|
||||||
|
$('.box.tags .item-cont select[name="tag"]').each(function()
|
||||||
|
{
|
||||||
|
if (paramTag.indexOf(this.value) === -1 && this.value != "")
|
||||||
|
paramTag.push(this.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.value != "")
|
||||||
|
{
|
||||||
|
createNewElem = true; // if we modify an existing element to a value, we don't delete it
|
||||||
|
$('.box.tags select').each(function()
|
||||||
|
{
|
||||||
|
if ($(this).val() == "")
|
||||||
|
createNewElem = false;
|
||||||
|
});
|
||||||
|
if (createNewElem)
|
||||||
|
{
|
||||||
|
html = '<span><span class="inline">※ </span><select name="tag">';
|
||||||
|
html += '<option value="">Aucun</option>';
|
||||||
|
for (a of originalAvailableOptions.tags)
|
||||||
|
html += '<option value="' + a + '">' + a + '</option>';
|
||||||
|
html += '</select></span>';
|
||||||
|
$(".box.tags .item-cont").append(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if the element has no value, we delete it
|
||||||
|
$(this).parent().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedOptions = gatherURLdata();
|
||||||
|
data = originalData;
|
||||||
|
filterData(selectedOptions);
|
||||||
|
availableOptions = [];
|
||||||
|
availableOptions = gatherData();
|
||||||
|
updateMenu(availableOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handleTags();
|
||||||
|
|
||||||
function visualFilterCheckboxItem(name, param)
|
function visualFilterCheckboxItem(name, param)
|
||||||
{
|
{
|
||||||
@ -285,7 +331,6 @@ jQuery(document).ready(function($)
|
|||||||
visualFilterCheckboxItem("help", paramHelp);
|
visualFilterCheckboxItem("help", paramHelp);
|
||||||
|
|
||||||
visualFilterListItem("place", paramPlace);
|
visualFilterListItem("place", paramPlace);
|
||||||
visualFilterListItem("tag", paramTag);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
|
@ -199,7 +199,7 @@ function URLGeneration(availableOptions)
|
|||||||
html += '</select></span>';
|
html += '</select></span>';
|
||||||
$(selector + ' .item-cont').append(html);
|
$(selector + ' .item-cont').append(html);
|
||||||
}
|
}
|
||||||
if (!param.includes("all") && param.length >= 1)
|
if (!param.includes("all") && param.length >= 1 && name != "place")
|
||||||
{
|
{
|
||||||
html = '<span><span class="inline">※ </span><select name="' + name + '">';
|
html = '<span><span class="inline">※ </span><select name="' + name + '">';
|
||||||
html += '<option value="">Aucun</option>';
|
html += '<option value="">Aucun</option>';
|
||||||
@ -253,37 +253,6 @@ function userActionHandle(availableOptions)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// for tags
|
|
||||||
function listOptionSelected(selector, name, names)
|
|
||||||
{
|
|
||||||
$(selector).on('change', 'select[name="' + name + '"]', function()
|
|
||||||
{
|
|
||||||
if (this.value != "")
|
|
||||||
{
|
|
||||||
createNewElem = true; // if we modify an existing element to a value, we don't delete it
|
|
||||||
$(selector + ' select').each(function()
|
|
||||||
{
|
|
||||||
if ($(this).val() == "")
|
|
||||||
createNewElem = false;
|
|
||||||
});
|
|
||||||
if (createNewElem)
|
|
||||||
{
|
|
||||||
html = '<span><span class="inline">※ </span><select name="' + name + '">';
|
|
||||||
html += '<option value="">Aucun</option>';
|
|
||||||
for (a of names)
|
|
||||||
html += '<option value="' + a + '">' + a + '</option>';
|
|
||||||
html += '</select></span>';
|
|
||||||
$(selector + " .item-cont").append(html);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if the element has no value, we delete it
|
|
||||||
$(this).parent().remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$("input").prop("checked", false); // by default, uncheck all options
|
$("input").prop("checked", false); // by default, uncheck all options
|
||||||
allCheckBoxSelected("years", "year");
|
allCheckBoxSelected("years", "year");
|
||||||
allCheckBoxSelected("months", "month");
|
allCheckBoxSelected("months", "month");
|
||||||
@ -294,7 +263,6 @@ function userActionHandle(availableOptions)
|
|||||||
allCheckBoxSelected("tags", "tag");
|
allCheckBoxSelected("tags", "tag");
|
||||||
allCheckBoxSelected("photos", "photo");
|
allCheckBoxSelected("photos", "photo");
|
||||||
allCheckBoxSelected("helps", "help");
|
allCheckBoxSelected("helps", "help");
|
||||||
listOptionSelected(".box.tags", "tag", availableOptions.tags);
|
|
||||||
|
|
||||||
// special case for photos with "exist"
|
// special case for photos with "exist"
|
||||||
$('input[id="exist"]').click(function()
|
$('input[id="exist"]').click(function()
|
||||||
|
Loading…
Reference in New Issue
Block a user