From d77b96a40fabda13fa2bff9f8361de1f9406c01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= <cuu508@gmail.com> Date: Mon, 30 Sep 2024 10:29:30 +0300 Subject: [PATCH] Update the uuid/slug switching links to not lose currently selected tags --- static/js/checks.js | 11 +++++++++++ templates/front/checks_table.html | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/static/js/checks.js b/static/js/checks.js index 2db2adb6..a637d8d2 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -140,6 +140,17 @@ $(function () { // User changes the search string: apply filters $("#search").keyup(applyFilters); + function switchUrlFormat(format) { + var url = new URL(window.location.href); + url.searchParams.delete("urls"); + url.searchParams.append("urls", format); + window.location.href = url.toString(); + return false; + } + + $("#to-uuid").click(e => switchUrlFormat("uuid")); + $("#to-slug").click(e => switchUrlFormat("slug")); + $(".show-log").click(function(e) { var code = $(this).closest("tr.checks-row").attr("id"); var url = base + "/checks/" + code + "/details/"; diff --git a/templates/front/checks_table.html b/templates/front/checks_table.html index d9e1b544..3255daa5 100644 --- a/templates/front/checks_table.html +++ b/templates/front/checks_table.html @@ -27,8 +27,8 @@ <span class="visible-md-inline">{{ project.show_slugs|yesno:"Key/Slug,UUID" }}</span> {% if rw %} <small id="url-style-switcher"> - <a href="?urls=uuid" {% if not project.show_slugs %}class="active"{% endif %}>uuid</a> - <a href="?urls=slug" {% if project.show_slugs %}class="active"{% endif %}>slug</a> + <a id="to-uuid" href="?urls=uuid" {% if not project.show_slugs %}class="active"{% endif %}>uuid</a> + <a id="to-slug" href="?urls=slug" {% if project.show_slugs %}class="active"{% endif %}>slug</a> </small> {% endif %} </th>