[Inspector] Use metadata capability

Instead of manually getting each entry for
the object inspector, just get the selected
object's metadata capability.
Still need to manually get the parents. #73.
This commit is contained in:
slhale 2015-08-24 12:32:26 -07:00
parent 57e3c2554d
commit d877ee3ce3
2 changed files with 18 additions and 36 deletions

View File

@ -23,23 +23,14 @@
<span class="ui-symbol info-icon"> <span class="ui-symbol info-icon">
G G
</span> </span>
<ul> <ul>
<li> <li ng-repeat="data in metadata">
<em>Name </em> <em>{{ data.name }}</em>
{{ ngModel.selectedObject.getModel().name }} {{ data.value }}
</li>
<li ng-if='ngModel.selectedObject.getModel().modified !== undefined'>
<em>Last modified </em>
{{ ngModel.selectedObject.getModel().modified }}
</li>
<li>
<em>ID </em>
{{ ngModel.selectedObject.getId() }}
</li> </li>
<li> <li>
<em>Location </em> <em>Location </em>
{{ controller.getPath() }}
<span class="inspector-location" <span class="inspector-location"
ng-repeat="parent in parents"> ng-repeat="parent in parents">
<mct-representation key="'label'" <mct-representation key="'label'"

View File

@ -36,47 +36,38 @@ define(
* @constructor * @constructor
*/ */
function ObjectInspectorController($scope, objectService) { function ObjectInspectorController($scope, objectService) {
$scope.pathString = '';
$scope.parents = []; $scope.parents = [];
// Gets an array of the parents/anscestors of the selected object
function getPath() { function getPath() {
var currentObj = $scope.ngModel.selectedObject, var currentObj = $scope.ngModel.selectedObject,
currentParent, currentParent,
parents = [], parents = [];
pathString = '';
while (currentObj && currentObj.getModel().type !== 'root' && currentObj.hasCapability('context')) { while (currentObj && currentObj.getModel().type !== 'root' && currentObj.hasCapability('context')) {
// Record this object // Record this object
pathString = currentObj.getModel().name + ', ' + pathString;
parents.unshift(currentObj); parents.unshift(currentObj);
// Get the next one up the tree // Get the next one up the tree
currentParent = currentObj.getCapability('context').getParent(); currentParent = currentObj.getCapability('context').getParent();
currentObj = currentParent; currentObj = currentParent;
} }
pathString = pathString.substring(0, pathString.length - 2);
$scope.parents = parents; $scope.parents = parents;
$scope.pathString = pathString;
return [pathString, parents];
} }
return { // Gets the metadata for the selected object
// Sets scope variables, but does not return anything function getMetadata() {
getPath: function () { $scope.metadata = $scope.ngModel.selectedObject &&
getPath(); $scope.ngModel.selectedObject.hasCapability('metadata') &&
}, $scope.ngModel.selectedObject.useCapability('metadata');
}
getPathString: function () {
return getPath()[0]; // Set scope variables when the selected object changes
}, $scope.$watch('ngModel.selectedObject', function () {
getMetadata();
getParents: function () { getPath();
return getPath()[1]; });
}
};
} }
return ObjectInspectorController; return ObjectInspectorController;