diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index 9dc59c1764..29fb15fafb 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -147,6 +147,26 @@ define( telemetrySubscriber.subscribe(domainObject, updateValues); } + // Position a panel after a drop event + function handleDrop(e, id, position) { + // Make sure there is a "elements" field in the + // view configuration. + $scope.configuration.elements = + $scope.configuration.elements || {}; + // Store the position of this element. + $scope.configuration.elements[id] = { + position: [ + Math.floor(position.x / gridSize[0]), + Math.floor(position.y / gridSize[1]) + ], + dimensions: DEFAULT_DIMENSIONS + }; + // Mark change as persistable + if ($scope.commit) { + $scope.commit("Dropped a frame."); + } + } + // Position panes when the model field changes $scope.$watch("model", lookupPanels); @@ -156,6 +176,9 @@ define( // Free up subscription on destroy $scope.$on("$destroy", releaseSubscription); + // Position panes where they are dropped + $scope.$on("mctDrop", handleDrop); + // Initialize styles (position etc.) for cells refreshCellStyles();