← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11381: ouwt bug fixed, load children when a orgunit is selected. This bug occured when partial loading w...

 

------------------------------------------------------------
revno: 11381
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-07-11 12:42:16 +0700
message:
  ouwt bug fixed, load children when a orgunit is selected. This bug occured when partial loading was enabled, and you were trying to use a multiorgunit form where the orgunits had not been loaded into dom storage.
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	2013-07-03 05:50:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2013-07-11 05:42:16 +0000
@@ -446,7 +446,13 @@
             names.push( name );
         }
 
-        listenerFunction( ids, names, children );
+        if ( !$.isArray( selected ) ) {
+            subtree.getChildren( selected ).done(function() {
+                listenerFunction( ids, names, children );
+            });
+        } else {
+            listenerFunction( ids, names, children );
+        }
     };
 
     function getTagId( unitId )
@@ -694,6 +700,26 @@
         }
     }
 
+    this.getChildren = function( parentId ) {
+        return $.post( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action?parentId=' + parentId, function ( data, textStatus, jqXHR )
+            {
+                // load additional organisationUnits into sessionStorage
+                if ( sessionStorage["organisationUnits"] === undefined )
+                {
+                    sessionStorage["organisationUnits"] = JSON.stringify( data.organisationUnits );
+                }
+                else
+                {
+                    var units = JSON.parse( sessionStorage["organisationUnits"] );
+                    $.extend(units, data.organisationUnits);
+                    sessionStorage["organisationUnits"] = JSON.stringify( units );
+                }
+
+                $.extend(organisationUnits, data.organisationUnits);
+            }
+        );
+    }
+
     function getAndCreateChildren(parentTag, parent)
     {
         if ( parent.c !== undefined )
@@ -704,25 +730,9 @@
             }
             else
             {
-                $.post( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action?parentId=' + parent.id,
-                function ( data, textStatus, jqXHR )
-                    {
-                        // load additional organisationUnits into sessionStorage
-                        if ( sessionStorage["organisationUnits"] === undefined )
-                        {
-                            sessionStorage["organisationUnits"] = JSON.stringify( data.organisationUnits );
-                        } 
-                        else 
-                        {
-                            var units = JSON.parse( sessionStorage["organisationUnits"] );
-                            $.extend(units, data.organisationUnits);
-                            sessionStorage["organisationUnits"] = JSON.stringify( units );
-                        }
-
-                        $.extend(organisationUnits, data.organisationUnits);
-                        createChildren( parentTag, parent );
-                    }
-                );
+                subtree.getChildren( parent.id ).done( function () {
+                    createChildren( parentTag, parent );
+                } );
             }
         }