[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.
This commit is contained in:
Victor Woeltjen 2015-06-16 13:44:35 -07:00
parent 084d6b6859
commit 3738ea16d7

View File

@ -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("/"));