mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[Representation] Pass ID through dndService
Pass ID as well as full domain object through dndService, to support drag-drop behavior like WTD-988.
This commit is contained in:
parent
818510da14
commit
f9290b8e42
@ -45,12 +45,19 @@ define(
|
||||
domainObject.getId()
|
||||
);
|
||||
|
||||
// Finally, also pass the object instance via the dndService,
|
||||
// so more than the ID can be retrieved (if desired)
|
||||
// Finally, also pass the id object instance via the
|
||||
// dndService, allowing inspection during drag as well
|
||||
// as retrieval of the original domain object.
|
||||
dndService.setData(
|
||||
GestureConstants.MCT_DRAG_TYPE,
|
||||
GestureConstants.MCT_EXTENDED_DRAG_TYPE,
|
||||
domainObject
|
||||
);
|
||||
dndService.setData(
|
||||
GestureConstants.MCT_DRAG_TYPE,
|
||||
domainObject.getId()
|
||||
);
|
||||
|
||||
|
||||
} catch (err) {
|
||||
// Exceptions at this point indicate that the browser
|
||||
// do not fully support drag-and-drop (e.g. if
|
||||
@ -66,6 +73,7 @@ define(
|
||||
function endDrag() {
|
||||
// Clear the drag data after the drag is complete
|
||||
dndService.removeData(GestureConstants.MCT_DRAG_TYPE);
|
||||
dndService.removeData(GestureConstants.MCT_EXTENDED_DRAG_TYPE);
|
||||
}
|
||||
|
||||
// Mark the element as draggable, and handle the dragstart event
|
||||
|
@ -10,6 +10,12 @@ define({
|
||||
* calls.)
|
||||
*/
|
||||
MCT_DRAG_TYPE: 'mct-domain-object-id',
|
||||
/**
|
||||
* The string identifier for the data type used for drag-and-drop
|
||||
* composition of domain objects, by object instance (passed through
|
||||
* the dndService)
|
||||
*/
|
||||
MCT_EXTENDED_DRAG_TYPE: 'mct-domain-object',
|
||||
/**
|
||||
* An estimate for the dimensions of a context menu, used for
|
||||
* positioning.
|
||||
|
@ -65,6 +65,10 @@ define(
|
||||
handlers.dragstart({ dataTransfer: mockDataTransfer });
|
||||
expect(mockDndService.setData).toHaveBeenCalledWith(
|
||||
GestureConstants.MCT_DRAG_TYPE,
|
||||
TEST_ID
|
||||
);
|
||||
expect(mockDndService.setData).toHaveBeenCalledWith(
|
||||
GestureConstants.MCT_EXTENDED_DRAG_TYPE,
|
||||
mockDomainObject
|
||||
);
|
||||
});
|
||||
@ -78,8 +82,12 @@ define(
|
||||
|
||||
// End the drag
|
||||
handlers.dragend({ dataTransfer: mockDataTransfer });
|
||||
|
||||
// Should have removed the data that was attached
|
||||
expect(mockDndService.removeData)
|
||||
.toHaveBeenCalledWith(GestureConstants.MCT_DRAG_TYPE);
|
||||
expect(mockDndService.removeData)
|
||||
.toHaveBeenCalledWith(GestureConstants.MCT_EXTENDED_DRAG_TYPE);
|
||||
});
|
||||
|
||||
it("logs a warning if dataTransfer cannot be set", function () {
|
||||
|
Loading…
Reference in New Issue
Block a user