← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4472: made multiple roots work correctly in ouwt

 

------------------------------------------------------------
revno: 4472
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-08-28 14:17:29 +0200
message:
  made multiple roots work correctly in ouwt
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-08-27 14:03:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-08-28 12:17:29 +0000
@@ -516,33 +516,17 @@
         var $treeTag = $( "#orgUnitTree" );
         $treeTag.children().eq( 0 ).remove();
 
-        if ( sessionStorage[getTagId( "Selected" )] == null )
-        {
-            var roots = JSON.parse( localStorage[getTagId( "Roots" )] );
-
-            expandTreeAtOrgUnits( roots );
-        }
-        else
-        {
-            var selected = sessionStorage[getTagId( "Selected" )];
-
-            if ( selected != null )
-            {
-                selected = JSON.parse( selected );
-
-                if ( $.isArray( selected ) )
-                {
-                    expandTreeAtOrgUnits( selected );
-                }
-                else
-                {
-                    expandTreeAtOrgUnit( selected );
-                    selected = [ selected ];
-                }
-
-                selectOrgUnits( selected );
-            }
-        }
+        var roots = localStorage[getTagId( "Roots" )];
+        var selected = sessionStorage[getTagId( "Selected" )];
+
+        roots = roots ? JSON.parse( roots ) : [];
+        selected = selected ? JSON.parse( selected ) : [];
+        selected = $.isArray( selected ) ? selected : [ selected ];
+
+        expandTreeAtOrgUnits( roots );
+        expandTreeAtOrgUnits( selected );
+
+        selectOrgUnits( selected );
     };
 
     // force reload