[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:
Shivam Dave
2015-06-18 10:54:51 -07:00
parent dc85d3c191
commit a8488a92d9
2 changed files with 39 additions and 13 deletions

View File

@@ -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...