Skip to content
Snippets Groups Projects
Commit 5b9d3a4c authored by Timothee P's avatar Timothee P :sunflower:
Browse files

fix error of duplicating a layer after dragging, if same layer found in different basemaps

parent b07d85d3
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,8 @@
:data-basemap-index="basemap.id"
>
<div
v-for="(layer, index) in basemap.layers"
:key="basemap.id + '-' + layer.id + '-' + index"
v-for="layer in basemap.layers"
:key="basemap.id + '-' + layer.id"
class="layer-item transition visible item list-group-item"
:data-id="layer.id"
>
......@@ -108,6 +108,7 @@ export default {
},
mounted() {
this.basemapLayers = [...this.basemap.layers];
setTimeout(this.initSortable.bind(this), 1000);
},
......
......@@ -235,16 +235,16 @@ export default {
},
onlayerMove() {
// Get the names of the current layers in order.
const currentLayersNamesInOrder = Array.from(
document.getElementsByClassName('layer-item transition visible')
// Get ids of the draggable layers in its current order.
const currentLayersIdInOrder = Array.from(
document.querySelectorAll('.content.active .layer-item.transition.visible')
).map((el) => parseInt(el.attributes['data-id'].value));
// Create an array to put the layers in order.
// Create an array to put the original layers in the same order.
let movedLayers = [];
for (const layerName of currentLayersNamesInOrder) {
for (const layerId of currentLayersIdInOrder) {
movedLayers.push(
this.activeBasemap.layers.find((el) => el.id === layerName)
this.activeBasemap.layers.find((el) => el.id === layerId)
);
}
// Remove existing layers undefined
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment