From 7782c59a54da13e2cb51b6dbcd3ac8636fdeeca6 Mon Sep 17 00:00:00 2001 From: sethg Date: Sat, 20 Jun 2026 00:57:01 +0200 Subject: [PATCH 1/2] Add sorting to columns and fix page size logic --- .../html-bootstrap/collection-items.html | 81 ++++++++++++++++--- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/share/ogcapi/templates/html-bootstrap/collection-items.html b/share/ogcapi/templates/html-bootstrap/collection-items.html index d989fbad47..5cfc801209 100644 --- a/share/ogcapi/templates/html-bootstrap/collection-items.html +++ b/share/ogcapi/templates/html-bootstrap/collection-items.html @@ -34,11 +34,11 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

{% if show_next_link == true %} @@ -52,8 +52,8 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

ID {% if response.features %} {% for key, value in response.features.0.properties %} - {{ key }} -{% endfor %} + {{ key }} +{% endfor %} {% endif %} @@ -73,9 +73,39 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

function changePageSize() { const limitSelect = document.getElementById("limit"); - const url = "{{ template.api_root }}/collections/{{ response.collection.id }}/items?limit=" + limitSelect.value + "{{ template.extra_params }}"; - window.location.href = url; + + const url = new URL(window.location.href); + url.searchParams.set("limit", limitSelect.value); + url.searchParams.delete("offset"); + + window.location.href = url.toString(); +} + +// sorting +let sortables = []; + +function renderSortableHeaders() { + const currentSort = new URLSearchParams(window.location.search).get('sortby') || ''; + document.querySelectorAll('th[data-property]').forEach(th => { + const prop = th.dataset.property; + if (!sortables.includes(prop)) return; + + const isAsc = currentSort === '+' + prop || currentSort === prop; + const isDesc = currentSort === '-' + prop; + const nextSort = isAsc ? '-' + prop : '+' + prop; + const arrow = isAsc ? ' ▲' : isDesc ? ' ▼' : ' ⇅'; + + const url = new URL(window.location.href); + url.searchParams.set('sortby', nextSort); + url.searchParams.delete('offset'); // reset to first page on sort change + + th.innerHTML = ` + ${prop}${arrow} + `; + th.style.cursor = 'pointer'; + }); } + document.addEventListener("DOMContentLoaded", function () { // // mapping @@ -89,7 +119,11 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

{{ template.title }} - Collection Items: {{ response.collection.title }} r.json()) + .then(data => { + sortables = data.properties ? Object.keys(data.properties) : []; + renderSortableHeaders(); + }) + .catch(err => { + console.error("Failed to load sortable fields", err); + }); + }); From 9fe18891d649a483802195046bcaed5235233905 Mon Sep 17 00:00:00 2001 From: sethg Date: Sat, 20 Jun 2026 13:10:38 +0200 Subject: [PATCH 2/2] Allow multiple column sorting and basic column filtering --- .../html-bootstrap/collection-items.html | 175 ++++++++++++++++-- 1 file changed, 158 insertions(+), 17 deletions(-) diff --git a/share/ogcapi/templates/html-bootstrap/collection-items.html b/share/ogcapi/templates/html-bootstrap/collection-items.html index 5cfc801209..6cb7429c5f 100644 --- a/share/ogcapi/templates/html-bootstrap/collection-items.html +++ b/share/ogcapi/templates/html-bootstrap/collection-items.html @@ -44,6 +44,11 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

next {% endif %} +
+ + Clear filters +
@@ -54,6 +59,14 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}

{{ key }} {% endfor %} +{% endif %} + + + +{% if response.features %} +{% for key, value in response.features.0.properties %} + +{% endfor %} {% endif %} @@ -71,6 +84,10 @@

{{ template.title }} - Collection Items: {{ response.collection.title }}