From 856c61816cbe6668d9b925c88c75eee1ea80bba5 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 9 Dec 2015 14:08:19 -0800 Subject: [PATCH] Go to original now shows prompt --- .../commonUI/browse/src/BrowseController.js | 20 +++++++++++++++---- .../edit/src/capabilities/EditorCapability.js | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index f2d7fbcd7b..252bbdfa22 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -82,10 +82,22 @@ define( // Callback for updating the in-scope reference to the object // that is currently navigated-to. function setNavigation(domainObject) { - $scope.navigatedObject = domainObject; - $scope.treeModel.selectedObject = domainObject; - navigationService.setNavigation(domainObject); - updateRoute(domainObject); + if (domainObject === $scope.navigatedObject){ + //do nothing; + return; + } + + if (isDirty() && !confirm(CONFIRM_MSG)) { + navigationService.setNavigation($scope.navigatedObject); + } else { + if ($scope.navigatedObject && $scope.navigatedObject.hasCapability("editor")){ + $scope.navigatedObject.getCapability("editor").cancel(); + } + $scope.navigatedObject = domainObject; + $scope.treeModel.selectedObject = domainObject; + navigationService.setNavigation(domainObject); + updateRoute(domainObject); + } } function setSelectedObject(domainObject) { diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 81d3486021..a2938dab3e 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -114,6 +114,7 @@ define( EditorCapability.prototype.cancel = function () { this.editableObject.getCapability("status").set("editing", false); //TODO: Reset the cache as well here. + this.cache.markClean(this.editableObject); return resolvePromise(undefined); };