← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10495: added availability service to anonymous reports. enable add button even if getDataElements ajax c...

 

------------------------------------------------------------
revno: 10495
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-08 12:53:22 +0700
message:
  added availability service to anonymous reports. enable add button even if getDataElements ajax call fails.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties


--
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-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2013-03-21 13:37:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2013-04-08 05:53:22 +0000
@@ -3,6 +3,9 @@
         datePickerInRange( 'startDate', 'endDate', true, true );
         disableCriteriaDiv();
     } );
+
+    var i18n_online_notification = '$encoder.jsEscape( $i18n.getString( "online_notification" ) , "'")';
+    var i18n_offline_notification = '$encoder.jsEscape( $i18n.getString( "offline_notification" ) , "'")';
 </script>
 
 <h3>$i18n.getString( "anonymous_events_management" ) #openHelp('single_event_without_registration')</h3>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-08 05:43:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-08 05:53:22 +0000
@@ -6,8 +6,6 @@
         cache: false
     } );
 
-    setHeaderMessage( "Loading.. please wait" );
-
     $( "#orgUnitTree" ).one( "ouwtLoaded", function () {
         // initialize the stores, and then try and add the data
         DAO.programs = new dhis2.storage.Store( {name: 'programs', adapter: 'dom-ss'}, function ( store ) {
@@ -26,8 +24,55 @@
         } );
     } );
 
+    $( document ).bind( 'dhis2.online', function ( event, loggedIn ) {
+        if ( loggedIn ) {
+            setHeaderDelayMessage( i18n_online_notification );
+        }
+        else {
+            var form = [
+                '<form style="display:inline;">',
+                '<label for="username">Username</label>',
+                '<input name="username" id="username" type="text" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
+                '<label for="password">Password</label>',
+                '<input name="password" id="password" type="password" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
+                '<button id="login_button" type="button">Login</button>',
+                '</form>'
+            ].join( '' );
+
+            setHeaderMessage( form );
+            ajax_login();
+        }
+    } );
+
+    $( document ).bind( 'dhis2.offline', function () {
+        setHeaderMessage( i18n_offline_notification );
+    } );
+
+    dhis2.availability.startAvailabilityCheck();
 } );
 
+function ajax_login()
+{
+    $( '#login_button' ).bind( 'click', function()
+    {
+        var username = $( '#username' ).val();
+        var password = $( '#password' ).val();
+
+        $.post( '../dhis-web-commons-security/login.action', {
+            'j_username' : username,
+            'j_password' : password
+        } ).success( function()
+        {
+            var ret = dhis2.availability.syncCheckAvailability();
+
+            if ( !ret )
+            {
+                alert( i18n_ajax_login_failed );
+            }
+        } );
+    } );
+}
+
 function organisationUnitSelected( orgUnits, orgUnitNames ) {
     showById( 'dataEntryMenu' );
     hideById( 'eventActionMenu' );
@@ -142,7 +187,9 @@
 
             enableCriteriaDiv();
             validateSearchEvents( true );
-        } );
+        } ).fail(function() {
+            enable( 'addBtn' );
+        });
 }
 
 function dataElementOnChange( this_ ) {

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2013-04-02 15:45:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2013-04-08 05:53:22 +0000
@@ -107,6 +107,12 @@
 
 offline=Offline
 online=Online
+online_notification=You are online
+offline_notification=You are offline, data will be stored locally
+need_to_sync_notification=There is data stored locally, please upload to server
+sync_now=Upload
+sync_success=Upload to server was successful
+sync_failed=Upload to server failed, please try again later
 year=Year
 details=Details
 show_details=Show details

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2013-02-05 12:34:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2013-04-08 05:53:22 +0000
@@ -79,12 +79,6 @@
 save=Save
 save_comment=Save comment
 operation_not_available_offline=This operation is not available in off-line mode
-online_notification=You are online
-offline_notification=You are offline, data will be stored locally
-need_to_sync_notification=There is data stored locally, please upload to server
-sync_now=Upload
-sync_success=Upload to server was successful
-sync_failed=Upload to server failed, please try again later
 uploading_data_notification=Uploading locally stored data to the server
 ajax_login_failed=Login failed, check your username and password and try again
 mark_value_for_followup=Mark value for follow-up