From 57e63975db3b28c1fc7aa548f5d783b969d33b2e Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Mon, 1 Sep 2025 17:32:03 +0200 Subject: [PATCH] fix: Sort sources alphabetically in UI for consistent display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed Sources list and dropdown to sort alphabetically by name instead of dynamically by last data arrival time. This provides a stable, predictable order that is less distracting during use. - Modified updateSourcesLegend() in map-manager.js to sort sources by name - Modified updateSourceFilter() in ui-manager.js to maintain consistent sorting - Sources now use localeCompare() for proper alphabetical ordering 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- assets/static/js/modules/map-manager.js | 7 ++++++- assets/static/js/modules/ui-manager.js | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/static/js/modules/map-manager.js b/assets/static/js/modules/map-manager.js index e3438e8..3149e51 100644 --- a/assets/static/js/modules/map-manager.js +++ b/assets/static/js/modules/map-manager.js @@ -199,7 +199,12 @@ export class MapManager { legend.innerHTML = ''; - for (const [id, source] of this.sourcesData) { + // Sort sources alphabetically by name + const sortedSources = Array.from(this.sourcesData.values()).sort((a, b) => + a.name.localeCompare(b.name) + ); + + for (const source of sortedSources) { const item = document.createElement('div'); item.className = 'legend-item'; item.innerHTML = ` diff --git a/assets/static/js/modules/ui-manager.js b/assets/static/js/modules/ui-manager.js index 8db8301..9bb8618 100644 --- a/assets/static/js/modules/ui-manager.js +++ b/assets/static/js/modules/ui-manager.js @@ -226,8 +226,12 @@ export class UIManager { // Clear options except "All Sources" select.innerHTML = ''; - // Add source options - for (const [id, source] of this.sourcesData) { + // Sort sources alphabetically by name and add options + const sortedSources = Array.from(this.sourcesData.entries()).sort((a, b) => + a[1].name.localeCompare(b[1].name) + ); + + for (const [id, source] of sortedSources) { const option = document.createElement('option'); option.value = id; option.textContent = source.name;