From d7ad2659d7ef8d0fffbb1cba8218061ebd516dd0 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 3 Feb 2012 15:09:54 -0800 Subject: Handle delete of multiple objects. Also, have deletion go through the mediator so elementDeleted event is fired for SnapManager, DrawUtils, etc. to clean up after deleted element(s). Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 7 +++++++ js/mediators/element-mediator.js | 14 +++++++++----- js/stage/layout.js | 17 +++++------------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 08a27618..c07391db 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -110,6 +110,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementDeleted", this, false); + this.eventManager.addEventListener("deleteSelection", this, false); this.eventManager.addEventListener("elementChange", this, false); } }, @@ -127,6 +128,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, + handleDeleteSelection: { + value: function(event) { + this.drawWorkingPlane(); + } + }, + _shouldUpdatePlanes: { value: function(props) { if(!props) diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index b2bc5355..992ac620 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -44,12 +44,16 @@ exports.ElementMediator = Montage.create(NJComponent, { this.deleteDelegate.handleDelete(); } else { // Add the Undo/Redo - var els = []; + var els = [], + len = this.application.ninja.selectedElements.length; - if(this.application.ninja.selectedElements.length > 0) { - for(var i=0, item; item = this.application.ninja.selectedElements[i]; i++) { - ElementController.removeElement(item._element); - els.push(item._element); + if(len) { + for(var i = 0; i