diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index 3ff94ba974..3cfcae1b87 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -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... diff --git a/platform/representation/test/gestures/DropGestureSpec.js b/platform/representation/test/gestures/DropGestureSpec.js index 023c37c86f..466073098e 100644 --- a/platform/representation/test/gestures/DropGestureSpec.js +++ b/platform/representation/test/gestures/DropGestureSpec.js @@ -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 () {