mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-09-30 05:13:32 +02:00
Better Food search
This commit is contained in:
@@ -34,6 +34,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-check">
|
||||
<label for="stock_only" class="form-check-label">
|
||||
<input id="stock_only" name="stock_only" type="checkbox" class="checkboxinput form-check-input" checked>
|
||||
{% trans "Filter with only food in stock" %}
|
||||
</label>
|
||||
</div>
|
||||
<input id="searchbar" type="text" class="form-control"
|
||||
placeholder="{% trans "Search by attribute such as name..." %}">
|
||||
</div>
|
||||
@@ -114,7 +120,26 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
let old_pattern = null;
|
||||
let searchbar_obj = $("#searchbar");
|
||||
let stock_only_obj = $("#stock_only");
|
||||
|
||||
function reloadTable() {
|
||||
let pattern = searchbar_obj.val();
|
||||
|
||||
$("#dynamic-table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + (
|
||||
stock_only_obj.is(':checked') ? "" : "&stock=1") + " #dynamic-table");
|
||||
}
|
||||
|
||||
searchbar_obj.keyup(reloadTable);
|
||||
stock_only_obj.change(reloadTable);
|
||||
|
||||
$(document).on("click", ".table-row", function () {
|
||||
window.document.location = $(this).data("href");
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('goButton').addEventListener('click', function(event) {
|
||||
|
Reference in New Issue
Block a user