Skip to content
Snippets Groups Projects
Commit 9e525eb1 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

block edit on double click for multi geometry

parent 545b154c
Branches
Tags
1 merge request!500REDMINE_ISSUE-14954| Désactiver l'édition de la géométrie dans le cas des géométries multiples
...@@ -66,7 +66,7 @@ const editionService = { ...@@ -66,7 +66,7 @@ const editionService = {
mapService.fitExtent(buffer(this.drawSource.getExtent(),200)); mapService.fitExtent(buffer(this.drawSource.getExtent(),200));
}, },
addEditionControls(geomType) { addEditionControls(geomType, isEditable) {
this.geom_type = geomType; this.geom_type = geomType;
this.drawSource = new VectorSource(); this.drawSource = new VectorSource();
this.drawnItems = new VectorLayer({ this.drawnItems = new VectorLayer({
...@@ -150,12 +150,6 @@ const editionService = { ...@@ -150,12 +150,6 @@ const editionService = {
features: this.selectForUpdate.getFeatures() features: this.selectForUpdate.getFeatures()
}); });
// je garde ce bout de code pour l'implementation a venir du snapping
//snapping
// var snap = new Snap({
// source: this.drawSource
//});
// This workaround allows to avoid the ol freeze // This workaround allows to avoid the ol freeze
// referenced bug : https://github.com/openlayers/openlayers/issues/6310 // referenced bug : https://github.com/openlayers/openlayers/issues/6310
// May be corrected in a future version // May be corrected in a future version
...@@ -168,10 +162,8 @@ const editionService = { ...@@ -168,10 +162,8 @@ const editionService = {
} }
}; };
mapService.getMap().addInteraction(this.selectForUpdate); if (isEditable) mapService.getMap().addInteraction(this.selectForUpdate); // disable edit on double-click if edition is disabled
mapService.getMap().addInteraction(this.modify); mapService.getMap().addInteraction(this.modify);
// je garde ce bout de code pour l'implementation a venir du snapping
//map.addInteraction(snap);
}, },
resetAllTools() { resetAllTools() {
if (this.draw) { if (this.draw) {
... ...
......
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
<SidebarLayers v-if="basemaps && map" /> <SidebarLayers v-if="basemaps && map" />
<EditingToolbar <EditingToolbar
v-if="basemaps && map && (feature_type && !feature_type.geom_type.includes('multi'))" v-if="isEditable"
:map="map" :map="map"
/> />
</div> </div>
...@@ -521,6 +521,10 @@ export default { ...@@ -521,6 +521,10 @@ export default {
} }
return []; return [];
}, },
isEditable() {
return this.basemaps && this.map && (this.feature_type && !this.feature_type.geom_type.includes('multi'));
}
}, },
watch: { watch: {
...@@ -890,7 +894,7 @@ export default { ...@@ -890,7 +894,7 @@ export default {
onFeatureTypeLoaded() { onFeatureTypeLoaded() {
const geomType = this.feature_type.geom_type; const geomType = this.feature_type.geom_type;
editionService.addEditionControls(geomType); editionService.addEditionControls(geomType, this.isEditable);
editionService.draw.on('drawend', (evt) => { editionService.draw.on('drawend', (evt) => {
const feature = evt.feature; const feature = evt.feature;
this.updateGeomField(new GeoJSON().writeGeometry(feature.getGeometry(),{ dataProjection:'EPSG:4326',featureProjection:'EPSG:3857' })); this.updateGeomField(new GeoJSON().writeGeometry(feature.getGeometry(),{ dataProjection:'EPSG:4326',featureProjection:'EPSG:3857' }));
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment