[Addressability] Update path on navigation

Update path in browse mode when navigation state changes.
WTD-1149.
This commit is contained in:
Victor Woeltjen 2015-06-16 13:28:19 -07:00
parent 9fae2db04a
commit 084d6b6859
2 changed files with 13 additions and 2 deletions

View File

@ -14,7 +14,7 @@
{ {
"key": "BrowseController", "key": "BrowseController",
"implementation": "BrowseController.js", "implementation": "BrowseController.js",
"depends": [ "$scope", "$routeParams", "objectService", "navigationService" ] "depends": [ "$scope", "$route", "$location", "objectService", "navigationService" ]
}, },
{ {
"key": "CreateMenuController", "key": "CreateMenuController",

View File

@ -41,17 +41,28 @@ define(
* *
* @constructor * @constructor
*/ */
function BrowseController($scope, $routeParams, objectService, navigationService) { function BrowseController($scope, $routeParams, $location, objectService, navigationService) {
var path = [ROOT_ID].concat( var path = [ROOT_ID].concat(
($routeParams.ids || DEFAULT_PATH).split("/") ($routeParams.ids || DEFAULT_PATH).split("/")
); );
function updateRoute(domainObject) {
var context = domainObject.getCapability('context'),
objectPath = context.getPath(),
ids = objectPath.map(function (domainObject) {
return domainObject.getId();
});
$location.path("/browse/" + ids.slice(1).join("/"));
}
// Callback for updating the in-scope reference to the object // Callback for updating the in-scope reference to the object
// that is currently navigated-to. // that is currently navigated-to.
function setNavigation(domainObject) { function setNavigation(domainObject) {
$scope.navigatedObject = domainObject; $scope.navigatedObject = domainObject;
$scope.treeModel.selectedObject = domainObject; $scope.treeModel.selectedObject = domainObject;
navigationService.setNavigation(domainObject); navigationService.setNavigation(domainObject);
updateRoute(domainObject);
} }
function navigateTo(domainObject) { function navigateTo(domainObject) {