[Common UI] Initial commonUI bundles
Bring in work on general-purpose and over-arching user interface bundles from the sandbox transition branch. WTD-574.
This commit is contained in:
53
platform/commonUI/browse/src/BrowseController.js
Normal file
53
platform/commonUI/browse/src/BrowseController.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/*global define,Promise*/
|
||||
|
||||
/**
|
||||
* Module defining BrowseController. Created by vwoeltje on 11/7/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
var ROOT_OBJECT = "ROOT";
|
||||
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function BrowseController($scope, objectService, navigationService) {
|
||||
function setNavigation(domainObject) {
|
||||
$scope.navigatedObject = domainObject;
|
||||
//$scope.$apply("navigatedObject");
|
||||
}
|
||||
|
||||
objectService.getObjects([ROOT_OBJECT]).then(function (objects) {
|
||||
var composition = objects[ROOT_OBJECT].useCapability("composition");
|
||||
$scope.domainObject = objects[ROOT_OBJECT];
|
||||
if (composition) {
|
||||
composition.then(function (c) {
|
||||
// Navigate to the last root level component (usually "mine")
|
||||
if (!navigationService.getNavigation()) {
|
||||
navigationService.setNavigation(c[c.length - 1]);
|
||||
} else {
|
||||
$scope.navigatedObject = navigationService.getNavigation();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on("$destroy", function () {
|
||||
navigationService.removeListener(setNavigation);
|
||||
});
|
||||
|
||||
navigationService.addListener(setNavigation);
|
||||
|
||||
return {
|
||||
setNavigation: function (domainObject) {
|
||||
navigationService.setNavigation(domainObject);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return BrowseController;
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user