[New Edit Mode] Fixed positioning of dropped objects #386

This commit is contained in:
Henry 2015-12-09 09:51:00 -08:00
parent aae8f1575d
commit 49579378dd
6 changed files with 25 additions and 5 deletions

View File

@ -92,8 +92,14 @@ define(
}
}
function setEditable(editableDomainObject) {
self.domainObject = editableDomainObject;
scope.model = editableDomainObject.getModel();
}
// Place the "commit" method in the scope
scope.commit = commit;
scope.setEditable = setEditable;
}
// Handle a specific representation of a specific domain object

View File

@ -19,6 +19,7 @@
"type": "telemetry.panel",
"templateUrl": "templates/fixed.html",
"uses": [ "composition" ],
"gestures": [ "drop" ],
"toolbar": {
"sections": [
{

View File

@ -273,12 +273,15 @@ define(
}
// Position a panel after a drop event
function handleDrop(e, id, position) {
function handleDrop(e, id, position, editableDomainObject) {
// Don't handle this event if it has already been handled
// color is set to "" to let the CSS theme determine the default color
if (e.defaultPrevented) {
return;
}
if (editableDomainObject){
$scope.setEditable(editableDomainObject);
}
e.preventDefault();
// Store the position of this element.
addElement({

View File

@ -62,10 +62,15 @@ define(
}
// Position a panel after a drop event
function handleDrop(e, id, position) {
//An editableDomainObject is provided, as the drop may have
// triggered a transition to edit mode.
function handleDrop(e, id, position, editableDomainObject) {
if (e.defaultPrevented) {
return;
}
if (editableDomainObject){
$scope.setEditable(editableDomainObject);
}
// Ensure that configuration field is populated
$scope.configuration = $scope.configuration || {};
// Make sure there is a "panels" field in the

View File

@ -8,6 +8,7 @@
"glyph": "6",
"templateUrl": "templates/plot.html",
"needs": [ "telemetry" ],
"gestures": [ "drop" ],
"priority": "preferred",
"delegation": true
}

View File

@ -45,12 +45,12 @@ define(
function DropGesture(dndService, $q, navigationService, objectService, instantiate, typeService, element, domainObject) {
var actionCapability = domainObject.getCapability('action'),
editableDomainObject,
scope = element && element.scope && element.scope(),
action; // Action for the drop, when it occurs
function broadcastDrop(id, event) {
// Find the relevant scope...
var scope = element && element.scope && element.scope(),
rect;
var rect;
if (scope && scope.$broadcast) {
// Get the representation's bounds, to convert
// drop position
@ -65,7 +65,8 @@ define(
{
x: event.pageX - rect.left,
y: event.pageY - rect.top
}
},
editableDomainObject
);
}
}
@ -148,6 +149,9 @@ define(
if (shouldCreateVirtualPanel(domainObject)){
editableDomainObject = createVirtualPanel(domainObject, id);
navigationService.setNavigation(editableDomainObject);
//Also broadcast the editableDomainObject to
// avoid race condition against non-editable
// version in EditRepresenter
broadcastDrop(id, event);
} else {
$q.when(action && action.perform()).then(function (result) {