Skip to content

Commit e625753

Browse files
committed
fix: restore selection highlight after redraws and wire up layer dropdown
Selection highlight lost on redraw or palette switch: the three render*() functions nulled out _selectedType/_selectedId before rebuilding layers, and the switch*Scheme() functions called setStyle on all layers without checking for an active selection. Fixed by removing the null-outs and adding a highlightObject() call at the end of each render and scheme-switch path (including inside the async applyGeoFeatures callback in renderSegments) so the orange highlight is reapplied immediately after every restyle. Layer selection dropdown had no effect: initializeLayerSwitching(map) was defined in map_layers_config.html but never called — only initializeMapLayers(map) was invoked in object_map.html. Added the missing call so the [data-layer] click handlers are actually attached.
1 parent fb00b61 commit e625753

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

cesnet_service_path_plugin/static/cesnet_service_path_plugin/js/object_map.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
layer.eachLayer(sub => { if (sub.setStyle) sub.setStyle({ color }); });
353353
}
354354
});
355+
if (_selectedType === 'segment') highlightObject('segment', _selectedId);
355356
updateLegend();
356357
}
357358

@@ -366,6 +367,7 @@
366367
if (!site) return;
367368
marker.setStyle({ fillColor: getSiteColor(site) });
368369
});
370+
if (_selectedType === 'site') highlightObject('site', _selectedId);
369371
updateLegend();
370372
}
371373

@@ -383,6 +385,7 @@
383385
layer.setStyle({ color });
384386
}
385387
});
388+
if (_selectedType === 'circuit') highlightObject('circuit', _selectedId);
386389
updateLegend();
387390
}
388391

@@ -848,7 +851,6 @@
848851
}
849852

850853
function renderSites() {
851-
if (_selectedType === 'site') { _selectedType = null; _selectedId = null; }
852854
siteGroup.clearLayers();
853855
siteLayers.clear();
854856

@@ -935,6 +937,8 @@
935937
});
936938
});
937939
}
940+
941+
if (_selectedType === 'site') highlightObject('site', _selectedId);
938942
}
939943

940944
// -------------------------------------------------------------------------
@@ -1208,7 +1212,6 @@
12081212
let cachedGeoFeatures = null;
12091213

12101214
function renderSegments() {
1211-
if (_selectedType === 'segment') { _selectedType = null; _selectedId = null; }
12121215
segmentPathGroup.clearLayers();
12131216
segmentLayers.clear();
12141217

@@ -1241,6 +1244,7 @@
12411244
segmentPathGroup.addLayer(layer);
12421245
segmentLayers.set(feature.properties.id.toString(), layer);
12431246
});
1247+
if (_selectedType === 'segment') highlightObject('segment', _selectedId);
12441248
fitMap();
12451249
}
12461250

@@ -1262,7 +1266,6 @@
12621266
// Circuit rendering
12631267
// -------------------------------------------------------------------------
12641268
function renderCircuits() {
1265-
if (_selectedType === 'circuit') { _selectedType = null; _selectedId = null; }
12661269
circuitGroup.clearLayers();
12671270
circuitLayers.clear();
12681271

@@ -1292,6 +1295,8 @@
12921295
circuitGroup.addLayer(line);
12931296
circuitLayers.set(circ.id.toString(), line);
12941297
});
1298+
1299+
if (_selectedType === 'circuit') highlightObject('circuit', _selectedId);
12951300
}
12961301

12971302
// -------------------------------------------------------------------------

cesnet_service_path_plugin/templates/cesnet_service_path_plugin/object_map.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ <h1 class="page-title mb-0">
408408
var _mapData = JSON.parse(document.getElementById('map-data').textContent);
409409
var map = L.map('map').setView([_mapData.mapCenter.lat, _mapData.mapCenter.lng], _mapData.mapCenter.zoom);
410410
initializeMapLayers(map);
411+
initializeLayerSwitching(map);
411412
</script>
412413
<script src="{% static 'cesnet_service_path_plugin/js/object_map.js' %}"></script>
413414

0 commit comments

Comments
 (0)