mirror of
https://github.com/nasa/openmct.git
synced 2024-12-29 17:38:53 +00:00
[Views] Broadcast event on drop
Broadcast an event when drag-drop domain object composition occurs, such that the view in question may utilize the drop coordinates (e.g. to position elements in a layout or fixed position view.) WTD-877.
This commit is contained in:
parent
8d6b218646
commit
4190941bfb
@ -20,6 +20,19 @@ define(
|
||||
*/
|
||||
|
||||
function DropGesture($q, element, domainObject) {
|
||||
function broadcastDrop(id, event) {
|
||||
// Find the relevant scope...
|
||||
var scope = element && element.scope && element.scope();
|
||||
if (scope && scope.$broadcast) {
|
||||
// ...and broadcast the event. This allows specific
|
||||
// views to have post-drop behavior which depends on
|
||||
// drop position.
|
||||
scope.$broadcast(
|
||||
GestureConstants.MCT_DROP_EVENT,
|
||||
{ id: id, dropEvent: event }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function doPersist() {
|
||||
var persistence = domainObject.getCapability("persistence");
|
||||
@ -60,6 +73,11 @@ define(
|
||||
}
|
||||
}
|
||||
)).then(function (result) {
|
||||
// Broadcast the drop event if it was successful
|
||||
if (result) {
|
||||
broadcastDrop(id, event);
|
||||
}
|
||||
|
||||
// If mutation was successful, persist the change
|
||||
return result && doPersist();
|
||||
});
|
||||
|
@ -14,5 +14,9 @@ define({
|
||||
* An estimate for the dimensions of a context menu, used for
|
||||
* positioning.
|
||||
*/
|
||||
MCT_MENU_DIMENSIONS: [ 170, 200 ]
|
||||
MCT_MENU_DIMENSIONS: [ 170, 200 ],
|
||||
/**
|
||||
* Identifier for drop events.
|
||||
*/
|
||||
MCT_DROP_EVENT: 'mctDrop'
|
||||
});
|
Loading…
Reference in New Issue
Block a user