← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8771: Mobile: Updated to use new $.mobile.loading methods. Should now properly display loader in all si...

 

------------------------------------------------------------
revno: 8771
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-30 15:02:06 +0100
message:
  Mobile: Updated to use new $.mobile.loading methods. Should now properly display loader in all situations where its waiting for the server.
removed:
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/interpretations.vm
modified:
  dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm
  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/message.vm
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/messages.vm
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/new-message.vm
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm


--
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/resources/dhis-mobile-manifest.appcache'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache	2012-10-25 13:45:18 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache	2012-10-30 14:02:06 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# Version: 18
+# Version: 22
 
 CACHE:
 ../mobile/index

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm	2012-10-26 13:58:54 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm	2012-10-30 14:02:06 +0000
@@ -26,7 +26,7 @@
     }
 
     function loadOrganisationUnitsPage() {
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         var organisationUnits = fm.organisationUnits();
         var tmpl = $( '#organisation-units-template' ).html();
@@ -38,17 +38,16 @@
         $('#organisation-unit-list').listview();
         $('#organisation-unit-list li a').bind('click', selectOrganisationUnit);
 
-        $.mobile.hidePageLoadingMsg();
+        $.mobile.loading( 'hide' );
     }
 
     function loadDataSetsPage() {
-        if( Selected.orgUnit === undefined )
-        {
+        if( Selected.orgUnit === undefined ) {
             $.mobile.changePage( '#organisation-units-page' );
             return;
         }
 
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         var organisationUnit = fm.organisationUnit( Selected.orgUnit );
         var tmpl = $( '#data-sets-template' ).html();
@@ -60,7 +59,7 @@
         $('#data-set-list').listview();
         $('#data-set-list li a').bind( 'click', selectDataSet );
 
-        $.mobile.hidePageLoadingMsg();
+        $.mobile.loading( 'hide' );
     }
 
     function refreshPeriods() {
@@ -123,14 +122,14 @@
             return;
         }
 
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         var form = fm.form( Selected.dataSet );
         periodType = form.periodType;
         allowFuturePeriods = form.allowFuturePeriods;
         refreshPeriods();
 
-        $.mobile.hidePageLoadingMsg();
+        $.mobile.loading( 'hide' );
     }
 
     function loadDataEntryPage() {
@@ -152,7 +151,7 @@
             return;
         }
 
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         function renderFormTemplate(form, valueMap) {
             var tmpl = $( '#data-entry-template' ).html();
@@ -186,7 +185,7 @@
 
             var form = fm.form(Selected.dataSet);
             renderFormTemplate(form, valueMap);
-            $.mobile.hidePageLoadingMsg();
+            $.mobile.loading( 'hide' );
         } else {
             $.ajax({
                 url: '../api/dataSets/' + Selected.dataSet + '/form',
@@ -201,13 +200,13 @@
                 var form = fm.form(Selected.dataSet);
                 renderFormTemplate(form);
             }).complete(function() {
-                $.mobile.hidePageLoadingMsg();
+                $.mobile.loading( 'hide' );
             });
         }
     }
 
     function saveValues() {
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         var fields = $('#data-entry-form :input[name]');
 
@@ -234,7 +233,7 @@
         dataValueSet.dataValues = dataValues;
 
         fm.saveDataValueSet( dataValueSet ).always(function() {
-            $.mobile.hidePageLoadingMsg();
+            $.mobile.loading( 'hide' );
             location.href = 'index';
         });
     }
@@ -252,7 +251,10 @@
         if( pageLoaders[pageId] ) {
             pageLoaders[pageId].call();
         } else {
-            $.mobile.showPageLoadingMsg($.mobile.pageLoadErrorMessageTheme, "Tried changing to invalid page.", true);
+            $.mobile.loading( 'show', {
+                text: 'Tried changing to invalid page',
+                textonly: true
+            });
         }
     });
 </script>

=== 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-30 11:56:01 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm	2012-10-30 14:02:06 +0000
@@ -32,21 +32,21 @@
             if( data.unreadMessageConversation > 0 ) {
                 $( '#messages a' ).append("<span class='ui-li-count'>" + data.unreadMessageConversation + "</span>");
             }
-        }).error(function() {
-            $.mobile.hidePageLoadingMsg();
         });
     }
 
-    $(document).bind('pagebeforecreate',function(){
-        $.mobile.showPageLoadingMsg();
+    $(document).bind('pagechange',function(){
+        $.mobile.loading( 'show' );
 
         getDashboard().always(function() {
             $('section[data-role="content"] ul').listview('refresh');
-        }).then( fm.getMetaData().then( fm.uploadDataValueSets() ).always( function() {
-            $.mobile.hidePageLoadingMsg();
-            updateMenu();
-            renderOfflineStatus();
-        }));
+
+            $.when( fm.getMetaData(), fm.uploadDataValueSets()).always(function() {
+                updateMenu();
+                renderOfflineStatus();
+                $.mobile.loading( 'hide' );
+            });
+        });
 
         $('body').bind('dhis2.online', function() {
             if( loggedInStatus ) {

=== removed file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/interpretations.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/interpretations.vm	2012-10-10 09:29:10 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/interpretations.vm	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-
-<section data-role="page" id="interpretations-page" data-theme="c">
-
-	<header data-role="header" data-theme="b">
-        <h1 align="center"><img src="$baseUrl/../dhis-web-commons/css/light_blue/logo_banner.png" /></h1>
-        <a href="index" data-icon="back">Back</a>
-	</header>
-
-	<section data-role="content">
-	</section>
-
-    <footer data-role="footer" data-theme="b">
-        <h1></h1>
-   	</footer>
-
-</section>

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/message.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/message.vm	2012-10-26 13:58:54 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/message.vm	2012-10-30 14:02:06 +0000
@@ -20,7 +20,7 @@
                 return;
             }
 
-            $.mobile.showPageLoadingMsg();
+            $.mobile.loading( 'show' );
 
             $.ajax({
                 url         : '$baseUrl/../api/messageConversations/${messageId}',
@@ -31,8 +31,14 @@
                 $.mobile.hidePageLoadingMsg();
                 location.reload(true);
             }).error(function () {
-                $.mobile.showPageLoadingMsg($.mobile.pageLoadErrorMessageTheme, "Unable to send reply, please try again later", true);
-                setTimeout($.mobile.hidePageLoadingMsg, 1500);
+                $.mobile.loading( 'show', {
+                    text: 'Unable to send reply, please try again later',
+                    textonly: true
+                });
+
+                setTimeout( function() {
+                    $.mobile.loading( 'hide' );
+                }, 1500);
             });
 
             e.preventDefault();
@@ -53,8 +59,14 @@
             $('section[data-role="content"]').trigger('create');
             bindSubmitHandler();
         }).error(function () {
-            $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, "Unable to load message, please try again later", true );
-            setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
+            $.mobile.loading( 'show', {
+                text: 'Unable to load message, please try again later',
+                textonly: true
+            });
+
+            setTimeout( function() {
+                $.mobile.loading( 'hide' );
+            }, 1500);
         });
     });
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/messages.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/messages.vm	2012-10-30 10:52:19 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/messages.vm	2012-10-30 14:02:06 +0000
@@ -1,10 +1,11 @@
 
 <script>
-    $(document).bind('pagebeforecreate',function(){
+    $(document).bind('pagechange',function(){
+        $.mobile.loading( 'show' );
+
         $.ajax({
             url: '../api/currentUser/inbox',
-            dataType: 'json',
-            async: false
+            dataType: 'json'
         }).success(function(data) {
             if( data['messageConversations'] !== undefined ) {
                 $.each(data.messageConversations, function(i, item) {
@@ -18,8 +19,17 @@
                 $('#messageList').append('<li>No messages</li>');
             }
         }).error(function() {
-            $.mobile.showPageLoadingMsg($.mobile.pageLoadErrorMessageTheme, "Unable to get inbox, please try again later", true);
-            setTimeout($.mobile.hidePageLoadingMsg, 1500);
+            $.mobile.loading( 'show', {
+                text: 'Unable to get inbox, please try again later',
+                textonly: true
+            });
+
+            setTimeout( function() {
+                $.mobile.loading( 'hide' );
+            }, 1500);
+        }).complete(function() {
+            $('section[data-role="content"] ul').listview('refresh');
+            $.mobile.loading( 'hide' );
         });
     });
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/new-message.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/new-message.vm	2012-10-30 11:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/new-message.vm	2012-10-30 14:02:06 +0000
@@ -108,7 +108,7 @@
                 return;
             }
 
-            $.mobile.showPageLoadingMsg();
+            $.mobile.loading( 'show' );
 
             $.ajax({
                 url  : '$baseUrl/../api/currentUser/recipients',
@@ -186,8 +186,14 @@
                 $('#selection-list').listview('refresh');
                 $.mobile.hidePageLoadingMsg();
             }).error(function() {
-                $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, "Unable to search, please try again later", true );
-                setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
+                $.mobile.loading( 'show', {
+                    text: 'Unable to search, please try again later',
+                    textonly: true
+                });
+
+                setTimeout( function() {
+                    $.mobile.loading( 'hide' );
+                }, 1500);
             });
 
             $('form[role="search"] input:text').bind('keyup', fn1);
@@ -208,18 +214,32 @@
         message.userGroups = [];
 
         if( !message.subject.length > 0 ) {
-            $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, "Please fill in subject", true );
-            setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
+            $.mobile.loading( 'show', {
+                text: 'Please fill in subject',
+                textonly: true
+            });
+
+            setTimeout( function() {
+                $.mobile.loading( 'hide' );
+            }, 1500);
+
             return false;
         }
 
         if( !message.text.length > 0 ) {
-            $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, "Please fill in text", true );
-            setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
+            $.mobile.loading( 'show', {
+                text: 'Please fill in text',
+                textonly: true
+            });
+
+            setTimeout( function() {
+                $.mobile.loading( 'hide' );
+            }, 1500);
+
             return false;
         }
 
-        $.mobile.showPageLoadingMsg();
+        $.mobile.loading( 'show' );
 
         _(_(selected).keys()).each(function(key) {
             if( key.indexOf('ou:') != -1 )
@@ -249,12 +269,17 @@
            data: JSON.stringify(message),
            async: false
         }).success(function() {
-            $.mobile.hidePageLoadingMsg();
+            $.mobile.loading( 'hide' );
             window.location.href = '../messages';
         }).error(function() {
-            $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, "Unable to send message, please try again later", true );
-            setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
-            console.log("failed to send message");
+            $.mobile.loading( 'show', {
+                text: 'Unable to send message, please try again later',
+                textonly: true
+            });
+
+            setTimeout( function() {
+                $.mobile.loading( 'hide' );
+            }, 1500);
         });
 
         e.preventDefault();

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm	2012-10-30 11:56:01 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm	2012-10-30 14:02:06 +0000
@@ -1,15 +1,18 @@
 
 <script>
-    $(document).bind('pageinit',function(){
+    $(document).bind('pagechange',function(){
+        $.mobile.loading( 'show' );
+
         $.ajax({
             url: '../api/currentUser',
-            dataType: 'json',
-            async: false
+            dataType: 'json'
         }).success(function(data) {
             $('#firstNameInput').val(data.firstName);
             $('#surnameInput').val(data.surname);
             $('#emailInput').val(data.email);
             $('#phoneNumberInput').val(data.phoneNumber);
+        }).complete(function() {
+            $.mobile.loading( 'hide' );
         });
 
         $('input:submit').bind('click', function(e) {
@@ -20,7 +23,7 @@
                return acc;
             }, {});
 
-            $.mobile.showPageLoadingMsg();
+            $.mobile.loading( 'show' );
 
             $.ajax({
                 url: '../api/currentUser/user-account.json',
@@ -28,7 +31,7 @@
                 data: JSON.stringify( settings ),
                 type: 'POST'
             }).complete(function() {
-                $.mobile.hidePageLoadingMsg();
+                $.mobile.loading( 'hide' );
                 window.location.href = '../mobile';
             });