the default filter and sort URLs are now less verbose - fixes #568 default tip

Thu, 09 Oct 2025 11:49:39 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 09 Oct 2025 11:49:39 +0200
changeset 401
bf220daedabe
parent 400
d23b29972dca

the default filter and sort URLs are now less verbose - fixes #568

src/main/kotlin/de/uapcore/lightpit/Constants.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog-de.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/issue-filter.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/sort-box.jspf file | annotate | diff | comparison | revisions
src/main/webapp/issue-overview.js file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/Constants.kt	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/Constants.kt	Thu Oct 09 11:49:39 2025 +0200
@@ -29,7 +29,7 @@
     /**
      * A data in yyyy-mm-dd format to identify the release.
      */
-    const val VERSION_DATE = "2025-10-06"
+    const val VERSION_DATE = "2025-10-09"
 
     /**
      * The path where the JSP files reside.
--- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Thu Oct 09 11:49:39 2025 +0200
@@ -228,15 +228,22 @@
     val category: List<IssueCategory> = evalEnum(http, "c")
     val assignee: List<Int> = evalInts(http, "u")
 
-    val sortPrimary: IssueSorter.Criteria = evalSort(http, "primary", IssueSorter.Criteria(IssueSorter.Field.DONE))
-    val sortSecondary: IssueSorter.Criteria = evalSort(http, "secondary", IssueSorter.Criteria(IssueSorter.Field.ETA))
-    val sortTertiary: IssueSorter.Criteria = evalSort(http, "tertiary", IssueSorter.Criteria(IssueSorter.Field.UPDATED, false))
+    val defaultSortPrimary: IssueSorter.Criteria = IssueSorter.Criteria(IssueSorter.Field.DONE)
+    val defaultSortSecondary: IssueSorter.Criteria = IssueSorter.Criteria(IssueSorter.Field.ETA)
+    val defaultSortTertiary: IssueSorter.Criteria = IssueSorter.Criteria(IssueSorter.Field.UPDATED, false)
+    val sortPrimary: IssueSorter.Criteria = evalSort(http, "primary", defaultSortPrimary)
+    val sortSecondary: IssueSorter.Criteria = evalSort(http, "secondary", defaultSortSecondary)
+    val sortTertiary: IssueSorter.Criteria = evalSort(http, "tertiary", defaultSortTertiary)
 
     val anyListFilterActive = status.isNotEmpty() || category.isNotEmpty() || assignee.isNotEmpty()
 
     fun containsAssignee(user: User?): Boolean = assignee.contains(user?.id?:-1)
 
     private fun evalSort(http: HttpRequest, prio: String, defaultValue: IssueSorter.Criteria): IssueSorter.Criteria {
+        if (http.param("sort").equals("default")) {
+            http.session.removeAttribute("sort_$prio")
+            return defaultValue
+        }
         val param = http.param("sort_$prio")
         if (param != null) {
             http.session.removeAttribute("sort_$prio")
--- a/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Thu Oct 09 11:49:39 2025 +0200
@@ -38,6 +38,7 @@
     <li>Die Vorschläge in den Suchfeldern für Vorgänge sind nun absteigend nach Vorgangsnummer sortiert.</li>
     <li>Die Standardkategorie für neue Vorgänge in veröffentlichten Versionen ist nun "Fehler" anstelle von "Feature".</li>
     <li>Die Links zu den Varianten in der Vorgangsansicht wechseln nun lediglich die geöffnete Variante, anstatt zur Vorgangsliste zurückzukehren.</li>
+    <li>Die erzeugten URLs für Filter und Sortierung sind nun deutlich schlanker (diese Änderung ist komplett abwärtskompatibel).</li>
     <li>Positionen der Schaltflächen unterhalb der Vorgangsfilter getauscht, um Konsistent mit allen anderen Schaltflächen in der Anwendung zu sein.</li>
     <li>Fehlerhafte Delta-Anzeige in RSS-Feeds behoben.</li>
     <li>Ungefiltertes HTML aus Vorgangsbeschreibungen in RSS-Feeds behoben.</li>
--- a/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Thu Oct 09 11:49:39 2025 +0200
@@ -38,6 +38,7 @@
     <li>Change that issues suggested by the search boxes are now sorted by ID in descending order.</li>
     <li>Change that the default category for new issues in released versions is Bug instead of Feature.</li>
     <li>Change that the variant links in the issue view now stay within the issue and only switch the opened variant.</li>
+    <li>Change the default filter and sort URLs to be less verbose (fully backwards compatible).</li>
     <li>Switch position of Apply and Remove buttons below the filter to be in line with the design rule that submit buttons are always right aligned.</li>
     <li>Fix wrong diffs in RSS feed.</li>
     <li>Fix unescaped HTML in RSS feed.</li>
--- a/src/main/webapp/WEB-INF/jspf/issue-filter.jspf	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/webapp/WEB-INF/jspf/issue-filter.jspf	Thu Oct 09 11:49:39 2025 +0200
@@ -76,17 +76,21 @@
         </div>
         <c:set var="sortPriority" value="primary"/>
         <c:set var="currentSort" value="${viewmodel.filter.sortPrimary}"/>
+        <c:set var="defaultSort" value="${viewmodel.filter.defaultSortPrimary}"/>
         <%@include file="sort-box.jspf"%>
         <c:set var="sortPriority" value="secondary"/>
         <c:set var="currentSort" value="${viewmodel.filter.sortSecondary}"/>
+        <c:set var="defaultSort" value="${viewmodel.filter.defaultSortSecondary}"/>
         <%@include file="sort-box.jspf"%>
         <c:set var="sortPriority" value="tertiary"/>
         <c:set var="currentSort" value="${viewmodel.filter.sortTertiary}"/>
+        <c:set var="defaultSort" value="${viewmodel.filter.defaultSortTertiary}"/>
         <%@include file="sort-box.jspf"%>
     </div>
     <div class="medskip">
-        <input type="hidden" id="filter-remove" name="filter">
+        <input type="hidden" id="sort-default" name="sort" disabled/>
+        <input type="hidden" id="filter-remove" name="filter" disabled>
         <a class="button" onclick="removeAllFilters()"><fmt:message key="button.remove"/></a>
-        <button name="filter" type="submit"><fmt:message key="button.apply"/></button>
+        <button type="button" onclick="submitFilters()"><fmt:message key="button.apply"/></button>
     </div>
 </form>
--- a/src/main/webapp/WEB-INF/jspf/sort-box.jspf	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/webapp/WEB-INF/jspf/sort-box.jspf	Thu Oct 09 11:49:39 2025 +0200
@@ -2,10 +2,11 @@
 Page attribute:
   sortPriority: String
   currentSort: IssueSorter.Criteria
+  defaultSort: IssueSorter.Criteria
 --%>
 <div style="display: inline-block">
     <label class="caption" style="display:block;" for="sort_${sortPriority}"><fmt:message key="issue.filter.sort.${sortPriority}"/></label>
-    <select id="sort_${sortPriority}" name="sort_${sortPriority}">
+    <select id="sort_${sortPriority}" name="sort_${sortPriority}" data-default="${defaultSort}">
         <c:forEach var="criteria" items="${viewmodel.filter.sortCriteria}">
             <option value="${criteria}" <c:if test="${currentSort eq criteria}">selected</c:if> >
                 <fmt:message key="${criteria.field.resourceKey}"/>
--- a/src/main/webapp/issue-overview.js	Tue Oct 07 10:08:34 2025 +0200
+++ b/src/main/webapp/issue-overview.js	Thu Oct 09 11:49:39 2025 +0200
@@ -24,26 +24,50 @@
  */
 
 function toggleFilterDetails() {
-    const filters = document.getElementById('more-filters')
-    const toggle = document.getElementById('show-more-filters')
+    const filters = document.getElementById('more-filters');
+    const toggle = document.getElementById('show-more-filters');
     if (toggle.checked) {
-        filters.style.display = 'flex'
+        filters.style.display = 'flex';
     } else {
-        filters.style.display = 'none'
+        filters.style.display = 'none';
     }
 }
 
 function toggleAssigneeOnlyMine() {
-    const filters = document.getElementById('filter-assignee')
-    const toggle = document.getElementById('filter-only-mine')
+    const filters = document.getElementById('filter-assignee');
+    const toggle = document.getElementById('filter-only-mine');
     filters.disabled = !!toggle.checked;
 }
 
 function removeAllFilters() {
-    document.querySelectorAll('#filter-form *[name=filter]')
+    document.querySelectorAll('#filter-form *[name=filter], #filter-form *[name^=sort_]')
         .forEach((elem) => elem.value = '');
-    document.getElementById('filter-remove').value = 'clear'
-    document.getElementById('filter-form').submit()
+    document.getElementById('sort-default').value = 'default';
+    document.getElementById('sort-default').disabled = false;
+    document.getElementById('filter-remove').value = 'clear';
+    document.getElementById('filter-remove').disabled = false;
+    document.getElementById('filter-form').submit();
+}
+
+function cleanDefaultSort(elem) {
+    if (elem.value === elem.dataset.default) {
+        elem.value = '';
+        elem.disabled = true;
+    }
+}
+
+function submitFilters() {
+    let sort1 = document.getElementById('sort_primary')
+    let sort2 = document.getElementById('sort_secondary')
+    let sort3 = document.getElementById('sort_tertiary')
+    cleanDefaultSort(sort1);
+    cleanDefaultSort(sort2);
+    cleanDefaultSort(sort3);
+    if (sort1.disabled && sort2.disabled && sort3.disabled) {
+        document.getElementById('sort-default').value = 'default';
+        document.getElementById('sort-default').disabled = false;
+    }
+    document.getElementById('filter-form').submit();
 }
 
 window.addEventListener('load', function() { toggleFilterDetails() }, false)

mercurial