From 92796ad2a82490d8514e9b113caeb23d66b2d8d1 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:26:47 -0400 Subject: [PATCH] Fix missing changeset comment in sidebar. Show changeset source tag in sidebar --- js/dataController.js | 2 +- js/index.js | 2 +- js/mapController.js | 1 + js/sidebarController.js | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/dataController.js b/js/dataController.js index 6a0393c..d817b6a 100644 --- a/js/dataController.js +++ b/js/dataController.js @@ -62,7 +62,7 @@ async function fetchOsmChangeset(id) { let url = `https://api.openstreetmap.org/api/0.6/changeset/${id}.json`; let response = await fetch(url); let json = await response.json(); - osmChangesetCache[id] = json && json.elements && json.elements.length && json.elements[0]; + osmChangesetCache[id] = json && json.changeset; } return osmChangesetCache[id]; } \ No newline at end of file diff --git a/js/index.js b/js/index.js index 308bc59..de195af 100644 --- a/js/index.js +++ b/js/index.js @@ -378,7 +378,7 @@ function selectEntity(entityInfo) { updateMapForSelection(); updateMapForHover(); - if (isSidebarOpen()) updateSidebar(); + if (isSidebarOpen()) updateSidebar(selectedEntityInfo); if (!selectedEntityInfo) return; diff --git a/js/mapController.js b/js/mapController.js index 10db3dd..fc124f5 100644 --- a/js/mapController.js +++ b/js/mapController.js @@ -1533,6 +1533,7 @@ function entityForEvent(e, layerIds) { return { id: feature.properties.OSM_ID, type: feature.properties.OSM_TYPE, + changeset: feature.properties.OSM_CHANGESET, focusLngLat: focusLngLat, rawFeature: feature, }; diff --git a/js/sidebarController.js b/js/sidebarController.js index 5497dec..9da37e5 100644 --- a/js/sidebarController.js +++ b/js/sidebarController.js @@ -16,7 +16,7 @@ function openSidebar() { } document.getElementsByTagName('body')[0].classList.add('sidebar-open'); setHashParameters({ inspect: 1 }); - updateSidebar(); + updateSidebar(selectedEntityInfo); } } function closeSidebar() { @@ -26,9 +26,7 @@ function closeSidebar() { } } -function updateSidebar() { - - let entity = selectedEntityInfo; +function updateSidebar(entity) { if (!entity) { document.getElementById('sidebar').innerHTML = ""; @@ -101,14 +99,16 @@ function updateSidebar() { function updateMetaTable(entity, changeset) { let formattedDate = getFormattedDate(new Date(entity.timestamp)); let comment = changeset && changeset.tags && changeset.tags.comment || ''; + let sources = changeset && changeset.tags && changeset.tags.source || ''; let html = ""; html += `