From 70e5dbe7ddf4e287ee2a4a7310932bd79cb42651 Mon Sep 17 00:00:00 2001 From: Joachim Schleicher Date: Sat, 30 Dec 2023 21:22:22 +0100 Subject: [PATCH] fix dirty flags when re-ordering layers The index of the top layer in the view starts with zero, while the rank of the layers count backwards. Thus moving the second-last to the last position should set the dirty flag of rank 0 and 1. Instead the former implementation set the dirty flag for layers >= 19 in a list of 20 layers - resulting in the wrong layers saved. Fixes #375 --- umap/static/umap/js/umap.controls.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index ab25569b..89e1bd5c 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -632,12 +632,14 @@ L.U.DataLayersControl = L.Control.extend({ function (e) { const layer = this.map.datalayers[e.src.dataset.id], other = this.map.datalayers[e.dst.dataset.id], - minIndex = Math.min(e.initialIndex, e.finalIndex) + minIndex = Math.min(layer.getRank(), other.getRank()), + maxIndex = Math.max(layer.getRank(), other.getRank()) if (e.finalIndex === 0) layer.bringToTop() else if (e.finalIndex > e.initialIndex) layer.insertBefore(other) else layer.insertAfter(other) this.map.eachDataLayerReverse((datalayer) => { - if (datalayer.getRank() >= minIndex) datalayer.isDirty = true + if (datalayer.getRank() >= minIndex && datalayer.getRank() <= maxIndex) + datalayer.isDirty = true }) this.map.indexDatalayers() },