mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
[Angular] Avoid infinite digest
Avoid infinite digest loop from LocatorController associated with upgrade to Angular 1.4.4
This commit is contained in:
parent
52c471bd3a
commit
52df7fe1e2
@ -31,7 +31,7 @@
|
|||||||
{
|
{
|
||||||
"key": "LocatorController",
|
"key": "LocatorController",
|
||||||
"implementation": "creation/LocatorController",
|
"implementation": "creation/LocatorController",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope", "$timeout" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "MenuArrowController",
|
"key": "MenuArrowController",
|
||||||
|
@ -33,7 +33,7 @@ define(
|
|||||||
* @memberof platform/commonUI/browse
|
* @memberof platform/commonUI/browse
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function LocatorController($scope) {
|
function LocatorController($scope, $timeout) {
|
||||||
// Populate values needed by the locator control. These are:
|
// Populate values needed by the locator control. These are:
|
||||||
// * rootObject: The top-level object, since we want to show
|
// * rootObject: The top-level object, since we want to show
|
||||||
// the full tree
|
// the full tree
|
||||||
@ -41,9 +41,19 @@ define(
|
|||||||
// used for bi-directional object selection.
|
// used for bi-directional object selection.
|
||||||
function setLocatingObject(domainObject, priorObject) {
|
function setLocatingObject(domainObject, priorObject) {
|
||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability("context");
|
domainObject.getCapability("context"),
|
||||||
|
contextRoot = context && context.getRoot();
|
||||||
|
|
||||||
|
if (contextRoot && contextRoot !== $scope.rootObject) {
|
||||||
|
$scope.rootObject = undefined;
|
||||||
|
// Update the displayed tree on a timeout to avoid
|
||||||
|
// an infinite digest exception.
|
||||||
|
$timeout(function () {
|
||||||
|
$scope.rootObject =
|
||||||
|
(context && context.getRoot()) || $scope.rootObject;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.rootObject = (context && context.getRoot()) || $scope.rootObject;
|
|
||||||
$scope.treeModel.selectedObject = domainObject;
|
$scope.treeModel.selectedObject = domainObject;
|
||||||
$scope.ngModel[$scope.field] = domainObject;
|
$scope.ngModel[$scope.field] = domainObject;
|
||||||
|
|
||||||
@ -52,10 +62,7 @@ define(
|
|||||||
$scope.structure &&
|
$scope.structure &&
|
||||||
$scope.structure.validate) {
|
$scope.structure.validate) {
|
||||||
if (!$scope.structure.validate(domainObject)) {
|
if (!$scope.structure.validate(domainObject)) {
|
||||||
setLocatingObject(
|
setLocatingObject(priorObject, undefined);
|
||||||
$scope.structure.validate(priorObject) ?
|
|
||||||
priorObject : undefined
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user