mirror of
https://github.com/nasa/openmct.git
synced 2025-04-16 07:26:53 +00:00
[Fixed Position] Select newly-created elements
When elements are added to a fixed position view, select them immediately. WTD-880.
This commit is contained in:
parent
668a1e4534
commit
84e90f6ad1
@ -163,8 +163,8 @@ define(
|
||||
subscribe($scope.domainObject);
|
||||
}
|
||||
|
||||
// Position a panel after a drop event
|
||||
function handleDrop(e, id, position) {
|
||||
// Add an element to this view
|
||||
function addElement(element) {
|
||||
// Ensure that configuration field is populated
|
||||
$scope.configuration = $scope.configuration || {};
|
||||
// Make sure there is a "elements" field in the
|
||||
@ -172,7 +172,23 @@ define(
|
||||
$scope.configuration.elements =
|
||||
$scope.configuration.elements || [];
|
||||
// Store the position of this element.
|
||||
$scope.configuration.elements.push({
|
||||
$scope.configuration.elements.push(element);
|
||||
// Refresh displayed elements
|
||||
refreshElements();
|
||||
// Select the newly-added element
|
||||
if (selection) {
|
||||
selection.select(elementProxies[elementProxies.length - 1]);
|
||||
}
|
||||
// Mark change as persistable
|
||||
if ($scope.commit) {
|
||||
$scope.commit("Dropped an element.");
|
||||
}
|
||||
}
|
||||
|
||||
// Position a panel after a drop event
|
||||
function handleDrop(e, id, position) {
|
||||
// Store the position of this element.
|
||||
addElement({
|
||||
type: "fixed.telemetry",
|
||||
x: Math.floor(position.x / gridSize[0]),
|
||||
y: Math.floor(position.y / gridSize[1]),
|
||||
@ -180,22 +196,14 @@ define(
|
||||
width: DEFAULT_DIMENSIONS[0],
|
||||
height: DEFAULT_DIMENSIONS[1]
|
||||
});
|
||||
// Mark change as persistable
|
||||
if ($scope.commit) {
|
||||
$scope.commit("Dropped an element.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Track current selection state
|
||||
if (Array.isArray($scope.selection)) {
|
||||
selection = new LayoutSelection(
|
||||
$scope.selection,
|
||||
new FixedProxy(
|
||||
$scope.configuration,
|
||||
$q,
|
||||
dialogService,
|
||||
refreshElements
|
||||
)
|
||||
new FixedProxy(addElement, $q, dialogService)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,13 @@ define(
|
||||
/**
|
||||
* Proxy for configuring a fixed position view via the toolbar.
|
||||
* @constructor
|
||||
* @param configuration the view configuration object to manage
|
||||
* @param {Function} addElementCallback callback to invoke when
|
||||
* elements are created
|
||||
* @param $q Angular's $q, for promise-handling
|
||||
* @param {DialogService} dialogService dialog service to use
|
||||
* when adding a new element will require user input
|
||||
*/
|
||||
function FixedProxy(configuration, $q, dialogService, callback) {
|
||||
function FixedProxy(addElementCallback, $q, dialogService) {
|
||||
var factory = new ElementFactory(dialogService);
|
||||
|
||||
return {
|
||||
@ -20,9 +24,6 @@ define(
|
||||
add: function (type) {
|
||||
// Place a configured element into the view configuration
|
||||
function addElement(element) {
|
||||
// Ensure that there is an Elements array
|
||||
configuration.elements = configuration.elements || [];
|
||||
|
||||
// Configure common properties of the element
|
||||
element.x = element.x || 0;
|
||||
element.y = element.y || 0;
|
||||
@ -31,10 +32,7 @@ define(
|
||||
element.type = type;
|
||||
|
||||
// Finally, add it to the view's configuration
|
||||
configuration.elements.push(element);
|
||||
|
||||
// Let the view know it needs to refresh
|
||||
callback();
|
||||
addElementCallback(element);
|
||||
}
|
||||
|
||||
// Defer creation to the factory
|
||||
|
Loading…
x
Reference in New Issue
Block a user