If user selects has_albums=no, disable the yield_albums option.

This commit is contained in:
voussoir 2022-10-27 21:16:32 -07:00
parent 6cc0246764
commit f2d5853b29
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -297,7 +297,7 @@
</option>
{% endfor %}
</select>
<select name="has_albums" class="basic_param">
<select name="has_albums" class="basic_param" onchange="return disable_yield_albums_if_not_has_albums();">
<option value="" {{"selected" if search_kwargs['has_albums']==None else ""}}>Album or no album</option>
<option value="yes" {{"selected" if search_kwargs['has_albums']==True else ""}}>Photos contained in albums</option>
<option value="no" {{"selected" if search_kwargs['has_albums']==False else ""}}>Photos not in albums</option>
@ -518,6 +518,21 @@ function orderby_remove_hook(button)
}
}
function disable_yield_albums_if_not_has_albums()
{
const has_albums = document.querySelector("select[name='has_albums']");
const yield_albums = document.querySelector("select[name='yield_albums']");
if (has_albums.value == "no")
{
yield_albums.value = "no";
yield_albums.disabled = true;
}
else
{
yield_albums.disabled = false;
}
}
function orderby_hide_direction_hook(event)
{
if (event.target.value == "random")
@ -738,6 +753,7 @@ common.bind_box_to_button(input_expression, search_go_button);
function on_pageload()
{
photo_clipboard.register_hotkeys();
disable_yield_albums_if_not_has_albums();
}
document.addEventListener("DOMContentLoaded", on_pageload);
</script>