From bcf6bbf627c6ab33d233d8c3a76b994cdca3b52b Mon Sep 17 00:00:00 2001 From: slhale Date: Thu, 27 Aug 2015 11:28:27 -0700 Subject: [PATCH] [Inspector] Lay groundwork for multiple selection Created a new ngModel property for inspection which is an array. Currently the array only holds one object at a time, but it can be expanded in the future. --- .../commonUI/browse/src/BrowseController.js | 3 ++ .../general/res/templates/tree-node.html | 2 +- .../controllers/ObjectInspectorController.js | 45 ++++++++++++++++--- .../features/plot/res/templates/plot.html | 5 ++- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index eec5033442..5897b5ff0c 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -143,6 +143,9 @@ define( $scope.treeModel = { selectedObject: navigationService.getNavigation() }; + // Create an array of objects which will allow for multiple selection + // for the object inspector. + $scope.inspectionObjects = [$scope.selectedObject]; // Listen for changes in navigation state. navigationService.addListener(setNavigation); diff --git a/platform/commonUI/general/res/templates/tree-node.html b/platform/commonUI/general/res/templates/tree-node.html index 1228604b2e..681b285f55 100644 --- a/platform/commonUI/general/res/templates/tree-node.html +++ b/platform/commonUI/general/res/templates/tree-node.html @@ -36,7 +36,7 @@ key="'label'" mct-object="domainObject" ng-model="ngModel" - ng-click="ngModel.selectedObject = domainObject" + ng-click="ngModel.selectedObject = domainObject; ngModel.inspectionObjects = []; ngModel.inspectionObjects[0] = domainObject" > diff --git a/platform/commonUI/general/src/controllers/ObjectInspectorController.js b/platform/commonUI/general/src/controllers/ObjectInspectorController.js index 9a1410d3f9..446f5f1174 100644 --- a/platform/commonUI/general/src/controllers/ObjectInspectorController.js +++ b/platform/commonUI/general/src/controllers/ObjectInspectorController.js @@ -41,10 +41,16 @@ define( // Gets an array of the contextual parents/anscestors of the selected object function getContextualPath() { - var currentObj = $scope.ngModel && $scope.ngModel.selectedObject, + var currentObj, currentParent, parents = []; + if ($scope.ngModel && $scope.ngModel.inspectionObjects) { + currentObj = $scope.ngModel.inspectionObjects[0]; + } else { + currentObj = $scope.ngModel && $scope.ngModel.selectedObject; + } + currentParent = currentObj && currentObj.hasCapability('context') && currentObj.getCapability('context').getParent(); @@ -69,7 +75,12 @@ define( // If this the the initial call of this recursive function if (!current) { - current = $scope.ngModel.selectedObject; + if ($scope.ngModel && $scope.ngModel.inspectionObjects) { + current = $scope.ngModel.inspectionObjects[0]; + } else { + current = $scope.ngModel && $scope.ngModel.selectedObject; + } + $scope.primaryParents = []; } @@ -87,9 +98,16 @@ define( // Gets the metadata for the selected object function getMetadata() { - $scope.metadata = $scope.ngModel && $scope.ngModel.selectedObject && - $scope.ngModel.selectedObject.hasCapability('metadata') && - $scope.ngModel.selectedObject.useCapability('metadata'); + // We want to get info from the inspectionObjects, but otherwise just use + // the selectedObject. + if ($scope.ngModel && $scope.ngModel.inspectionObjects && + $scope.ngModel.inspectionObjects[0].hasCapability('metadata')) { + $scope.metadata = $scope.ngModel.inspectionObjects[0].useCapability('metadata'); + } else { + $scope.metadata = $scope.ngModel && $scope.ngModel.selectedObject && + $scope.ngModel.selectedObject.hasCapability('metadata') && + $scope.ngModel.selectedObject.useCapability('metadata'); + } } // Set scope variables when the selected object changes @@ -109,6 +127,23 @@ define( getMetadata(); }); + + $scope.$watch('ngModel.inspectionObjects[0]', function () { + var isLink = $scope && $scope.ngModel && + $scope.ngModel.inspectionObjects && + $scope.ngModel.inspectionObjects[0].hasCapability('location') && + $scope.ngModel.inspectionObjects[0].getCapability('location').isLink(); + + if (isLink) { + getPrimaryPath(); + getContextualPath(); + } else { + $scope.primaryParents = []; + getContextualPath(); + } + + getMetadata(); + }); } return ObjectInspectorController; diff --git a/platform/features/plot/res/templates/plot.html b/platform/features/plot/res/templates/plot.html index ab63c9ca2c..8b66277ea6 100644 --- a/platform/features/plot/res/templates/plot.html +++ b/platform/features/plot/res/templates/plot.html @@ -30,12 +30,15 @@ + ng-click="ngModel.inspectionObjects[0] = telemetryObject"> {{telemetryObject.getModel().name}} + + + {{ log(ngModel.inspectionObjects[0].getModel()); log(ngModel.selectedObject.getModel()) }}