← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8693: Mobile: minor changes to upload logic

 

------------------------------------------------------------
revno: 8693
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-24 15:28:42 +0200
message:
  Mobile: minor changes to upload logic
modified:
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.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-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm	2012-10-24 12:16:41 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm	2012-10-24 13:28:42 +0000
@@ -44,30 +44,40 @@
             $('section[data-role="content"] ul').listview('refresh');
         }).then( fm.getMetaData().then( fm.uploadDataValueSets() ).always( function() {
             $.mobile.hidePageLoadingMsg();
+            updateMenu();
             renderOfflineStatus();
         }));
 
         $('body').bind('dhis2.online', function() {
             if( loggedInStatus ) {
-                $( '#messages').removeClass('ui-disabled');
-                $( '#settings').removeClass('ui-disabled');
-
-                renderOfflineStatus();
-
-                getDashboard().always(function() {
-                    $('section[data-role="content"] ul').listview('refresh');
+                fm.uploadDataValueSets().always(function() {
+                    updateMenu();
+                    renderOfflineStatus();
+
+                    getDashboard().always(function() {
+                        $('section[data-role="content"] ul').listview('refresh');
+                    });
                 });
             }
         });
 
         $('body').bind('dhis2.offline', function() {
+            updateMenu();
+            renderOfflineStatus();
+        });
+
+        onlineTimer();
+    });
+
+    function updateMenu() {
+        if( onlineStatus ) {
+            $( '#messages').removeClass('ui-disabled');
+            $( '#settings').removeClass('ui-disabled');
+        } else {
             $( '#messages').addClass('ui-disabled');
             $( '#settings').addClass('ui-disabled');
-            renderOfflineStatus();
-        });
-
-        onlineTimer();
-    });
+        }
+    }
 
     function onlineTimer() {
         setTimeout(function () {
@@ -98,7 +108,11 @@
     <% if( dataValueSets.length == 0 ) { %>
         <p>No data is stored locally.</p>
     <% } else { %>
-        <p>You have <%= dataValueSets.length %> forms stored locally</p>
+        <% if( dataValueSets.length == 1 ) { %>
+            <p>You have <strong><%= dataValueSets.length %></strong> form stored locally</p>
+        <% } else { %>
+            <p>You have <strong><%= dataValueSets.length %></strong> forms stored locally</p>
+        <% } %>
     <% } %>
 
     <% if( online ) { %>

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js	2012-10-21 14:38:30 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js	2012-10-24 13:28:42 +0000
@@ -93,13 +93,11 @@
         url: '../api/dataValueSets',
         type: 'POST',
         contentType: 'application/json',
-        data: JSON.stringify(dataValueSet),
-    }).success(function() {
-        // nop, successfully uploaded
+        data: JSON.stringify( dataValueSet )
     }).error(function() {
         // add to local dataValueSets
-        dataValueSets.push(dataValueSet);
-        localStorage['dataValueSets'] = JSON.stringify(dataValueSets);
+        dataValueSets.push( dataValueSet );
+        localStorage['dataValueSets'] = JSON.stringify( dataValueSets );
     });
 };