Skip to content

Commit

Permalink
Fix route modif not saved if an incorrect marker has been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
justinefricou authored and submarcos committed Sep 4, 2024
1 parent ad2d965 commit 58924cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions geotrek/core/static/core/multipath.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,24 +917,29 @@ L.Handler.MultiPath = L.Handler.extend({
})
oldStepsIndexes = data.oldStepsIndexes
newStepsIndexes = data.newStepsIndexes
var previousRouteLayer = this._routeLayer.getLayers()

if (!this._routeLayer) {
this._routeLayer = L.featureGroup()
this.map.addLayer(this._routeLayer);
}
this.updateRouteLayers(data.geojson.geometries, oldStepsIndexes, newStepsIndexes)

this._routeIsValid = true
var isNewMarkerBeingCorrected = this._routeIsValid == false && this._previousStepsNb > previousRouteLayer.length + 1

// Store the new topology
var nbSubToposToRemove = 0
if (oldStepsIndexes.length > 0)
if (isNewMarkerBeingCorrected) {
nbSubToposToRemove = 1
} else if (oldStepsIndexes.length > 0) {
// If it's not the first time displaying a layer
nbSubToposToRemove = oldStepsIndexes.length - 1
}
var spliceArgs = [newStepsIndexes[0], nbSubToposToRemove].concat(data.serialized)
this._routeTopology.splice.apply(this._routeTopology, spliceArgs)
this.fire('computed_topology', {topology: this._routeTopology});

this._routeIsValid = true
this.setupNewRouteDragging(this._routeLayer)
this.disableLoadingMode()
},
Expand Down

0 comments on commit 58924cd

Please sign in to comment.