From 4b786d3536e7f4223fd791ab9b9652b791b4c9cb Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 18 Apr 2016 16:42:22 -0700 Subject: [PATCH] Removed sysouts --- .../regions/src/InspectorController.js | 12 +------- .../representation/src/MCTRepresentation.js | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/platform/commonUI/regions/src/InspectorController.js b/platform/commonUI/regions/src/InspectorController.js index 3c0df1e839..32b0e1903d 100644 --- a/platform/commonUI/regions/src/InspectorController.js +++ b/platform/commonUI/regions/src/InspectorController.js @@ -32,8 +32,7 @@ define( */ function InspectorController($scope, policyService) { var domainObject = $scope.domainObject, - typeCapability = domainObject.getCapability('type'), - listener; + typeCapability = domainObject.getCapability('type'); /** * Filters region parts to only those allowed by region policies @@ -51,16 +50,7 @@ define( $scope.regions = filterRegions(typeCapability.getDefinition().inspector || new InspectorRegion()); } - //Listen for changes to object status that might necessitate - // recalculation of screen regions. - //listener = - // domainObject.getCapability("status").listen(setRegions); - setRegions(); - - $scope.$on("$destroy", function() { - listener(); - }) } return InspectorController; diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index a120507f27..4283a30a4a 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -241,18 +241,25 @@ define( // Also update when the represented domain object changes // (to a different object) $scope.$watch("domainObject", refresh); - $scope.$watch("domainObject", function(domainObject) { - if (domainObject){ - if (statusListener) { - statusListener(); - listeners--; - console.log("directive listeners " + listeners); - } - statusListener = domainObject.getCapability("status").listen(refresh); - listeners++; - console.log("directive listeners " + listeners); + + function listenForStatusChange(object) { + if (statusListener) { + statusListener(); + } + statusListener = object.getCapability("status").listen(refresh); + } + + /** + * Add a listener for status changes to the object itself. + */ + $scope.$watch("domainObject", function(domainObject, oldDomainObject) { + if (domainObject!==oldDomainObject){ + listenForStatusChange(domainObject); } }); + if ($scope.domainObject) { + listenForStatusChange($scope.domainObject); + } // Finally, also update when there is a new version of that // same domain object; these changes should be tracked in the @@ -265,8 +272,6 @@ define( $scope.$on("$destroy", function () { if (statusListener) { statusListener(); - listeners--; - console.log("directive listeners " + listeners); } });