mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 09:08:43 +00:00
[Timeline] Handle drops for reordering
...as these would be disallowed by Move, normally.
This commit is contained in:
@ -110,14 +110,26 @@ define(
|
|||||||
// Choose an appropriate composition action for the drag-and-drop
|
// Choose an appropriate composition action for the drag-and-drop
|
||||||
function chooseAction(targetObject, droppedObject) {
|
function chooseAction(targetObject, droppedObject) {
|
||||||
var actionCapability =
|
var actionCapability =
|
||||||
targetObject.getCapability('action'),
|
targetObject.getCapability('action'),
|
||||||
actionKey = droppedObject.hasCapability('editor') ?
|
actionKey = droppedObject.hasCapability('editor') ?
|
||||||
'move' : 'link',
|
'move' : 'link',
|
||||||
actions = actionCapability && actionCapability.getActions({
|
droppedContext = droppedObject.getCapability('context'),
|
||||||
key: actionKey,
|
droppedParent =
|
||||||
selectedObject: droppedObject
|
droppedContext && droppedContext.getParent(),
|
||||||
});
|
droppedParentId = droppedParent && droppedParent.getId();
|
||||||
return actions[0];
|
|
||||||
|
if (targetObject.getId() === droppedParentId) {
|
||||||
|
return {
|
||||||
|
perform: function () {
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionCapability && actionCapability.getActions({
|
||||||
|
key: actionKey,
|
||||||
|
selectedObject: droppedObject
|
||||||
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose an index for insertion in a domain object's composition
|
// Choose an index for insertion in a domain object's composition
|
||||||
@ -135,9 +147,10 @@ define(
|
|||||||
function insert(id, target, indexOffset) {
|
function insert(id, target, indexOffset) {
|
||||||
var myId = swimlane.domainObject.getId();
|
var myId = swimlane.domainObject.getId();
|
||||||
return doMutate(target, function (model) {
|
return doMutate(target, function (model) {
|
||||||
model.composition = model.composition.filter(function (i) {
|
model.composition =
|
||||||
return i !== id;
|
model.composition.filter(function (compId) {
|
||||||
});
|
return compId !== id;
|
||||||
|
});
|
||||||
model.composition.splice(
|
model.composition.splice(
|
||||||
chooseTargetIndex(myId, indexOffset, model.composition),
|
chooseTargetIndex(myId, indexOffset, model.composition),
|
||||||
0,
|
0,
|
||||||
|
Reference in New Issue
Block a user