Skip to content

Commit

Permalink
Bugfix: LayersTool - Fix collapse all headers
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Mar 27, 2024
1 parent 1923fe5 commit ec341f4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/essence/Tools/Layers/LayersTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var LayersTool = {
vars: {},
MMGISInterface: null,
orderingHistory: [],
_maxDepth: 0,
initialize: function () {
//Get tool variables
this.vars = L_.getToolVars('layers')
Expand Down Expand Up @@ -217,10 +218,13 @@ function interfaceWithMMGIS(fromInit) {

let headerI = 0

LayersTool._maxDepth = 0

//This is where the layers list is created in the tool panel.
depthTraversal(L_.configData.layers, {}, 0)

function depthTraversal(node, parent, depth) {
LayersTool._maxDepth = Math.max(LayersTool._maxDepth, depth)
for (var i = 0; i < node.length; i++) {
let currentOpacity
let currentBrightness
Expand Down Expand Up @@ -1170,14 +1174,19 @@ function interfaceWithMMGIS(fromInit) {
})

$('#searchLayers > #collapse').on('click', function () {
$('#layersToolList > li').each(function () {
if (
$(this).attr('type') == 'header' &&
$(this).attr('childrenon') == 'true'
) {
LayersTool.toggleHeader($(this).attr('id'))
}
})
// Collapse deepest first
for (let depth = LayersTool._maxDepth; depth >= 0; depth--) {
$(`#layersToolList > li[type="header"][depth="${depth}"]`).each(
function () {
if (
$(this).attr('type') == 'header' &&
$(this).attr('childrenon') == 'true'
) {
LayersTool.toggleHeader($(this).attr('id'))
}
}
)
}
})

$('#filterLayers .right > div').on('click', function () {
Expand Down

0 comments on commit ec341f4

Please sign in to comment.