mirror of
https://github.com/nasa/openmct.git
synced 2025-05-06 18:48:27 +00:00
[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:
parent
084d6b6859
commit
3738ea16d7
@ -41,9 +41,9 @@ define(
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function BrowseController($scope, $routeParams, $location, objectService, navigationService) {
|
function BrowseController($scope, $route, $location, objectService, navigationService) {
|
||||||
var path = [ROOT_ID].concat(
|
var path = [ROOT_ID].concat(
|
||||||
($routeParams.ids || DEFAULT_PATH).split("/")
|
($route.current.ids || DEFAULT_PATH).split("/")
|
||||||
);
|
);
|
||||||
|
|
||||||
function updateRoute(domainObject) {
|
function updateRoute(domainObject) {
|
||||||
@ -51,6 +51,12 @@ define(
|
|||||||
objectPath = context.getPath(),
|
objectPath = context.getPath(),
|
||||||
ids = objectPath.map(function (domainObject) {
|
ids = objectPath.map(function (domainObject) {
|
||||||
return domainObject.getId();
|
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("/"));
|
$location.path("/browse/" + ids.slice(1).join("/"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user