Module: nagvis
Branch: master
Commit: 588d92eb849b6c9aa9492a62744b3856cdf7c963
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=588d92eb849b6c9aa9492a62744b3856cdf7c963

Author: Lars Michelsen <[email protected]>
Date:   Wed Sep 29 19:30:11 2010 +0200

#357 Fixed bug which could result in broken map configs when deleting/editing 
map objects of same type without reloading the map

---

 share/frontend/wui/js/wui.js |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/share/frontend/wui/js/wui.js b/share/frontend/wui/js/wui.js
index 272be03..2509c9f 100644
--- a/share/frontend/wui/js/wui.js
+++ b/share/frontend/wui/js/wui.js
@@ -432,6 +432,10 @@ function saveObjectAfterMoveAndDrop(oObj) {
        oResult = null;
 }
 
+function getDomObjectIds(objId) {
+    return [ 'box_'+objId, 'icon_'+objId+'-context', 'rel_label_'+objId, 
'abs_label_'+objId ];
+}
+
 // This function handles object deletions on maps
 function deleteMapObject(objId) {
        if(confirm(printLang(lang['confirmDelete'],''))) {
@@ -450,7 +454,7 @@ function deleteMapObject(objId) {
 
                // Remove the object with all childs and other containers from 
the map
                var oMap = document.getElementById('mymap');
-               var ids = [ objId, 'icon_'+type+'_'+id+'-context', 
'rel_label_'+type+'_'+id, 'abs_label_'+type+'_'+id ];
+               var ids = getDomObjectIds(type+'_'+id)
                for(var i in ids) {
                        var o = document.getElementById(ids[i])
                        if(o) {
@@ -459,6 +463,25 @@ function deleteMapObject(objId) {
                        }
                }
                oMap = null;
+
+               // Now change all objects of the same type which have a higher 
object id.
+               // The object id of these objects needs to be reduced by one.
+               var oObj, domIds;
+               var newId = parseInt(id);
+               var nextId = newId+1;
+               while(document.getElementById('box_'+type+'_'+nextId)) {
+                       domIds = getDomObjectIds(type+'_'+nextId);
+                       for(var i in domIds) {
+                               var oObj = document.getElementById(domIds[i]);
+                               if(oObj)
+                                       oObj.setAttribute('id', 
domIds[i].replace(nextId, newId));
+                       }
+                       nextId++;
+                       newId++;
+               }
+    nextId = null;
+    newId = null;
+               oObj = null;
                
                return true;
        } else {


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to