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
@ -43,7 +43,7 @@ define(
|
||||
function DropGesture(dndService, $q, element, domainObject) {
|
||||
var actionCapability = domainObject.getCapability('action'),
|
||||
action; // Action for the drop, when it occurs
|
||||
|
||||
|
||||
function broadcastDrop(id, event) {
|
||||
// Find the relevant scope...
|
||||
var scope = element && element.scope && element.scope(),
|
||||
@ -92,17 +92,26 @@ define(
|
||||
|
||||
function drop(e) {
|
||||
var event = (e || {}).originalEvent || e,
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE);
|
||||
|
||||
// Handle the drop; add the dropped identifier to the
|
||||
// destination domain object's composition, and persist
|
||||
// the change.
|
||||
if (id) {
|
||||
$q.when(action && action.perform()).then(function (result) {
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
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
|
||||
// the change.
|
||||
if (id) {
|
||||
$q.when(action && action.perform()).then(function (result) {
|
||||
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,15 +132,32 @@ 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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user