From c1d9e3c6d17c99fed3b89344adf237012a8477ec Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 3 Oct 2025 10:26:26 +0200 Subject: 💄 UI: improve criteria panel layout - add shortcuts for search, sheet opening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/static/js/ishtar.js | 64 ++++++++++++++++++++++ .../templates/blocks/bs_form_snippet.html | 17 ++++-- ishtar_common/templates/ishtar/sheet.html | 6 +- ishtar_common/templates/widgets/search_input.html | 9 +-- ishtar_common/views_item.py | 11 ++-- 5 files changed, 90 insertions(+), 17 deletions(-) diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index cf7009ef9..f091aed85 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -1017,6 +1017,7 @@ function register_advanced_search(){ if (key === "Enter") { $(".advanced-search-valid").click(); e.stopPropagation(); + $("#search-input-filter").focus(); return false; } }); @@ -1042,6 +1043,69 @@ function register_advanced_search(){ update_search_field(); $("#search-input-filter").focus(); }); + // generic shortcuts + document.addEventListener('keydown', function(event) { + if (event.altKey) { + if (event.code === 'KeyC') { + $("#criteria-button").click(); + } + else if (event.code === 'KeyL') { + $("#clear-search-button").click(); + $("#id_search_vector").focus(); + } + else if (event.code === 'KeyP') { + $("#pin-search-button").click(); + $("#id_search_vector").focus(); + } + else if (event.code === 'KeyS') { + $("#id_search_vector").focus(); + } + } + else if (event.ctrlKey) { + if (event.code === 'ArrowLeft' && last_window) { + $("#" + last_window + " .previous_page").click() + } + else if (event.code === 'ArrowRight' && last_window) { + $("#" + last_window + " .next_page").click() + } + else if (event.code === 'Digit1') { + $(".form.search .display_details")[0].click(); + } + else if (event.code === 'Digit2') { + $(".form.search .display_details")[1].click(); + } + else if (event.code === 'Digit3') { + $(".form.search .display_details")[2].click(); + } + else if (event.code === 'Digit4') { + $(".form.search .display_details")[3].click(); + } + else if (event.code === 'Digit5') { + $(".form.search .display_details")[4].click(); + } + else if (event.code === 'Digit6') { + $(".form.search .display_details")[5].click(); + } + else if (event.code === 'Digit7') { + $(".form.search .display_details")[6].click(); + } + else if (event.code === 'Digit8') { + $(".form.search .display_details")[7].click(); + } + else if (event.code === 'Digit9') { + $(".form.search .display_details")[8].click(); + } + } + else if (event.key == "Escape") { + if (last_window) { + hide_window(last_window); + last_window = ""; + } else { + hide_window($(".card.sheet").last().attr('id')); + } + $(".card.sheet").last().get(0).scrollIntoView({behavior: 'smooth'}); + } + }); } diff --git a/ishtar_common/templates/blocks/bs_form_snippet.html b/ishtar_common/templates/blocks/bs_form_snippet.html index 509883e80..4cb32a535 100644 --- a/ishtar_common/templates/blocks/bs_form_snippet.html +++ b/ishtar_common/templates/blocks/bs_form_snippet.html @@ -55,7 +55,14 @@ -
+
+
+
+ +
+
@@ -108,14 +115,12 @@

-

diff --git a/ishtar_common/templates/ishtar/sheet.html b/ishtar_common/templates/ishtar/sheet.html index a32ee2862..6dbe7aff0 100644 --- a/ishtar_common/templates/ishtar/sheet.html +++ b/ishtar_common/templates/ishtar/sheet.html @@ -41,13 +41,13 @@
+ title="{% trans 'Close [Esc]' %}"> diff --git a/ishtar_common/templates/widgets/search_input.html b/ishtar_common/templates/widgets/search_input.html index d8ad26d8d..14249f4e8 100644 --- a/ishtar_common/templates/widgets/search_input.html +++ b/ishtar_common/templates/widgets/search_input.html @@ -3,18 +3,19 @@ {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} /> + title="{% trans 'Clear the search [Alt+L]' %}"> @@ -22,7 +23,7 @@ + title="{% trans 'Pin the current search [Alt+P]' %}"> " + "onclick='load_window(\"{}\")'{}>" '' ) link_ext_template = '{}' @@ -3073,13 +3073,13 @@ def get_item( curl = reverse("show-" + default_name, args=[999999, ""]) if not curl.endswith("/"): curl += "/" - lnk = link_template.format(curl) + lnk = link_template.format(curl, "") lnk = lnk.replace("999999", "") if not has_locks: lnk = lnk.replace("", "") data = json.dumps(_format_geojson(datas, lnk, display_polygon)) return HttpResponse(data, content_type="application/json") - for data in datas: + for idx_data, data in enumerate(datas): res = { "id": data[0], } @@ -3102,7 +3102,10 @@ def get_item( if not curl.endswith("/"): curl += "/" lnk_template = link_template - lnk = lnk_template.format(curl) + lnk_title = "" + if idx_data < 9: + lnk_title = f' title="[Ctrl+{idx_data+1}]"' + lnk = lnk_template.format(curl, lnk_title) if has_locks and data[-2]: if data[-1] == current_user_id: lnk = lnk.replace("", own_lock) -- cgit v1.2.3