mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +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:
@ -163,8 +163,8 @@ define(
|
|||||||
subscribe($scope.domainObject);
|
subscribe($scope.domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position a panel after a drop event
|
// Add an element to this view
|
||||||
function handleDrop(e, id, position) {
|
function addElement(element) {
|
||||||
// Ensure that configuration field is populated
|
// Ensure that configuration field is populated
|
||||||
$scope.configuration = $scope.configuration || {};
|
$scope.configuration = $scope.configuration || {};
|
||||||
// Make sure there is a "elements" field in the
|
// Make sure there is a "elements" field in the
|
||||||
@ -172,7 +172,23 @@ define(
|
|||||||
$scope.configuration.elements =
|
$scope.configuration.elements =
|
||||||
$scope.configuration.elements || [];
|
$scope.configuration.elements || [];
|
||||||
// Store the position of this element.
|
// 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",
|
type: "fixed.telemetry",
|
||||||
x: Math.floor(position.x / gridSize[0]),
|
x: Math.floor(position.x / gridSize[0]),
|
||||||
y: Math.floor(position.y / gridSize[1]),
|
y: Math.floor(position.y / gridSize[1]),
|
||||||
@ -180,22 +196,14 @@ define(
|
|||||||
width: DEFAULT_DIMENSIONS[0],
|
width: DEFAULT_DIMENSIONS[0],
|
||||||
height: DEFAULT_DIMENSIONS[1]
|
height: DEFAULT_DIMENSIONS[1]
|
||||||
});
|
});
|
||||||
// Mark change as persistable
|
|
||||||
if ($scope.commit) {
|
|
||||||
$scope.commit("Dropped an element.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Track current selection state
|
// Track current selection state
|
||||||
if (Array.isArray($scope.selection)) {
|
if (Array.isArray($scope.selection)) {
|
||||||
selection = new LayoutSelection(
|
selection = new LayoutSelection(
|
||||||
$scope.selection,
|
$scope.selection,
|
||||||
new FixedProxy(
|
new FixedProxy(addElement, $q, dialogService)
|
||||||
$scope.configuration,
|
|
||||||
$q,
|
|
||||||
dialogService,
|
|
||||||
refreshElements
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,13 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Proxy for configuring a fixed position view via the toolbar.
|
* Proxy for configuring a fixed position view via the toolbar.
|
||||||
* @constructor
|
* @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);
|
var factory = new ElementFactory(dialogService);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -20,9 +24,6 @@ define(
|
|||||||
add: function (type) {
|
add: function (type) {
|
||||||
// Place a configured element into the view configuration
|
// Place a configured element into the view configuration
|
||||||
function addElement(element) {
|
function addElement(element) {
|
||||||
// Ensure that there is an Elements array
|
|
||||||
configuration.elements = configuration.elements || [];
|
|
||||||
|
|
||||||
// Configure common properties of the element
|
// Configure common properties of the element
|
||||||
element.x = element.x || 0;
|
element.x = element.x || 0;
|
||||||
element.y = element.y || 0;
|
element.y = element.y || 0;
|
||||||
@ -31,10 +32,7 @@ define(
|
|||||||
element.type = type;
|
element.type = type;
|
||||||
|
|
||||||
// Finally, add it to the view's configuration
|
// Finally, add it to the view's configuration
|
||||||
configuration.elements.push(element);
|
addElementCallback(element);
|
||||||
|
|
||||||
// Let the view know it needs to refresh
|
|
||||||
callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defer creation to the factory
|
// Defer creation to the factory
|
||||||
|
Reference in New Issue
Block a user