Skip to content

Commit

Permalink
Deactivate objectediting and objecteditingTool if 'active' property i…
Browse files Browse the repository at this point in the history
…s false

GEO-1652
  • Loading branch information
ger-benjamin committed Dec 3, 2018
1 parent 89b9858 commit 67d2a2e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions contribs/gmf/src/directives/objectediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -448,7 +457,6 @@ gmf.ObjecteditingController.prototype.$onInit = function() {

// Toggle on
this.initializeInteractions_();
this.registerInteractions_();
this.toggle_(true);
this.resetGeometryChanges_();

Expand Down Expand Up @@ -545,7 +553,6 @@ gmf.ObjecteditingController.prototype.undo = function() {


/**
* Undo the latest modifications.
* @return {boolean} Whether the state is INSERT or not.
* @export
*/
Expand Down Expand Up @@ -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);
Expand All @@ -706,6 +715,7 @@ gmf.ObjecteditingController.prototype.toggle_ = function(active) {

}

this.toolsActive = active;
this.modify_.setActive(active);
};

Expand Down Expand Up @@ -1069,7 +1079,7 @@ gmf.ObjecteditingController.prototype.handleGetQueryableLayersInfo_ = function(
gmf.ObjecteditingController.prototype.handleDestroy_ = function() {
this.features_.clear();
this.toggle_(false);
this.unregisterInteractions_();
this.undoAllChanges_();
};


Expand Down

0 comments on commit 67d2a2e

Please sign in to comment.