From 4014c2e9bbd75f8c88d7def950d34f2c756e385f Mon Sep 17 00:00:00 2001 From: Benjamin Gerber Date: Mon, 3 Dec 2018 13:05:52 +0100 Subject: [PATCH 1/3] Correct 'active' property name in oeedit index GEO-1652 --- contribs/gmf/apps/oeedit/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/gmf/apps/oeedit/index.html b/contribs/gmf/apps/oeedit/index.html index b7a86d80b0c7..0359562da48f 100644 --- a/contribs/gmf/apps/oeedit/index.html +++ b/contribs/gmf/apps/oeedit/index.html @@ -76,7 +76,7 @@ Date: Mon, 3 Dec 2018 13:06:52 +0100 Subject: [PATCH 2/3] Deactivate objecteditingtools if property active is false GEO-1652 --- .../gmf/src/directives/objecteditingtools.js | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/contribs/gmf/src/directives/objecteditingtools.js b/contribs/gmf/src/directives/objecteditingtools.js index a3b25d48a4c6..a8cf8dd9351a 100644 --- a/contribs/gmf/src/directives/objecteditingtools.js +++ b/contribs/gmf/src/directives/objecteditingtools.js @@ -252,6 +252,24 @@ gmf.ObjecteditingtoolsController = function($injector, $scope, $scope.$on('$destroy', this.handleDestroy_.bind(this)); }; +/** + * Init the controller + */ +gmf.ObjecteditingtoolsController.prototype.$onInit = function() { + this.scope_.$watch( + () => this.active, + (newVal, oldVal) => { + // if it's not active, deactive tools + if (!this.active) { + this.requiresLayer = false; + for (let i = 0, ii = this.toolActiveNames_.length; i < ii; i++) { + this[this.toolActiveNames_[i]] = false; + } + } + } + ); +}; + /** * Register a tool using its `active` property name and what behavior it should @@ -310,19 +328,15 @@ gmf.ObjecteditingtoolsController.prototype.handleToolActiveChange_ = function( this.requiresLayer = requiresLayer; } - // Update active property + // If one tool is active, update active property to true. let active = false; for (let i = 0, ii = this.toolActiveNames_.length; i < ii; i++) { - active = active || this[this.toolActiveNames_[i]]; + active = this[this.toolActiveNames_[i]]; if (active) { break; } } this.active = active; - - if (!this.active) { - this.requiresLayer = false; - } }; From 67d2a2ea78085eb4f32f7016d0607aa929027cdd Mon Sep 17 00:00:00 2001 From: Benjamin Gerber Date: Mon, 3 Dec 2018 13:08:04 +0100 Subject: [PATCH 3/3] Deactivate objectediting and objecteditingTool if 'active' property is false GEO-1652 --- contribs/gmf/src/directives/objectediting.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/contribs/gmf/src/directives/objectediting.js b/contribs/gmf/src/directives/objectediting.js index fffd25ef4dec..bfdea9f54f26 100644 --- a/contribs/gmf/src/directives/objectediting.js +++ b/contribs/gmf/src/directives/objectediting.js @@ -393,6 +393,15 @@ gmf.ObjecteditingController.prototype.$onInit = function() { this.handleGetQueryableLayersInfo_.bind(this) ); + this.scope_.$watch( + () => this.active, + (newVal, oldVal) => { + if (newVal != oldVal) { + this.toggle_(newVal); + } + } + ); + this.scope_.$watchCollection( () => { if (this.gmfTreeManager_.rootCtrl) { @@ -448,7 +457,6 @@ gmf.ObjecteditingController.prototype.$onInit = function() { // Toggle on this.initializeInteractions_(); - this.registerInteractions_(); this.toggle_(true); this.resetGeometryChanges_(); @@ -545,7 +553,6 @@ gmf.ObjecteditingController.prototype.undo = function() { /** - * Undo the latest modifications. * @return {boolean} Whether the state is INSERT or not. * @export */ @@ -693,9 +700,11 @@ gmf.ObjecteditingController.prototype.toggle_ = function(active) { toolMgr.registerTool(uid, this.modifyToolActivate_, true); toolMgr.registerTool(uid, this.toolsToolActivate_, false); + this.registerInteractions_(); + } else { - this.undoAllChanges_(); + this.unregisterInteractions_(); keys.forEach((key) => { ol.events.unlistenByKey(key); @@ -706,6 +715,7 @@ gmf.ObjecteditingController.prototype.toggle_ = function(active) { } + this.toolsActive = active; this.modify_.setActive(active); }; @@ -1069,7 +1079,7 @@ gmf.ObjecteditingController.prototype.handleGetQueryableLayersInfo_ = function( gmf.ObjecteditingController.prototype.handleDestroy_ = function() { this.features_.clear(); this.toggle_(false); - this.unregisterInteractions_(); + this.undoAllChanges_(); };