mirror of
https://github.com/nasa/openmct.git
synced 2025-01-29 15:43:52 +00:00
Merge pull request #1547 from nasa/no-error-on-root-load
[Browse] Handle missing path and nav to root
This commit is contained in:
commit
29d65e9cef
@ -113,11 +113,22 @@ define(
|
||||
$location.path('/browse/' + currentIds);
|
||||
}
|
||||
|
||||
function getLastChildIfRoot(object) {
|
||||
if (object.getId() !== 'ROOT') {
|
||||
return object;
|
||||
}
|
||||
return object.useCapability('composition')
|
||||
.then(function (composees) {
|
||||
return composees[composees.length - 1];
|
||||
});
|
||||
}
|
||||
|
||||
function navigateToPath(path) {
|
||||
return getObject('ROOT')
|
||||
.then(function (root) {
|
||||
return findViaComposition(root, path);
|
||||
})
|
||||
.then(getLastChildIfRoot)
|
||||
.then(function (object) {
|
||||
navigationService.setNavigation(object);
|
||||
});
|
||||
@ -147,10 +158,14 @@ define(
|
||||
// navigate to the path ourselves, which results in it being
|
||||
// properly set.
|
||||
$scope.$on('$routeChangeStart', function (event, route) {
|
||||
if (route.$$route === $route.current.$$route &&
|
||||
route.pathParams.ids !== $route.current.pathParams.ids) {
|
||||
event.preventDefault();
|
||||
navigateToPath(route.pathParams.ids.split('/'));
|
||||
if (route.$$route === $route.current.$$route) {
|
||||
if (route.pathParams.ids &&
|
||||
route.pathParams.ids !== $route.current.pathParams.ids) {
|
||||
event.preventDefault();
|
||||
navigateToPath(route.pathParams.ids.split('/'));
|
||||
} else {
|
||||
navigateToPath([]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user