mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 08:25:31 +00:00
Use instead of to avoid double digest issue (#2346)
This commit is contained in:
parent
1d2ed0398c
commit
08ef932926
@ -65,7 +65,8 @@ define([
|
|||||||
"depends": [
|
"depends": [
|
||||||
"$document",
|
"$document",
|
||||||
"$compile",
|
"$compile",
|
||||||
"$rootScope"
|
"$rootScope",
|
||||||
|
"$timeout"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -44,8 +44,9 @@ define(
|
|||||||
* @memberof platform/commonUI/dialog
|
* @memberof platform/commonUI/dialog
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function OverlayService($document, $compile, $rootScope) {
|
function OverlayService($document, $compile, $rootScope, $timeout) {
|
||||||
this.$compile = $compile;
|
this.$compile = $compile;
|
||||||
|
this.$timeout = $timeout;
|
||||||
|
|
||||||
// Don't include $document and $rootScope directly;
|
// Don't include $document and $rootScope directly;
|
||||||
// avoids https://docs.angularjs.org/error/ng/cpws
|
// avoids https://docs.angularjs.org/error/ng/cpws
|
||||||
@ -93,12 +94,14 @@ define(
|
|||||||
scope.key = key;
|
scope.key = key;
|
||||||
scope.typeClass = typeClass || 't-dialog';
|
scope.typeClass = typeClass || 't-dialog';
|
||||||
|
|
||||||
|
this.$timeout(() => {
|
||||||
// Create the overlay element and add it to the document's body
|
// Create the overlay element and add it to the document's body
|
||||||
element = this.$compile(TEMPLATE)(scope);
|
element = this.$compile(TEMPLATE)(scope);
|
||||||
|
|
||||||
// Append so that most recent dialog is last in DOM. This means the most recent dialog will be on top when
|
// Append so that most recent dialog is last in DOM. This means the most recent dialog will be on top when
|
||||||
// multiple overlays with the same z-index are active.
|
// multiple overlays with the same z-index are active.
|
||||||
this.findBody().append(element);
|
this.findBody().append(element);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dismiss: dismiss
|
dismiss: dismiss
|
||||||
|
@ -35,16 +35,20 @@ define(
|
|||||||
mockTemplate,
|
mockTemplate,
|
||||||
mockElement,
|
mockElement,
|
||||||
mockScope,
|
mockScope,
|
||||||
|
mockTimeout,
|
||||||
overlayService;
|
overlayService;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockDocument = jasmine.createSpyObj("$document", ["find"]);
|
mockDocument = jasmine.createSpyObj("$document", ["find"]);
|
||||||
mockCompile = jasmine.createSpy("$compile");
|
mockCompile = jasmine.createSpy("$compile");
|
||||||
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
|
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
|
||||||
mockBody = jasmine.createSpyObj("body", ["prepend"]);
|
mockBody = jasmine.createSpyObj("body", ["append"]);
|
||||||
mockTemplate = jasmine.createSpy("template");
|
mockTemplate = jasmine.createSpy("template");
|
||||||
mockElement = jasmine.createSpyObj("element", ["remove"]);
|
mockElement = jasmine.createSpyObj("element", ["remove"]);
|
||||||
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
|
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
|
||||||
|
mockTimeout = function (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
mockDocument.find.and.returnValue(mockBody);
|
mockDocument.find.and.returnValue(mockBody);
|
||||||
mockCompile.and.returnValue(mockTemplate);
|
mockCompile.and.returnValue(mockTemplate);
|
||||||
@ -54,7 +58,8 @@ define(
|
|||||||
overlayService = new OverlayService(
|
overlayService = new OverlayService(
|
||||||
mockDocument,
|
mockDocument,
|
||||||
mockCompile,
|
mockCompile,
|
||||||
mockRootScope
|
mockRootScope,
|
||||||
|
mockTimeout
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +72,7 @@ define(
|
|||||||
|
|
||||||
it("adds the templated element to the body", function () {
|
it("adds the templated element to the body", function () {
|
||||||
overlayService.createOverlay("test", {});
|
overlayService.createOverlay("test", {});
|
||||||
expect(mockBody.prepend).toHaveBeenCalledWith(mockElement);
|
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("places the provided model/key in its template's scope", function () {
|
it("places the provided model/key in its template's scope", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user