[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:
Victor Woeltjen
2015-02-20 15:47:07 -08:00
parent 668a1e4534
commit 84e90f6ad1
2 changed files with 28 additions and 22 deletions

View File

@ -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