← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18877: fix for multiorg/datasets, make sure to always fetch children datasets if they are not available

 

------------------------------------------------------------
revno: 18877
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-04-10 17:22:15 +0700
message:
  fix for multiorg/datasets, make sure to always fetch children datasets if they are not available
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-04-10 08:41:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-04-10 10:22:15 +0000
@@ -77,6 +77,9 @@
 // Indicates whether multi org unit is enabled on instance
 dhis2.de.multiOrganisationUnitEnabled = false;
 
+// Simple object to see if we have tried to fetch children DS for a parent before
+dhis2.de.fetchedDataSets = {};
+
 // "organisationUnits" object inherited from ouwt.js
 
 // Constants
@@ -224,7 +227,7 @@
                 
         $.when( dhis2.de.getMultiOrgUnitSetting(), dhis2.de.loadMetaData(), dhis2.de.loadDataSetAssociations() ).done( function() {
         	dhis2.de.setMetaDataLoaded();
-        	organisationUnitSelected( ids, names );
+          organisationUnitSelected( ids, names );
         } );
     } );
 } );
@@ -234,7 +237,7 @@
         return false;
     }
 
-    if( !$.isArray(ids) || ids.length == 0 ) {
+    if( !$.isArray(ids) || ids.length == 0 || (ids.length > 0 && dhis2.de.fetchedDataSets[ids[0]]) ) {
         return false;
     }
 
@@ -912,6 +915,14 @@
 	    return false;
 	}
 
+  if( dhis2.de.shouldFetchDataSets(orgUnits) ) {
+    dhis2.de.fetchDataSets( orgUnits[0] ).always(function() {
+      selection.responseReceived();
+    });
+
+    return false;
+  }
+
 	dhis2.de.currentOrganisationUnitId = orgUnits[0];
     var organisationUnitName = orgUnitNames[0];
 
@@ -1015,6 +1026,7 @@
             dhis2.de._updateDataSets(item);
         });
 
+        dhis2.de.fetchedDataSets[ou] = true;
         def.resolve(data);
     });