Skip to content

Commit

Permalink
PB-585: solving issue with drawings when updating layers
Browse files Browse the repository at this point in the history
Issue : When we updated the layers, we tried to fetch the drawings from the backend as if they were ordinary layers. This did not work and as a result, the features list had an occurrence where there was a layer with no features selected.
Fix : We add back the initial features if the feature list would be empty after updating.

some linting
  • Loading branch information
ltkum committed Jun 18, 2024
1 parent 3332561 commit 0bb18e1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/store/modules/features.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,17 @@ export default {
const { state, commit, getters, rootState } = store
const featuresPromises = []
getters.selectedLayerFeatures.forEach((feature) => {
featuresPromises.push(
getFeature(
feature.layer,
feature.id,
rootState.position.projection,
rootState.i18n.lang
// we avoid requesting the drawings and external layers, they're not handled here
if (rootState.layers.config.find((layer) => layer.id === feature.layer.id)) {
featuresPromises.push(
getFeature(
feature.layer,
feature.id,
rootState.position.projection,
rootState.i18n.lang
)
)
)
}
})
if (featuresPromises.length > 0) {
try {
Expand All @@ -661,12 +664,16 @@ export default {
const updatedFeaturesByLayerId = state.selectedFeaturesByLayerId.reduce(
(updated_array, layer) => {
const rawLayer = toRaw(layer)
const rawLayerFeatures = rawLayer.features
rawLayer.features = features.reduce((features_array, feature) => {
if (feature.layer.id === layer.layerId) {
if (feature.layer.id === rawLayer.layerId) {
features_array.push(feature)
}
return features_array
}, [])
if (rawLayer.features.length === 0) {
rawLayer.features = rawLayerFeatures
}
updated_array.push(rawLayer)
return updated_array
},
Expand Down

0 comments on commit 0bb18e1

Please sign in to comment.