mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[Gestures] Browse/Edit Composition
Disallows drag and drop during browse mode, unless dragging and dropping into a folder view. Allows drag and drop into a layout view only in edit mode also. Can be unit tested now. WTD-11.
This commit is contained in:
parent
dc85d3c191
commit
a8488a92d9
@ -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,10 @@ define(
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
// Informs user that drag and drop is not allowed.
|
||||
// window.alert("Cannot drag and drop objects during browse mode.");
|
||||
}
|
||||
}
|
||||
|
||||
// We can only handle drops if we have access to actions...
|
||||
|
@ -132,16 +132,33 @@ define(
|
||||
expect(mockEvent.dataTransfer.dropEffect).toBeDefined();
|
||||
});
|
||||
|
||||
it("invokes compose on drop", function () {
|
||||
it("invokes compose on drop in browse", function () {
|
||||
callbacks.dragover(mockEvent);
|
||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||
key: 'compose',
|
||||
selectedObject: mockDraggedObject
|
||||
});
|
||||
callbacks.drop(mockEvent);
|
||||
expect(mockCompose.perform).toHaveBeenCalled();
|
||||
mockDomainObject.useCapability('browse');
|
||||
var mockDomainObjectType = mockDomainObject.getModel().type;
|
||||
// if (mockDomainObjectType === 'folder' || mockDomainObject.hasCapability('editor') {
|
||||
expect((mockCompose.perform)).toHaveBeenCalled();
|
||||
// }
|
||||
});
|
||||
|
||||
// it("invokes compose on drop in edit", function () {
|
||||
// callbacks.dragover(mockEvent);
|
||||
// expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||
// key: 'compose',
|
||||
// selectedObject: mockDraggedObject
|
||||
// });
|
||||
// callbacks.drop(mockEvent);
|
||||
// mockDomainObject.useCapability('editor');
|
||||
// if (mockDomainObjectType === 'folder' || mockDomainObject.hasCapability('editor') {
|
||||
// expect((mockCompose.perform)).toHaveBeenCalled();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
it("broadcasts drop position", function () {
|
||||
testRect.left = 42;
|
||||
|
Loading…
Reference in New Issue
Block a user