← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8608: mobile: have saveDataValueSet return a $.Deferred (promise), so that we can react to state change...

 

------------------------------------------------------------
revno: 8608
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-10-21 16:38:30 +0200
message:
  mobile: have saveDataValueSet return a $.Deferred (promise), so that we can react to state changes. Saving a dataValueSet now redirects back to index page.
modified:
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm
  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/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/base.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm	2012-10-19 22:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm	2012-10-21 14:38:30 +0000
@@ -1,6 +1,6 @@
 <!DOCTYPE html>
-<html manifest="../dhis-web-mobile-resources/manifest.appcache">
-<!--  <html> -->
+<!--  <html manifest="../dhis-web-mobile-resources/manifest.appcache">  -->
+<html>
 <head>
 	<title>DHIS2</title>
 	<meta name="viewport" content="width=device-width, initial-scale=1">

=== 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-19 12:24:40 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm	2012-10-21 14:38:30 +0000
@@ -187,8 +187,10 @@
 
         dataValueSet.dataValues = dataValues;
 
-        fm.saveDataValueSet( dataValueSet );
-        $.mobile.hidePageLoadingMsg();
+        fm.saveDataValueSet( dataValueSet ).then(function() {
+            $.mobile.hidePageLoadingMsg();
+            $.mobile.changePage('index');
+        });
     }
 
     jQuery(document).bind('pagechange', function (event, data) {

=== 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-19 22:33:35 +0000
+++ 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
@@ -89,12 +89,11 @@
 dhis2.storage.FormManager.prototype.saveDataValueSet = function( dataValueSet ) {
     var dataValueSets = this.dataValueSets();
 
-    $.ajax({
+    return $.ajax({
         url: '../api/dataValueSets',
         type: 'POST',
         contentType: 'application/json',
         data: JSON.stringify(dataValueSet),
-        async: false
     }).success(function() {
         // nop, successfully uploaded
     }).error(function() {