[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">
G
</span>
<ul>
<li>
<em>Name </em>
{{ ngModel.selectedObject.getModel().name }}
</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 ng-repeat="data in metadata">
<em>{{ data.name }}</em>
{{ data.value }}
</li>
<li>
<em>Location </em>
{{ controller.getPath() }}
<span class="inspector-location"
ng-repeat="parent in parents">
<mct-representation key="'label'"

View File

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