[Inspector] Cleanup

Some more undefined checking. Changed unnecissary scope
variable into a regular one.
This commit is contained in:
slhale 2015-08-26 16:31:02 -07:00
parent 7a69bffb4a
commit 7b9a886beb

View File

@ -38,11 +38,10 @@ define(
function ObjectInspectorController($scope, objectService) { function ObjectInspectorController($scope, objectService) {
$scope.primaryParents = []; $scope.primaryParents = [];
$scope.contextutalParents = []; $scope.contextutalParents = [];
//$scope.isLink = false;
// Gets an array of the contextual parents/anscestors of the selected object // Gets an array of the contextual parents/anscestors of the selected object
function getContextualPath() { function getContextualPath() {
var currentObj = $scope.ngModel.selectedObject, var currentObj = $scope.ngModel && $scope.ngModel.selectedObject,
currentParent, currentParent,
parents = []; parents = [];
@ -84,23 +83,23 @@ define(
getPrimaryPath(next); getPrimaryPath(next);
}); });
} }
} }
// Gets the metadata for the selected object // Gets the metadata for the selected object
function getMetadata() { function getMetadata() {
$scope.metadata = $scope.ngModel.selectedObject && $scope.metadata = $scope.ngModel && $scope.ngModel.selectedObject &&
$scope.ngModel.selectedObject.hasCapability('metadata') && $scope.ngModel.selectedObject.hasCapability('metadata') &&
$scope.ngModel.selectedObject.useCapability('metadata'); $scope.ngModel.selectedObject.useCapability('metadata');
} }
// Set scope variables when the selected object changes // Set scope variables when the selected object changes
$scope.$watch('ngModel.selectedObject', function () { $scope.$watch('ngModel.selectedObject', function () {
$scope.isLink = $scope.ngModel.selectedObject && var isLink = $scope && $scope.ngModel &&
$scope.ngModel.selectedObject &&
$scope.ngModel.selectedObject.hasCapability('location') && $scope.ngModel.selectedObject.hasCapability('location') &&
$scope.ngModel.selectedObject.getCapability('location').isLink(); $scope.ngModel.selectedObject.getCapability('location').isLink();
if ($scope.isLink) { if (isLink) {
getPrimaryPath(); getPrimaryPath();
getContextualPath(); getContextualPath();
} else { } else {