From 89be1c810a944bf172c2dbb488186070d3dd818b Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Tue, 20 Dec 2016 15:29:00 -0800 Subject: [PATCH] [Browse] tighter tree view integration BrowseController uses new MCTTreeView parameters to prevent navigation events before triggering digests. It also no longer sets navigation more frequently than it should. https://github.com/nasa/openmct/issues/1360 --- .../commonUI/browse/src/BrowseController.js | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 785a950891..9442ba9fca 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -48,11 +48,16 @@ define( defaultPath ) { var initialPath = ($route.current.params.ids || defaultPath).split("/"); - - var currentIds = $route.current.params.ids; + var currentIds; $scope.treeModel = { - selectedObject: undefined + selectedObject: undefined, + onSelection: function (object) { + navigationService.setNavigation(object, true); + }, + allowSelection: function (object) { + return navigationService.shouldNavigate(); + } }; function idsForObject(domainObject) { @@ -103,7 +108,6 @@ define( function navigateToObject(desiredObject) { $scope.navigatedObject = desiredObject; $scope.treeModel.selectedObject = desiredObject; - navigationService.setNavigation(desiredObject); currentIds = idsForObject(desiredObject); $route.current.pathParams.ids = currentIds; $location.path('/browse/' + currentIds); @@ -114,10 +118,11 @@ define( .then(function (root) { return findViaComposition(root, path); }) - .then(navigateToObject); + .then(function (object) { + navigationService.setNavigation(object); + }); } - getObject('ROOT') .then(function (root) { $scope.domainObject = root; @@ -137,15 +142,6 @@ define( // Listen for changes in navigation state. navigationService.addListener(navigateDirectlyToModel); - // Also listen for changes which come from the tree. Changes in - // the tree will trigger a change in browse navigation state. - $scope.$watch("treeModel.selectedObject", function (newObject, oldObject) { - if (oldObject !== newObject) { - navigateDirectlyToModel(newObject); - } - }); - - // Listen for route changes which are caused by browser events // (e.g. bookmarks to pages in OpenMCT) and prevent them. Instead, // navigate to the path ourselves, which results in it being