portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r604373 - /portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm
Date Sat, 15 Dec 2007 02:39:44 GMT
Author: smilek
Date: Fri Dec 14 18:39:43 2007
New Revision: 604373

URL: http://svn.apache.org/viewvc?rev=604373&view=rev
Log:
fixed issue with add node (folder/page/link) where new node appears twice in tree - this occurred
whenever a node was added prior to expanding the parent of the new node

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm?rev=604373&r1=604372&r2=604373&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.2-POSTRELEASE/applications/j2-admin/src/webapp/WEB-INF/view/site/site-view.vm
Fri Dec 14 18:39:43 2007
@@ -1079,30 +1079,57 @@
   this.node = node;
   this.populate = function(data) 
   { 
-    // insert in sorted order
-    for(var i=0; i<parent.children.length; i++) 
+    var controller = dojo.widget.byId('treeController');
+    if ( parent.state != parent.loadStates.LOADED )
     {
-        var child = parent.children[i];
-        if (child.object == node.object)
+        controller.loadRemote( parent, true );
+        controller.expand( parent ) ;
+    }
+    else
+    {   // insert among already populated child tree nodes of parent
+        // insert in sorted order
+        var addAtIndex = -1;
+        var alreadyExists = false;
+        for(var i=0; i<parent.children.length; i++) 
         {
-             if (child.title > node.title)
-             {
-                break;
-             }
+            var child = parent.children[i];
+            if ( addAtIndex == -1 )
+            {
+                if (child.object == node.object)
+                {
+                     if (child.title > node.title)
+                     {
+                        addAtIndex = i;
+                     }
+                }
+                else
+                {
+                    if (node.object == "Folder")
+                        addAtIndex = i;
+                    if (node.object == "Page" && child.object == "Link")
+                        addAtIndex = i;
+                }
+            }
+            if ( child.object == node.object )
+            {
+                if ( child.title == node.title )
+                {
+                    alreadyExists = true;
+                    break;
+                }
+            }
         }
-        else
+        if ( ! alreadyExists )
         {
-            if (node.object == "Folder")
-                break;
-            if (node.object == "Page" && child.object == "Link")
-                break;
+            if ( addAtIndex == -1 )
+                addAtIndex = parent.children.length;
+            var controller = dojo.widget.byId('treeController');
+            var res = controller.createChild(parent, addAtIndex, node);
+            var selector = dojo.widget.byId('treeSelector');
+            selector.select({ source: parent, event: {} });
+            editResource(parent);
         }
     }
-    var controller = dojo.widget.byId('treeController');
-    var res = controller.createChild(parent, i, node);
-    var selector = dojo.widget.byId('treeSelector');
-    selector.select({ source: parent, event: {} });
-    editResource(parent);
   }
   this.failure = function(data)
   {



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message