Improved handling of virtual panels

This commit is contained in:
Andrew Henry 2015-10-28 12:53:50 -07:00
parent 3e7264d6b8
commit 2539e4008f

View File

@ -69,6 +69,13 @@ define(
); );
} }
} }
function shouldCreateVirtualPanel(domainObject){
//
return domainObject.useCapability('view').filter(function (view){
return view.key==='plot' && domainObject.getModel().type!== 'telemetry.panel'
}).length > 0;
}
function dragOver(e) { function dragOver(e) {
//Refresh domain object on each dragOver to catch external //Refresh domain object on each dragOver to catch external
@ -89,7 +96,7 @@ define(
})[0]; })[0];
//TODO: Fix this. Define an action for creating new //TODO: Fix this. Define an action for creating new
// virtual panel // virtual panel
if (action || selectedObject.getModel().type === 'generator') { if (action || shouldCreateVirtualPanel(domainObject)) {
event.dataTransfer.dropEffect = 'move'; event.dataTransfer.dropEffect = 'move';
// Indicate that we will accept the drag // Indicate that we will accept the drag
@ -136,7 +143,7 @@ define(
// destination domain object's composition, and persist // destination domain object's composition, and persist
// the change. // the change.
if (id) { if (id) {
if (domainObjectType === 'generator'){ if (shouldCreateVirtualPanel(domainObject)){
virtualObj = new EditableDomainObject(createVirtualPanel(domainObject, id)); virtualObj = new EditableDomainObject(createVirtualPanel(domainObject, id));
navigationService.setNavigation(virtualObj); navigationService.setNavigation(virtualObj);
broadcastDrop(id, event); broadcastDrop(id, event);