From 0263cf5407b2818af442d0269143896831d0e8f8 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 20 Nov 2015 13:59:32 -0800 Subject: [PATCH] Fixed cancel and drop-initiated edit --- platform/commonUI/browse/src/BrowseController.js | 12 +++--------- platform/commonUI/edit/src/actions/EditAction.js | 1 + .../edit/src/objects/EditableDomainObject.js | 1 - platform/representation/src/gestures/DropGesture.js | 2 ++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 9f3677a2c5..5c23e2ba67 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -76,6 +76,9 @@ define( if (domainObject !== $scope.navigatedObject && isDirty() && !confirm(CONFIRM_MSG)) { $scope.treeModel.selectedObject = $scope.navigatedObject; } else { + if (domainObject !== $scope.navigatedObject && $scope.navigatedObject.hasCapability('editor')){ + $scope.navigatedObject.getCapability('action').perform('cancel'); + } setNavigation(domainObject); } } @@ -163,15 +166,6 @@ define( return hasChanges; } - function beforeNavigateWarning (){ - if (isDirty()) { - return false; - } - else { - return true; - } - } - $scope.beforeUnloadWarning = function() { return isDirty() ? "Unsaved changes will be lost if you leave this page." : diff --git a/platform/commonUI/edit/src/actions/EditAction.js b/platform/commonUI/edit/src/actions/EditAction.js index 2f935963e2..6b8ba3e042 100644 --- a/platform/commonUI/edit/src/actions/EditAction.js +++ b/platform/commonUI/edit/src/actions/EditAction.js @@ -75,6 +75,7 @@ define( var editableObject; if (!this.domainObject.hasCapability("editor")) { editableObject = new EditableDomainObject(this.domainObject, this.$q); + editableObject.getCapability('status').set('editing', true); this.navigationService.setNavigation(editableObject); } //this.$location.path("/edit"); diff --git a/platform/commonUI/edit/src/objects/EditableDomainObject.js b/platform/commonUI/edit/src/objects/EditableDomainObject.js index 8ca905c9cd..bef4806040 100644 --- a/platform/commonUI/edit/src/objects/EditableDomainObject.js +++ b/platform/commonUI/edit/src/objects/EditableDomainObject.js @@ -118,7 +118,6 @@ define( cache = new EditableDomainObjectCache(EditableDomainObjectImpl, $q); cachedObject = cache.getEditableObject(domainObject); - cachedObject.getCapability('status').set('editing', true); return cachedObject; } diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index 3e57465636..6633d06527 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -137,6 +137,8 @@ define( domainObjectType = editableDomainObject.getModel().type, virtualObj; + editableDomainObject.getCapability('status').set('editing', true); + // If currently in edit mode allow drag and drop gestures to the // domain object. An exception to this is folders which have drop // gestures in browse mode.