[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:
@@ -43,7 +43,7 @@ define(
|
|||||||
function DropGesture(dndService, $q, element, domainObject) {
|
function DropGesture(dndService, $q, element, domainObject) {
|
||||||
var actionCapability = domainObject.getCapability('action'),
|
var actionCapability = domainObject.getCapability('action'),
|
||||||
action; // Action for the drop, when it occurs
|
action; // Action for the drop, when it occurs
|
||||||
|
|
||||||
function broadcastDrop(id, event) {
|
function broadcastDrop(id, event) {
|
||||||
// Find the relevant scope...
|
// Find the relevant scope...
|
||||||
var scope = element && element.scope && element.scope(),
|
var scope = element && element.scope && element.scope(),
|
||||||
@@ -92,17 +92,26 @@ define(
|
|||||||
|
|
||||||
function drop(e) {
|
function drop(e) {
|
||||||
var event = (e || {}).originalEvent || 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;
|
||||||
// Handle the drop; add the dropped identifier to the
|
|
||||||
// destination domain object's composition, and persist
|
// If currently in edit mode allow drag and drop gestures to the
|
||||||
// the change.
|
// domain object. An exception to this is folders which have drop
|
||||||
if (id) {
|
// gestures in browse mode.
|
||||||
$q.when(action && action.perform()).then(function (result) {
|
if (domainObjectType === 'folder' || domainObject.hasCapability('editor')) {
|
||||||
broadcastDrop(id, event);
|
|
||||||
});
|
// 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...
|
// We can only handle drops if we have access to actions...
|
||||||
|
|||||||
@@ -132,15 +132,32 @@ define(
|
|||||||
expect(mockEvent.dataTransfer.dropEffect).toBeDefined();
|
expect(mockEvent.dataTransfer.dropEffect).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("invokes compose on drop", function () {
|
it("invokes compose on drop in browse", function () {
|
||||||
callbacks.dragover(mockEvent);
|
callbacks.dragover(mockEvent);
|
||||||
expect(mockAction.getActions).toHaveBeenCalledWith({
|
expect(mockAction.getActions).toHaveBeenCalledWith({
|
||||||
key: 'compose',
|
key: 'compose',
|
||||||
selectedObject: mockDraggedObject
|
selectedObject: mockDraggedObject
|
||||||
});
|
});
|
||||||
callbacks.drop(mockEvent);
|
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 () {
|
it("broadcasts drop position", function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user