[Fixed Position] Implement remove

Implement remove button for selected elements in fixed
position view. WTD-879.
This commit is contained in:
Victor Woeltjen
2015-02-18 20:12:55 -08:00
parent f66fb0a32d
commit 5680710c06
5 changed files with 50 additions and 5 deletions

View File

@@ -93,8 +93,28 @@ define(
// Decorate elements in the current configuration
function refreshElements() {
elementProxies = (($scope.configuration || {}).elements || [])
.map(makeProxyElement);
// Cache selection; we are instantiating new proxies
// so we may want to restore this.
var selected = selection && selection.get(),
elements = (($scope.configuration || {}).elements || []),
index = -1; // Start with a 'not-found' value
// Find the selection in the new array
if (selected !== undefined) {
index = elements.indexOf(selected.element);
}
// Create the new proxies...
elementProxies = elements.map(makeProxyElement);
// Clear old selection, and restore if appropriate
if (selection) {
selection.deselect();
if (index > -1) {
selection.select(elementProxies[index]);
}
}
// TODO: Ensure elements for all domain objects?
}

View File

@@ -75,6 +75,11 @@ define(
return (obj === selected) || (obj === proxy);
}
// Getter for current selection
function get() {
return selected;
}
// Start with the proxy selected
selection.push(proxy);
@@ -95,6 +100,11 @@ define(
* @returns {boolean} true if selection changed
*/
deselect: deselect,
/**
* Get the currently-selected object.
* @returns the currently selected object
*/
get: get,
/**
* Clear the selection, including the proxy, and dispose
* of this selection scope. No other calls to methods on

View File

@@ -17,6 +17,7 @@ define(
*/
function ElementProxy(element, index, elements) {
return {
element: element,
x: new Accessor(element, 'x'),
y: new Accessor(element, 'y'),
z: new Accessor(element, 'z'),