mirror of
https://github.com/nasa/openmct.git
synced 2025-02-06 11:09:21 +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);
|
$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) {
|
function navigateToPath(path) {
|
||||||
return getObject('ROOT')
|
return getObject('ROOT')
|
||||||
.then(function (root) {
|
.then(function (root) {
|
||||||
return findViaComposition(root, path);
|
return findViaComposition(root, path);
|
||||||
})
|
})
|
||||||
|
.then(getLastChildIfRoot)
|
||||||
.then(function (object) {
|
.then(function (object) {
|
||||||
navigationService.setNavigation(object);
|
navigationService.setNavigation(object);
|
||||||
});
|
});
|
||||||
@ -147,10 +158,14 @@ define(
|
|||||||
// navigate to the path ourselves, which results in it being
|
// navigate to the path ourselves, which results in it being
|
||||||
// properly set.
|
// properly set.
|
||||||
$scope.$on('$routeChangeStart', function (event, route) {
|
$scope.$on('$routeChangeStart', function (event, route) {
|
||||||
if (route.$$route === $route.current.$$route &&
|
if (route.$$route === $route.current.$$route) {
|
||||||
route.pathParams.ids !== $route.current.pathParams.ids) {
|
if (route.pathParams.ids &&
|
||||||
event.preventDefault();
|
route.pathParams.ids !== $route.current.pathParams.ids) {
|
||||||
navigateToPath(route.pathParams.ids.split('/'));
|
event.preventDefault();
|
||||||
|
navigateToPath(route.pathParams.ids.split('/'));
|
||||||
|
} else {
|
||||||
|
navigateToPath([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user