mirror of
https://github.com/nasa/openmct.git
synced 2025-06-11 11:51:40 +00:00
[Timeline] Remove NULL_ACTION, clarify logic
Per code review feedback, https://github.com/nasa/openmct/pull/775/files#r57229759
This commit is contained in:
parent
cb655d486b
commit
c13231b8e8
@ -26,12 +26,6 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var NULL_ACTION = {
|
|
||||||
perform: function () {
|
|
||||||
return Promise.resolve(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles drop (from drag-and-drop) initiated changes to a swimlane.
|
* Handles drop (from drag-and-drop) initiated changes to a swimlane.
|
||||||
* @constructor
|
* @constructor
|
||||||
@ -112,15 +106,7 @@ define(
|
|||||||
var actionCapability =
|
var actionCapability =
|
||||||
targetObject.getCapability('action'),
|
targetObject.getCapability('action'),
|
||||||
actionKey = droppedObject.hasCapability('editor') ?
|
actionKey = droppedObject.hasCapability('editor') ?
|
||||||
'move' : 'link',
|
'move' : 'link';
|
||||||
droppedContext = droppedObject.getCapability('context'),
|
|
||||||
droppedParent =
|
|
||||||
droppedContext && droppedContext.getParent(),
|
|
||||||
droppedParentId = droppedParent && droppedParent.getId();
|
|
||||||
|
|
||||||
if (targetObject.getId() === droppedParentId) {
|
|
||||||
return NULL_ACTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return actionCapability && actionCapability.getActions({
|
return actionCapability && actionCapability.getActions({
|
||||||
key: actionKey,
|
key: actionKey,
|
||||||
@ -155,12 +141,27 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canDrop(targetObject, droppedObject) {
|
||||||
|
var droppedContext = droppedObject.getCapability('context'),
|
||||||
|
droppedParent =
|
||||||
|
droppedContext && droppedContext.getParent(),
|
||||||
|
droppedParentId = droppedParent && droppedParent.getId();
|
||||||
|
|
||||||
|
return (targetObject.getId() === droppedParentId) ||
|
||||||
|
!!chooseAction(targetObject, droppedObject);
|
||||||
|
}
|
||||||
|
|
||||||
function drop(domainObject, targetObject, indexOffset) {
|
function drop(domainObject, targetObject, indexOffset) {
|
||||||
var action = chooseAction(targetObject, domainObject);
|
var action = chooseAction(targetObject, domainObject);
|
||||||
return action.perform().then(function () {
|
|
||||||
|
function changeIndex() {
|
||||||
var id = domainObject.getId();
|
var id = domainObject.getId();
|
||||||
return insert(id, targetObject, indexOffset);
|
return insert(id, targetObject, indexOffset);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return action ?
|
||||||
|
action.perform().then(changeIndex) :
|
||||||
|
changeIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -175,7 +176,7 @@ define(
|
|||||||
return inEditMode() &&
|
return inEditMode() &&
|
||||||
!pathContains(swimlane, id) &&
|
!pathContains(swimlane, id) &&
|
||||||
!contains(swimlane, id) &&
|
!contains(swimlane, id) &&
|
||||||
!!chooseAction(swimlane.domainObject, domainObject);
|
canDrop(swimlane.domainObject, domainObject);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Check if a drop-after should be allowed for this swimlane,
|
* Check if a drop-after should be allowed for this swimlane,
|
||||||
@ -190,7 +191,7 @@ define(
|
|||||||
return inEditMode() &&
|
return inEditMode() &&
|
||||||
target &&
|
target &&
|
||||||
!pathContains(target, id) &&
|
!pathContains(target, id) &&
|
||||||
!!chooseAction(target.domainObject, domainObject);
|
canDrop(target.domainObject, domainObject);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Drop the provided domain object into a timeline. This is
|
* Drop the provided domain object into a timeline. This is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user