← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9045: more js fixes in data entry

 

------------------------------------------------------------
revno: 9045
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-11-15 12:17:51 +0100
message:
  more js fixes in data entry
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	2012-11-15 11:11:53 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2012-11-15 11:17:51 +0000
@@ -880,10 +880,9 @@
 
     addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
 
-    for ( i in periods )
-    {
-        addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
-    }
+    $.each(periods, function(idx, item) {
+        addOptionById( 'selectedPeriodId', item.id, item.name );
+    });
 }
 
 // -----------------------------------------------------------------------------
@@ -915,10 +914,9 @@
 
         addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
 
-        for ( i in periods )
-        {
-            addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
-        }
+        $.each(periods, function(idx, item) {
+            addOptionById( 'selectedPeriodId', item.id, item.name );
+        });
 
         var previousPeriodType = currentDataSetId ? dataSets[currentDataSetId].periodType : null;
 
@@ -1546,17 +1544,14 @@
 {
     var formIds = storageManager.getAllForms();
 
-    for ( i in formIds )
-    {
-        var localId = formIds[i];
-
-        if ( dataSets[localId] == null )
+    $.each(formIds, function(idx, item) {
+        if ( dataSets[item] == null )
         {
-            storageManager.deleteForm( localId );
-            storageManager.deleteFormVersion( localId );
-            log( 'Deleted locally stored form: ' + localId );
+            storageManager.deleteForm( item );
+            storageManager.deleteFormVersion( item );
+            log( 'Deleted locally stored form: ' + item );
         }
-    }
+    });
 
     log( 'Purged local forms' );
 }
@@ -1566,31 +1561,27 @@
     var formIds = storageManager.getAllForms();
     var formVersions = storageManager.getAllFormVersions();
 
-    for ( i in formIds )
-    {
-        var localId = formIds[i];
-
-        var remoteVersion = dataSets[localId].version;
-        var localVersion = formVersions[localId];
+    $.each(formIds, function(idx, item) {
+        var remoteVersion = dataSets[item].version;
+        var localVersion = formVersions[item];
 
         if ( remoteVersion == null || localVersion == null || remoteVersion != localVersion )
         {
-            storageManager.downloadForm( localId, remoteVersion );
+            storageManager.downloadForm( item, remoteVersion );
         }
-    }
+    });
 }
 
 function downloadRemoteForms()
 {
-    for ( dataSetId in dataSets )
-    {
-        var remoteVersion = dataSets[dataSetId].version;
+    $.each(dataSets, function(idx, item) {
+        var remoteVersion = item.version;
 
-        if ( !storageManager.formExists( dataSetId ) && !dataSets[dataSetId].skipOffline )
+        if ( !storageManager.formExists( idx ) && !item.skipOffline )
         {
-            storageManager.downloadForm( dataSetId, remoteVersion );
+            storageManager.downloadForm( idx, remoteVersion );
         }
-    }
+    });
 }
 
 // TODO break if local storage is full