← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10578: properly handle programStageUid if offline

 

------------------------------------------------------------
revno: 10578
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-04-16 17:02:01 +0700
message:
  properly handle programStageUid if offline
modified:
  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/entry.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-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-15 12:48:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-16 10:02:01 +0000
@@ -278,8 +278,14 @@
     jQuery( '#programId' ).append( '<option value="" psid="" reportDateDes="' + i18n_report_date + '">[' + i18n_please_select + ']</option>' );
 
     for ( var i = 0; i < arr.length; i++ ) {
-        jQuery( '#programId' ).append( '<option value="' + arr[i].key + '" psid="' + arr[i].programStages[0].id + '" reportDateDes="' +
-            arr[i].programStages[0].reportDateDescription + '">' + arr[i].name + '</option>' );
+        jQuery( '#programId' ).append(
+            '<option value="' + arr[i].key
+            + '" puid="' + arr[i].uid
+            + '" psid="' + arr[i].programStages[0].id
+            + '" psuid="' + arr[i].programStages[0].uid
+            + '" reportDateDes="' + arr[i].programStages[0].reportDateDescription + '">'
+            + arr[i].name
+            + '</option>' );
     }
 
     disableCriteriaDiv();

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-04-16 03:58:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-04-16 10:02:01 +0000
@@ -4,27 +4,21 @@
 
 function saveVal( dataElementUid )
 {
-	var programStageUid = jQuery('.stage-object-selected').attr('psuid');
-
-    if ( programStageUid == undefined ) {
-        if ( jQuery( '#entryFormContainer [id=programStageUid]' ) == null ) return;
-        else programStageUid = jQuery( '#entryFormContainer [id=programStageUid]' ).val();
-    }
-
+    var programStageUid = getProgramStageUid();
     var fieldId = programStageUid + '-' + dataElementUid + '-val';
-	
-	var field = byId( fieldId ); 
-	if( field == null) return;
-	
-	var fieldValue = jQuery.trim( field.value );
-	
-	var arrData = jQuery( "#" + fieldId ).attr('data').replace('{','').replace('}','').replace(/'/g,"").split(',');
-	var data = new Array();
+    var field = byId( fieldId );
+
+    if( field == null) return;
+
+    var fieldValue = jQuery.trim( field.value );
+    var arrData = jQuery( "#" + fieldId ).attr( 'data' ).replace( '{', '' ).replace( '}', '' ).replace( /'/g, "" ).split( ',' );
+    var data = new Array();
 
     for ( var i in arrData ) {
         var values = arrData[i].split( ':' );
         var key = jQuery.trim( values[0] );
-        var value = jQuery.trim( values[1] )
+        var value = jQuery.trim( values[1] );
+
         data[key] = value;
     }
 
@@ -87,7 +81,7 @@
 
 function saveOpt( dataElementUid )
 {
-	var programStageUid = jQuery('.stage-object-selected').attr('psuid');
+	var programStageUid = getProgramStageUid();
 	var field = byId( programStageUid + '-' + dataElementUid + '-val' );	
 	field.style.backgroundColor = SAVING_COLOR;
 	
@@ -116,6 +110,24 @@
     }
 }
 
+function getProgramStageUid() {
+    var programStageUid = jQuery( '.stage-object-selected' ).attr( 'psuid' );
+
+    if ( programStageUid == undefined ) {
+        programStageUid = jQuery( '#programId option:selected' ).attr( 'psuid' );
+    }
+
+    if ( programStageUid == undefined ) {
+        programStageUid = jQuery( '#entryFormContainer [id=programStageUid]' ).val();
+    }
+
+    if ( programStageUid == undefined ) {
+        programStageUid = jQuery( '#programStageUid' ).val();
+    }
+
+    return programStageUid;
+}
+
 /**
 * Display data element name in selection display when a value field recieves
 * focus.
@@ -267,7 +279,7 @@
  
     function markValue( color )
     {
-		var programStageUid = jQuery('#entryFormContainer [id=programStageUid]').val();
+		var programStageUid = getProgramStageUid();
 		var element = byId( programStageUid + "-" + dataElementUid + '-val' );
         element.style.backgroundColor = color;
     }
@@ -497,7 +509,7 @@
                 var programInstanceId = jQuery('#entryFormContainer [id=programInstanceId]').val();
 
                 if( irregular == 'true' && displayGenerateEventBox=="true" ) {
-                    var programStageUid = jQuery(".stage-object-selected").attr('psuid');
+                    var programStageUid = getProgramStageUid();
                     showCreateNewEvent( programInstanceId, programStageUid );
                 }
 
@@ -682,11 +694,7 @@
 	var currentFocus = undefined;
     var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
 	
-    loadProgramStageInstance(programStageInstanceId ).done(function() {
-
-    } ).fail(function() {
-
-    } ).always(function() {
+    loadProgramStageInstance(programStageInstanceId ).always(function() {
         if( jQuery("#entryFormContainer") ) {
 
             // Display entry form if excution-date is not null