mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 06:38:17 +00:00
[urlService] CleanUp/Refactor
Adjusted BrowseController's useRoute to use the urlService instead. Also adds urlService as a depency through bundle. Unit test also adjusted to account for a mockUrlService and a different value being passed into mockLocation.path(). WTD 16.
This commit is contained in:
@ -41,19 +41,13 @@ define(
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function BrowseController($scope, $route, $location, objectService, navigationService) {
|
||||
function BrowseController($scope, $route, $location, objectService, navigationService, urlService) {
|
||||
var path = [ROOT_ID].concat(
|
||||
($route.current.params.ids || DEFAULT_PATH).split("/")
|
||||
);
|
||||
|
||||
function updateRoute(domainObject) {
|
||||
var context = domainObject &&
|
||||
domainObject.getCapability('context'),
|
||||
objectPath = context ? context.getPath() : [],
|
||||
ids = objectPath.map(function (domainObject) {
|
||||
return domainObject.getId();
|
||||
}),
|
||||
priorRoute = $route.current,
|
||||
var priorRoute = $route.current,
|
||||
// Act as if params HADN'T changed to avoid page reload
|
||||
unlisten;
|
||||
|
||||
@ -61,8 +55,10 @@ define(
|
||||
$route.current = priorRoute;
|
||||
unlisten();
|
||||
});
|
||||
|
||||
$location.path("/browse/" + ids.slice(1).join("/"));
|
||||
// urlService.urlFor used to adjust current
|
||||
// path to new, addressed, path based on
|
||||
// domainObject
|
||||
$location.path(urlService.urlFor("browse", domainObject));
|
||||
}
|
||||
|
||||
// Callback for updating the in-scope reference to the object
|
||||
|
Reference in New Issue
Block a user