← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5500: Display the last anonymous event for the program no matter what orgunit is selected.

 

------------------------------------------------------------
revno: 5500
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-20 16:47:53 +0700
message:
  Display the last anonymous event for the program no matter what orgunit is selected.
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-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramInstances.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-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	2011-12-20 02:45:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2011-12-20 09:47:53 +0000
@@ -9,6 +9,7 @@
 			
 <div id="dataRecordingSelectDiv" class="inputCriteria" style="width:420px;height:80px;">
 	<input type='hidden' id="programStageId">
+	<input type='hidden' id='selectedProgramId'>
 	<table>
 		<tr>
 			<td>$i18n.getString('program')</td>

=== 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	2011-12-20 02:45:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2011-12-20 09:47:53 +0000
@@ -1,6 +1,7 @@
 
 function organisationUnitSelected( orgUnits )
 {
+	hideById('dataEntryFormDiv');
 	disable('executionDate');
 	setFieldValue('executionDate', '');
 	$('#executionDate').unbind('change');
@@ -14,10 +15,30 @@
 			clearListById( 'programId' );
 			addOptionById( 'programId', '', i18n_please_select );
 			
+			var preSelectedProgramId = getFieldValue('selectedProgramId');
 			for ( i in json.programInstances ) 
-			{
-				$('#programId').append('<option value=' + json.programInstances[i].id + ' singleevent="true" programInstanceId=' + json.programInstances[i].programInstanceId + '>' + json.programInstances[i].name + '</option>');
-			}			
+			{ 
+				if( preSelectedProgramId == json.programInstances[i].id )
+				{
+					$('#programId').append('<option selected value=' + json.programInstances[i].id + ' singleevent="true" programInstanceId=' + json.programInstances[i].programInstanceId + '>' + json.programInstances[i].name + '</option>');
+				}
+				else
+				{
+					$('#programId').append('<option value=' + json.programInstances[i].id + ' singleevent="true" programInstanceId=' + json.programInstances[i].programInstanceId + '>' + json.programInstances[i].name + '</option>');
+				}
+			}
+
+			if( byId('programId').selectedIndex > 0 )
+			{
+				showEventForm();
+			}
+			else
+			{
+				if( json.programInstances.length > 0 )
+				{
+					enable('createEventBtn');
+				}
+			}
 			
 		} );
 }
@@ -28,10 +49,12 @@
 function showEventForm()
 {	
 	setFieldValue('executionDate', '');
-	
-	if( getFieldValue('programId') == '' )
+	var programId = getFieldValue('programId');
+	
+	hideById('dataEntryFormDiv');
+	
+	if( programId == '' )
 	{
-		hideById('dataEntryFormDiv');
 		return;
 	}
 	
@@ -39,11 +62,12 @@
 	
 	jQuery.postJSON( "loadProgramStages.action",
 		{
-			programId: getFieldValue('programId')
+			programId: programId
 		}, 
 		function( json ) 
 		{    
 			setFieldValue( 'programStageId', json.programStages[0].id );
+			setFieldValue( 'selectedProgramId', programId );
 			
 			if( json.programStageInstances.length > 0 )
 			{

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramInstances.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramInstances.vm	2011-12-16 06:45:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramInstances.vm	2011-12-20 09:47:53 +0000
@@ -1,4 +1,4 @@
-#set( $size = $programs.size() )
+#set( $size = $programInstances.size() )
 { 
 	"programInstances": [
 		#foreach( $programInstance in $programInstances )