mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
[Locator] Don't reset root unnecessarily
...as this will trigger a refresh of the mct-representation for the tree, which will in turn create a new mct-tree instance, resulting in any expanded/collapsed state being lost. Fixes #1008.
This commit is contained in:
parent
eb3b6e5eca
commit
10d2794bb7
@ -50,7 +50,7 @@ define(
|
|||||||
$scope.rootObject =
|
$scope.rootObject =
|
||||||
(context && context.getRoot()) || $scope.rootObject;
|
(context && context.getRoot()) || $scope.rootObject;
|
||||||
}, 0);
|
}, 0);
|
||||||
} else if (!contextRoot) {
|
} else if (!contextRoot && !$scope.rootObject) {
|
||||||
//If no context root is available, default to the root
|
//If no context root is available, default to the root
|
||||||
// object
|
// object
|
||||||
$scope.rootObject = undefined;
|
$scope.rootObject = undefined;
|
||||||
|
@ -138,23 +138,34 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("when no context is available", function () {
|
describe("when no context is available", function () {
|
||||||
var defaultRoot = "DEFAULT_ROOT";
|
var defaultRoot = "DEFAULT_ROOT";
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
mockContext.getRoot.andReturn(undefined);
|
|
||||||
getObjectsPromise.then.andCallFake(function (callback) {
|
|
||||||
callback({'ROOT': defaultRoot});
|
|
||||||
});
|
|
||||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("provides a default context where none is available", function () {
|
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
|
||||||
mockTimeout.mostRecentCall.args[0]();
|
|
||||||
expect(mockScope.rootObject).toBe(defaultRoot);
|
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockContext.getRoot.andReturn(undefined);
|
||||||
|
getObjectsPromise.then.andCallFake(function (callback) {
|
||||||
|
callback({'ROOT': defaultRoot});
|
||||||
});
|
});
|
||||||
|
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("provides a default context where none is available", function () {
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
expect(mockScope.rootObject).toBe(defaultRoot);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not issue redundant requests for the root object", function () {
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](undefined);
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
expect(mockObjectService.getObjects.calls.length)
|
||||||
|
.toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user