← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11535: hide/show user group in the update program form

 

------------------------------------------------------------
revno: 11535
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-07-29 14:52:18 +0700
message:
  hide/show user group in the update program form
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.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-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2013-06-30 16:51:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2013-07-29 07:52:18 +0000
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd";>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2013-07-25 02:32:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2013-07-29 07:52:18 +0000
@@ -359,8 +359,16 @@
             reminder.setDateToCompare( datesToCompare.get( i ) );
             reminder.setSendTo( sendTo.get( i ) );
             reminder.setWhenToSend( whenToSend.get( i ) );
-            UserGroup selectedUserGroup = userGroupService.getUserGroup( userGroup.get( i ) );
-            reminder.setUserGroup( selectedUserGroup );
+            
+            if ( reminder.getSendTo() == PatientReminder.SEND_TO_USER_GROUP )
+            {
+                UserGroup selectedUserGroup = userGroupService.getUserGroup( userGroup.get( i ) );
+                reminder.setUserGroup( selectedUserGroup );
+            }
+            else
+            {
+                reminder.setUserGroup( null );
+            }
             patientReminders.add( reminder );
         }
         program.setPatientReminders( patientReminders );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2013-07-26 09:32:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2013-07-29 07:52:18 +0000
@@ -294,7 +294,7 @@
 				+ '<tr name="tr' + rowId + '">'
 				+ 	'<td><label>' + i18n_send_to + '</label></td>'
 				+ 	'<td>'
-				+ 		'<select id="sendTo' + rowId + '" name="sendTo' + rowId + '" class="sendTo" >'
+				+ 		'<select id="sendTo' + rowId + '" name="sendTo' + rowId + '" class="sendTo" onchange="onchangeUserGroup('+ rowId +')">'
 				+ 			'<option value="1">' + i18n_patient + '</option>'
 				+ 			'<option value="2">' + i18n_health_worker + '</option>'
 				+ 			'<option value="3">' + i18n_orgunit_registered + '</option>'
@@ -303,7 +303,7 @@
 				+ 		'</select>'
 				+	'</td>'
 				+ '/<tr>'
-				+ '<tr name="tr' + rowId + '">'
+				+ '<tr name="tr' + rowId + '" id="tr' + rowId + '">'
 				+ 	'<td><label>' + i18n_user_group + '</label></td>'
 				+ 	'<td>'
 				+	program_SMS_reminder_form
@@ -329,6 +329,19 @@
 				+ '</tr>';
 
 	jQuery('#programStageMessage').append( contend );
+	showHideUserGroup();
+}
+
+function showHideUserGroup()
+{
+	jQuery(".sendTo").each( function( i, item ){
+		var numb = i+1;
+		if( item.value == 5){
+			showById( 'tr'+numb );
+		}
+		else
+			hideById ( 'tr'+numb );
+	});
 }
 
 function removeTemplateMessageForm( rowId )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2013-07-25 02:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2013-07-29 07:52:18 +0000
@@ -6,7 +6,9 @@
 	program_SMS_reminder_form +="</select>";	
 	jQuery( document ).ready( function()
 	{
-		validation( 'updateProgramForm', function( form ){ 
+		showHideUserGroup();
+		
+		validation( 'updateProgramForm', function( form ){
 			if( duplicate==true) 
 				return false;
 			else{
@@ -84,8 +86,17 @@
 			});
 		};
 	});
-	checkValueIsExist( "name", "validateProgram.action",{id:getFieldValue('id')} );	
+	checkValueIsExist( "name", "validateProgram.action",{id:getFieldValue('id')} );
 });
+	function onchangeUserGroup( id )
+	{
+		var value = document.getElementById( 'sendTo'+id ).value;
+		hideById( 'tr'+id );
+		if ( value == 5) {
+			showById( 'tr'+id );
+		}
+	};
+	
 </script>
 
 <h3>$i18n.getString( "edit_program" )</h3>
@@ -334,7 +345,7 @@
 				<tr name="tr$index">
 					<td><label>$i18n.getString( "send_to" )</label></td>
 					<td>
-						<select type="text" id="sendTo$index" name="sendTo$index" class="sendTo {validate:{required:true,number:true}}">
+						<select type="text" id="sendTo$index" name="sendTo$index" class="sendTo {validate:{required:true,number:true}}" onchange="onchangeUserGroup( $index )">
 							<option value="1" #if($!reminder.sendTo==1) selected #end >$i18n.getString("patient")</option>
 							<option value="2" #if($!reminder.sendTo==2) selected #end >$i18n.getString("health_worker")</option>
 							<option value="3" #if($!reminder.sendTo==3) selected #end >$i18n.getString("orgunit_registered")</option>
@@ -343,7 +354,7 @@
 						</select>
 					</td>
 				</tr>
-				<tr name="tr$index">
+				<tr name="tr$index" id="tr$index">
 					<td><label>$i18n.getString( "user_group" )</label></td>
 					<td>
 						<select type="text" id="userGroup$index" name="userGroup$index" class="userGroup">