Skip to content

Commit

Permalink
Merge pull request #971 from geoadmin/fix-PB-734-topic-layers-config-…
Browse files Browse the repository at this point in the history
…mismatch

PB-734 : search all layers with ID before fallback to technical name - #patch
  • Loading branch information
pakb authored Jun 27, 2024
2 parents bc9b267 + e6a9cf7 commit 5c00f27
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/api/topics.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ const readTopicTreeRecursive = (node, availableLayers) => {
})
return new GeoAdminGroupOfLayers({ id: `${node.id}`, name: node.label, layers: children })
} else if (node.category === 'layer') {
const matchingLayer = availableLayers.find(
(layer) => layer.technicalName === node.layerBodId || layer.id === node.layerBodId
)
// we have to match IDs first, some layers have the same technicalNames (when 3D counterpart config exist for instance), and
// matching both together will result sometimes in the 3D config being displayed in the topic instead of the correct layer
let matchingLayer = availableLayers.find((layer) => layer.id === node.layerBodId)
if (!matchingLayer) {
matchingLayer = availableLayers.find((layer) => layer.technicalName === node.layerBodId)
}
if (matchingLayer) {
return matchingLayer
}
Expand Down

0 comments on commit 5c00f27

Please sign in to comment.