From 3738ea16d76ffa1167bc63941b7841c1de1af6ec Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:44:35 -0700 Subject: [PATCH] [Addressability] Update route without reinstantiating Work around normal behavior of Angular when path changes; instead of reinstantiating controller for Browse mode when Browse-initiated path changes occur, act as if the route hadn't changed (so that the URL updates but the currently-displayed state, e.g. tree expansion, is preserved.) WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index eebd11faf9..79a4c6d48d 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -41,9 +41,9 @@ define( * * @constructor */ - function BrowseController($scope, $routeParams, $location, objectService, navigationService) { + function BrowseController($scope, $route, $location, objectService, navigationService) { var path = [ROOT_ID].concat( - ($routeParams.ids || DEFAULT_PATH).split("/") + ($route.current.ids || DEFAULT_PATH).split("/") ); function updateRoute(domainObject) { @@ -51,6 +51,12 @@ define( objectPath = context.getPath(), ids = objectPath.map(function (domainObject) { return domainObject.getId(); + }), + priorRoute = $route.current, + // Act as if params HADN'T changed to avoid page reload + unlisten = $scope.$on('$locationChangeSuccess', function () { + $route.current = priorRoute; + unlisten(); }); $location.path("/browse/" + ids.slice(1).join("/"));