← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17504: add discard button to data-entry, discards locally stored datavalues

 

------------------------------------------------------------
revno: 17504
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-17 22:01:37 +0700
message:
  add discard button to data-entry, discards locally stored datavalues
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties
  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/select.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-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-08 23:03:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-17 15:01:37 +0000
@@ -124,6 +124,7 @@
 need_to_sync_notification=There is data stored locally, please upload to server
 uploading_data_notification=Uploading locally stored data to the server
 sync_now=Upload
+discard=Discard
 sync_success=Upload to server was successful
 sync_failed=Upload to server failed, please try again later
 year=Year

=== 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	2014-11-17 14:35:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-17 15:01:37 +0000
@@ -182,11 +182,13 @@
 	        if ( dhis2.de.storageManager.hasLocalData() )
 	        {
 	            var message = i18n_need_to_sync_notification
-	            	+ ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
+	            	+ ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>'
+	            	+ ' <button id="discard_button" type="button">' + i18n_discard + '</button>';
 
 	            setHeaderMessage( message );
 
 	            $( '#sync_button' ).bind( 'click', dhis2.de.uploadLocalData );
+	            $( '#discard_button' ).bind( 'click', dhis2.de.discardLocalData );
 	        }
 	        else
 	        {
@@ -285,7 +287,12 @@
 	        updateForms();
 	    }
 	} );
-}
+};
+
+dhis2.de.discardLocalData = function() {
+    dhis2.de.storageManager.clearAllDataValues();
+    hideHeaderMessage();
+};
 
 dhis2.de.uploadLocalData = function()
 {
@@ -2544,7 +2551,12 @@
     {
         return localStorage[KEY_DATAVALUES] != null ? JSON.parse( localStorage[KEY_DATAVALUES] ) : null;
     };
-    
+
+    this.clearAllDataValues = function()
+    {
+        localStorage[KEY_DATAVALUES] = "";
+    };
+
     /**
      * Returns all data value objects in an array. Returns an empty array if no
      * data values exist. Items in array are guaranteed not to be undefined.

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2014-10-28 14:29:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2014-11-17 15:01:37 +0000
@@ -32,6 +32,7 @@
 var i18n_offline_notification = '$encoder.jsEscape( $i18n.getString( "offline_notification" ) , "'")';
 var i18n_need_to_sync_notification = '$encoder.jsEscape( $i18n.getString( "need_to_sync_notification" ) , "'")';
 var i18n_sync_now = '$encoder.jsEscape( $i18n.getString( "sync_now" ) , "'")';
+var i18n_discard = '$encoder.jsEscape( $i18n.getString( "discard" ) , "'")';
 var i18n_sync_success = '$encoder.jsEscape( $i18n.getString( "sync_success" ) , "'")';
 var i18n_sync_failed = '$encoder.jsEscape( $i18n.getString( "sync_failed" ) , "'")';
 var i18n_uploading_data_notification = '$encoder.jsEscape( $i18n.getString( "uploading_data_notification" ) , "'")';