Add search field to scrollable choice fields

This commit is contained in:
Raphael Michel
2023-02-17 16:37:58 +01:00
parent 093eaace43
commit 285150354a
2 changed files with 21 additions and 0 deletions

View File

@@ -456,6 +456,24 @@ var form_handlers = function (el) {
dependency.on("change", update);
});
el.find("div.scrolling-choice:not(.no-search)").each(function () {
if ($(this).find("input[type=text]").length > 0) {
return;
}
var $menu = $("<div>").addClass("choice-options-menu");
var $inp_search = $("<input>").addClass("form-control").attr("type", "text").attr("placeholder", gettext("Search query"));
$menu.append($inp_search);
$(this).prepend($menu);
$inp_search.on("keyup change", function (e) {
var term = $inp_search.val().toLowerCase();
$(this).closest(".scrolling-choice").find("div.radio").each(function () {
$(this).toggleClass("hidden", !$(this).text().toLowerCase().includes(term));
})
})
});
el.find("div.scrolling-multiple-choice").each(function () {
if ($(this).find(".choice-options-all").length > 0) {
return;

View File

@@ -433,6 +433,9 @@ div.scrolling-multiple-choice, div.scrolling-choice {
height: auto;
padding: 2px 6px;
}
.form-control:first-child {
margin: 0;
}
}
}
table td > .checkbox {