[Browse] Handle missing path and nav to root
When no path is specified, don't throw error. Navigate to default, as expected. When navigating to root, navigate to the last child of root instead. This handles cases where DEFAULT_PATH is not found (e.g. deployments without "mine").
This commit is contained in:
@@ -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) {
|
||||||
|
if (route.pathParams.ids &&
|
||||||
route.pathParams.ids !== $route.current.pathParams.ids) {
|
route.pathParams.ids !== $route.current.pathParams.ids) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
navigateToPath(route.pathParams.ids.split('/'));
|
navigateToPath(route.pathParams.ids.split('/'));
|
||||||
|
} else {
|
||||||
|
navigateToPath([]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user