@@ -8,7 +8,7 @@
+ ng-model="treeModel">
diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js
index d96089d1d8..0d0e07781c 100644
--- a/platform/commonUI/browse/src/BrowseController.js
+++ b/platform/commonUI/browse/src/BrowseController.js
@@ -24,6 +24,7 @@ define(
// that is currently navigated-to.
function setNavigation(domainObject) {
$scope.navigatedObject = domainObject;
+ $scope.treeModel.selectedObject = domainObject;
}
// Load the root object, put it in the scope.
@@ -48,30 +49,22 @@ define(
}
});
+ // Provide a model for the tree to modify
+ $scope.treeModel = {
+ selectedObject: navigationService.getNavigation()
+ };
+
// Listen for changes in navigation state.
navigationService.addListener(setNavigation);
+ // Also listen for changes which come from the tree
+ $scope.$watch("treeModel.selectedObject", setNavigation);
+
// Clean up when the scope is destroyed
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);
});
- return {
- /**
- * Navigate to a specific domain object.
- *
- * This is exposed so that the browse tree has a callback
- * to invoke when the user clicks on a new object to navigate
- * to it.
- *
- * @method
- * @memberof BrowseController
- * @param {DomainObject} domainObject the object to navigate to
- */
- setNavigation: function (domainObject) {
- navigationService.setNavigation(domainObject);
- }
- };
}
return BrowseController;
diff --git a/platform/commonUI/general/res/templates/tree-node.html b/platform/commonUI/general/res/templates/tree-node.html
index bde748408f..27416597e4 100644
--- a/platform/commonUI/general/res/templates/tree-node.html
+++ b/platform/commonUI/general/res/templates/tree-node.html
@@ -8,9 +8,9 @@
+ ng-model="ngModel"
+ ng-click="ngModel.selectedObject = domainObject"
+ ng-class="{selected: treeNode.isSelected()}">
diff --git a/platform/commonUI/general/res/templates/tree.html b/platform/commonUI/general/res/templates/tree.html
index 16ffb7d936..46a3259634 100644
--- a/platform/commonUI/general/res/templates/tree.html
+++ b/platform/commonUI/general/res/templates/tree.html
@@ -1,6 +1,8 @@
diff --git a/platform/commonUI/general/src/TreeNodeController.js b/platform/commonUI/general/src/TreeNodeController.js
index 9310b212c1..18697748e8 100644
--- a/platform/commonUI/general/src/TreeNodeController.js
+++ b/platform/commonUI/general/src/TreeNodeController.js
@@ -29,9 +29,9 @@ define(
* expand-to-show-navigated-object behavior.)
* @constructor
*/
- function TreeNodeController($scope, navigationService) {
- var navigatedObject = navigationService.getNavigation(),
- isNavigated = false,
+ function TreeNodeController($scope) {
+ var selectedObject = ($scope.ngModel || {}).selectedObject,
+ isSelected = false,
hasBeenExpanded = false;
// Look up the id for a domain object. A convenience
@@ -73,7 +73,7 @@ define(
// Check if the navigated object is in the subtree of this
// node's domain object, by comparing the paths reported
// by their context capability.
- function isOnNavigationPath(nodeObject, navObject) {
+ function isOnSelectionPath(nodeObject, navObject) {
var nodeContext = nodeObject &&
nodeObject.getCapability('context'),
navContext = navObject &&
@@ -92,19 +92,19 @@ define(
// Consider the currently-navigated object and update
// parameters which support display.
- function checkNavigation() {
+ function checkSelection() {
var nodeObject = $scope.domainObject;
// Check if we are the navigated object. Check the parent
// as well to make sure we are the same instance of the
// navigated object.
- isNavigated =
- idsEqual(nodeObject, navigatedObject) &&
- idsEqual(parentOf(nodeObject), parentOf(navigatedObject));
+ isSelected =
+ idsEqual(nodeObject, selectedObject) &&
+ idsEqual(parentOf(nodeObject), parentOf(selectedObject));
// Expand if necessary (if the navigated object will
// be in this node's subtree)
- if (isOnNavigationPath(nodeObject, navigatedObject) &&
+ if (isOnSelectionPath(nodeObject, selectedObject) &&
$scope.toggle !== undefined) {
$scope.toggle.setState(true);
hasBeenExpanded = true;
@@ -113,17 +113,14 @@ define(
// Callback for the navigation service; track the currently
// navigated object and update display parameters as needed.
- function setNavigation(object) {
- navigatedObject = object;
- checkNavigation();
+ function setSelection(object) {
+ selectedObject = object;
+ checkSelection();
}
// Listen for changes which will effect display parameters
- navigationService.addListener(setNavigation);
- $scope.$on("$destroy", function () {
- navigationService.removeListener(setNavigation);
- });
- $scope.$watch("domainObject", checkNavigation);
+ $scope.$watch("ngModel.selectedObject", setSelection);
+ $scope.$watch("domainObject", checkSelection);
return {
/**
@@ -143,11 +140,13 @@ define(
},
/**
* Check whether or not the domain object represented by
- * this tree node is currently the navigated object.
- * @returns true if this is the navigated object
+ * this tree node should be highlighted.
+ * An object will be highlighted if it matches
+ * ngModel.selectedObject
+ * @returns true if this should be highlighted
*/
- isNavigated: function () {
- return isNavigated;
+ isSelected: function () {
+ return isSelected;
}
};
}
diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js
index f266535a35..db3ca467cf 100644
--- a/platform/representation/src/MCTRepresentation.js
+++ b/platform/representation/src/MCTRepresentation.js
@@ -141,7 +141,12 @@ define(
// Two-way bind key and parameters, get the represented domain
// object as "mct-object"
- scope: { key: "=", domainObject: "=mctObject", parameters: "=" }
+ scope: {
+ key: "=",
+ domainObject: "=mctObject",
+ ngModel: "=",
+ parameters: "="
+ }
};
}