Telemetry Panels now created correctly

This commit is contained in:
Henry
2015-11-12 10:22:37 -08:00
parent f0e293a513
commit 16c3229a84
5 changed files with 45 additions and 29 deletions

View File

@@ -22,7 +22,7 @@
"key": "drop",
"implementation": "gestures/DropGesture.js",
"depends": [ "dndService", "$q", "navigationService",
"objectService", "instantiate" ]
"objectService", "instantiate", "typeService" ]
},
{
"key": "menu",

View File

@@ -42,7 +42,7 @@ define(
* @param {DomainObject} domainObject the domain object whose
* composition should be modified as a result of the drop.
*/
function DropGesture(dndService, $q, navigationService, objectService, instantiate, element, domainObject) {
function DropGesture(dndService, $q, navigationService, objectService, instantiate, typeService, element, domainObject) {
var actionCapability = domainObject.getCapability('action'),
editableDomainObject,
action; // Action for the drop, when it occurs
@@ -108,16 +108,28 @@ define(
}
function createVirtualPanel(base, overlayId){
var model = {
name: 'New telemetry panel',
type: 'telemetry.panel',
composition: [base.getId(), overlayId],
location: base.getModel().location
},
id = uuid();
var typeKey = 'telemetry.panel',
type = typeService.getType(typeKey),
model = type.getInitialModel(),
id = uuid(),
newPanel = undefined;
model.type = typeKey;
model.name = 'New telemetry panel';
newPanel = instantiate(model, id);
[base.getId(), overlayId].forEach(function(id){
newPanel.getCapability('composition').add(id)
});
newPanel.getCapability('location').setPrimaryLocation(base.getCapability('location').getContextualLocation());
//ObjectService is wrapped by a decorator which is obscuring
// the newObject method.
return instantiate(model, id);
var virtualPanel = new EditableDomainObject(newPanel, $q);
virtualPanel.setOriginalObject(base);
return virtualPanel;
}
@@ -137,8 +149,7 @@ define(
// the change.
if (id) {
if (shouldCreateVirtualPanel(domainObject)){
virtualObj = new EditableDomainObject(createVirtualPanel(domainObject, id));
navigationService.setNavigation(virtualObj);
navigationService.setNavigation(createVirtualPanel(domainObject, id));
broadcastDrop(id, event);
} else {
$q.when(action && action.perform()).then(function (result) {