=== 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-18 10:45:26 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm 2012-10-19 12:24:40 +0000 @@ -189,13 +189,10 @@ fm.saveDataValueSet( dataValueSet ); $.mobile.hidePageLoadingMsg(); - - console.log(dataValueSet); } jQuery(document).bind('pagechange', function (event, data) { var pageId = data.toPage.attr('id'); - console.log(pageId); if( pageId == 'organisation-units-page' ) { loadOrganisationUnitsPage(); === 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-19 10:45:58 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/index.vm 2012-10-19 12:24:40 +0000 @@ -14,19 +14,28 @@ $.ajax({ url: '../api/currentUser/dashboard', - dataType: 'json', + dataType: 'json' }).success(function(data) { if( data.unreadMessageConversation > 0 ) { $('#messages a').append("" + data.unreadMessageConversation + ""); } - fm.initialize(); - fm.uploadDataValueSets(); + fm.initialize({ + success: function() { + fm.uploadDataValueSets({ + success: function() { + }, + done: function() { + $.mobile.hidePageLoadingMsg(); + } + }); + } + }); }).error(function() { $('#messages a').append("Offline") + $.mobile.hidePageLoadingMsg(); }).complete(function() { $('section[data-role="content"] ul').listview('refresh'); - $.mobile.hidePageLoadingMsg(); }); }); === 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-18 12:53:32 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js 2012-10-19 12:24:40 +0000 @@ -41,10 +41,21 @@ }).success(function ( data ) { localStorage['organisationUnits'] = JSON.stringify(data.organisationUnits); localStorage['forms'] = JSON.stringify(data.forms); + + if(args.success) { + args.success.call(data); + } }).error(function () { // offline ? reuse meta-data already present console.log("unable to load meta-data"); + + if(args.error) { + args.error.call(); + } }).complete(function() { + if(args.complete) { + args.complete.call(); + } }); }; @@ -108,7 +119,7 @@ }); }; -dhis2.storage.FormManager.prototype.uploadDataValueSets = function() { +dhis2.storage.FormManager.prototype.uploadDataValueSets = function( args ) { var dataValueSets = this.dataValueSets(); _.each(dataValueSets, function( dataValueSet, idx ) { @@ -120,6 +131,10 @@ async: false }).success(function() { delete dataValueSets[idx]; + + if( args.success ) { + args.success.call(); + } }).error(function() { }); }); @@ -128,6 +143,10 @@ dataValueSets = _.filter(dataValueSets, function(dv) { return dv !== undefined; }); localStorage['dataValueSets'] = JSON.stringify( dataValueSets ); + + if( args.done) { + args.done.call(); + } }; // global storage manager instance