mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 17:57:04 +00:00
commit
3512018e90
@ -92,7 +92,13 @@ define(
|
||||
|
||||
function drop(e) {
|
||||
var event = (e || {}).originalEvent || e,
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE);
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||
domainObjectType = domainObject.getModel().type;
|
||||
|
||||
// If currently in edit mode allow drag and drop gestures to the
|
||||
// domain object. An exception to this is folders which have drop
|
||||
// gestures in browse mode.
|
||||
if (domainObjectType === 'folder' || domainObject.hasCapability('editor')) {
|
||||
|
||||
// Handle the drop; add the dropped identifier to the
|
||||
// destination domain object's composition, and persist
|
||||
@ -102,7 +108,8 @@ define(
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// TODO: Alert user if drag and drop is not allowed
|
||||
}
|
||||
|
||||
// We can only handle drops if we have access to actions...
|
||||
|
@ -132,7 +132,10 @@ define(
|
||||
expect(mockEvent.dataTransfer.dropEffect).toBeDefined();
|
||||
});
|
||||
|
||||
it("invokes compose on drop", function () {
|
||||
it("invokes compose on drop in edit mode", function () {
|
||||
// Set the mockDomainObject to have the editor capability
|
||||
mockDomainObject.hasCapability.andReturn(true);
|
||||
|
||||
callbacks.dragover(mockEvent);
|
||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||
key: 'compose',
|
||||
@ -143,7 +146,41 @@ define(
|
||||
});
|
||||
|
||||
|
||||
it("broadcasts drop position", function () {
|
||||
it("does not invoke compose on drop in browse mode for non-folders", function () {
|
||||
// Set the mockDomainObject to not have the editor capability
|
||||
mockDomainObject.hasCapability.andReturn(false);
|
||||
// Set the mockDomainObject to not have a type of folder
|
||||
mockDomainObject.getModel.andReturn({type: 'notAFolder'});
|
||||
|
||||
callbacks.dragover(mockEvent);
|
||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||
key: 'compose',
|
||||
selectedObject: mockDraggedObject
|
||||
});
|
||||
callbacks.drop(mockEvent);
|
||||
expect(mockCompose.perform).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
it("invokes compose on drop in browse mode for folders", function () {
|
||||
// Set the mockDomainObject to not have the editor capability
|
||||
mockDomainObject.hasCapability.andReturn(false);
|
||||
// Set the mockDomainObject to have a type of folder
|
||||
mockDomainObject.getModel.andReturn({type: 'folder'});
|
||||
|
||||
callbacks.dragover(mockEvent);
|
||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||
key: 'compose',
|
||||
selectedObject: mockDraggedObject
|
||||
});
|
||||
callbacks.drop(mockEvent);
|
||||
expect(mockCompose.perform).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("broadcasts drop position (in edit mode)", function () {
|
||||
// Set the mockDomainObject to have the editor capability
|
||||
mockDomainObject.hasCapability.andReturn(true);
|
||||
|
||||
testRect.left = 42;
|
||||
testRect.top = 36;
|
||||
mockEvent.pageX = 52;
|
||||
|
Loading…
x
Reference in New Issue
Block a user