From 1b37250d4d23b34e1d944ebcd716ba0389692690 Mon Sep 17 00:00:00 2001 From: Unai Bolivar Date: Fri, 10 May 2024 12:53:38 +0200 Subject: [PATCH] CLMS-2802 (bug): filtered hotspot layers swap index orders in map when dataset orders are changed in the active layers tab --- src/components/MapViewer/MenuWidget.jsx | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/components/MapViewer/MenuWidget.jsx b/src/components/MapViewer/MenuWidget.jsx index 15441dd8..1d0d54d4 100644 --- a/src/components/MapViewer/MenuWidget.jsx +++ b/src/components/MapViewer/MenuWidget.jsx @@ -2873,10 +2873,31 @@ class MenuWidget extends React.Component { layersReorder() { let activeLayers = document.querySelectorAll('.active-layer'); let counter = activeLayers.length - 1; + let filterLayer; activeLayers.forEach((item, index) => { + if ( + this.props.hotspotData && + this.props.hotspotData.filteredLayers && + Object.keys(this.props.hotspotData.filteredLayers).length > 0 + ) { + Object.keys(this.props.hotspotData.activeLayers).forEach((key) => { + if (item.id.includes(key)) { + if (key.includes('all_lcc')) { + filterLayer = this.layers['lcc_filter']; + } else if (key.includes('all_present')) { + filterLayer = this.layers['lc_filter']; + } + } + this.map.reorder(filterLayer, index); + }); + } let order = counter - index; item.setAttribute('layer-order', order); - this.layerReorder(this.layers[item.getAttribute('layer-id')], order); + if (filterLayer === undefined) { + this.layerReorder(this.layers[item.getAttribute('layer-id')], order); + } else { + this.layerReorder(filterLayer, order); + } }); } @@ -2901,7 +2922,25 @@ class MenuWidget extends React.Component { * @param {*} index */ layerReorder(layer, index) { + let filterLayer; + //if (this.props.hotspotData && + // this.props.hotspotData.filteredLayers && + // Object.keys(this.props.hotspotData.filteredLayers).length > 0 + //) { + // //debugger; + // Object.keys(this.props.hotspotData.activeLayers).forEach((key) => { + // if (layer.id === key) { + // if (key.includes('all_lcc')) { + // filterLayer = this.layers['lcc_filter']; + // } else if (key.includes('all_present')) { + // filterLayer = this.layers['lc_filter']; + // } + // } + // this.map.reorder(filterLayer, index); + // }); + //} else { this.map.reorder(layer, index); + //} } /**