mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
Merge branch 'timeline-highlight-767'
This commit is contained in:
commit
cbea842c8b
@ -102,21 +102,37 @@ define(
|
||||
|
||||
function link(scope, element, attrs) {
|
||||
// Lookup swimlane by evaluating this attribute
|
||||
function swimlane() {
|
||||
function lookupSwimlane() {
|
||||
return scope.$eval(attrs.mctSwimlaneDrop);
|
||||
}
|
||||
// Handle dragover
|
||||
element.on('dragover', function (e) {
|
||||
dragOver(e, element, swimlane());
|
||||
var swimlane = lookupSwimlane(),
|
||||
highlight = swimlane.highlight(),
|
||||
highlightBottom = swimlane.highlightBottom();
|
||||
|
||||
dragOver(e, element, swimlane);
|
||||
|
||||
if (highlightBottom !== swimlane.highlightBottom() ||
|
||||
highlight !== swimlane.highlight()) {
|
||||
scope.$apply();
|
||||
}
|
||||
});
|
||||
// Handle drops
|
||||
element.on('drop', function (e) {
|
||||
drop(e, element, swimlane());
|
||||
drop(e, element, lookupSwimlane());
|
||||
scope.$apply();
|
||||
});
|
||||
// Clear highlights when drag leaves this swimlane
|
||||
element.on('dragleave', function () {
|
||||
swimlane().highlight(false);
|
||||
swimlane().highlightBottom(false);
|
||||
var swimlane = lookupSwimlane(),
|
||||
wasHighlighted = swimlane.highlight() ||
|
||||
swimlane.highlightBottom();
|
||||
swimlane.highlight(false);
|
||||
swimlane.highlightBottom(false);
|
||||
if (wasHighlighted) {
|
||||
scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ define(
|
||||
'dndService',
|
||||
['setData', 'getData', 'removeData']
|
||||
);
|
||||
mockScope = jasmine.createSpyObj('$scope', ['$eval']);
|
||||
mockScope = jasmine.createSpyObj('$scope', ['$eval', '$apply']);
|
||||
mockElement = jasmine.createSpyObj('element', ['on']);
|
||||
testAttrs = { mctSwimlaneDrop: "mockSwimlane" };
|
||||
mockSwimlane = jasmine.createSpyObj(
|
||||
@ -118,6 +118,7 @@ define(
|
||||
|
||||
expect(mockSwimlane.highlight).toHaveBeenCalledWith(true);
|
||||
expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false);
|
||||
expect(mockScope.$apply).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updates bottom highlights on drag over", function () {
|
||||
@ -128,6 +129,7 @@ define(
|
||||
|
||||
expect(mockSwimlane.highlight).toHaveBeenCalledWith(false);
|
||||
expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(true);
|
||||
expect(mockScope.$apply).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("respects swimlane's allowDropIn response", function () {
|
||||
@ -157,12 +159,15 @@ define(
|
||||
it("notifies swimlane on drop", function () {
|
||||
handlers.drop(testEvent);
|
||||
expect(mockSwimlane.drop).toHaveBeenCalledWith('abc', 'someDomainObject');
|
||||
expect(mockScope.$apply).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("clears highlights when drag leaves", function () {
|
||||
mockSwimlane.highlight.andReturn(true);
|
||||
handlers.dragleave();
|
||||
expect(mockSwimlane.highlight).toHaveBeenCalledWith(false);
|
||||
expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false);
|
||||
expect(mockScope.$apply).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user