Skip to content

Commit

Permalink
Fix missing changeset comment in sidebar. Show changeset source tag i…
Browse files Browse the repository at this point in the history
…n sidebar
  • Loading branch information
quincylvania committed Oct 15, 2024
1 parent a92a633 commit 92796ad
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion js/dataController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function selectEntity(entityInfo) {
updateMapForSelection();
updateMapForHover();

if (isSidebarOpen()) updateSidebar();
if (isSidebarOpen()) updateSidebar(selectedEntityInfo);

if (!selectedEntityInfo) return;

Expand Down
1 change: 1 addition & 0 deletions js/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
12 changes: 6 additions & 6 deletions js/sidebarController.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function openSidebar() {
}
document.getElementsByTagName('body')[0].classList.add('sidebar-open');
setHashParameters({ inspect: 1 });
updateSidebar();
updateSidebar(selectedEntityInfo);
}
}
function closeSidebar() {
Expand All @@ -26,9 +26,7 @@ function closeSidebar() {
}
}

function updateSidebar() {

let entity = selectedEntityInfo;
function updateSidebar(entity) {

if (!entity) {
document.getElementById('sidebar').innerHTML = "";
Expand Down Expand Up @@ -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 += `<tr><th colspan='2'>Meta</th></tr>`;
html += `<tr><td>ID</td><td><a href="https://www.openstreetmap.org/${entity.type}/${entity.id}" target="_blank">${entity.type}/${entity.id}</a></td></tr>`;
html += `<tr><td>Version</td><td><a href="https://www.openstreetmap.org/${entity.type}/${entity.id}/history" target="_blank">${entity.version}</a></td></tr>`;
html += `<tr><td>Changeset</td><td><a href="https://www.openstreetmap.org/changeset/${entity.changeset}" target="_blank">${entity.changeset}</a></td></tr>`;
html += `<tr><td>Comment</td><td>${comment}</td></tr>`;
html += `<tr><td>Uploaded</td><td>${formattedDate}</td></tr>`;
html += `<tr><td>User</td><td><a href="https://www.openstreetmap.org/user/${entity.user}" target="_blank">${entity.user}</a></td></tr>`;
html += `<tr><td>Changeset</td><td><a href="https://www.openstreetmap.org/changeset/${entity.changeset}" target="_blank">${entity.changeset}</a></td></tr>`;
html += `<tr><td>Comment</td><td>${comment}</td></tr>`;
html += `<tr><td>Source</td><td>${sources}</td></tr>`;
document.getElementById('meta-table').innerHTML = html;
}

Expand Down

0 comments on commit 92796ad

Please sign in to comment.