← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11206: Improve Search available person UI.

 

------------------------------------------------------------
revno: 11206
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-06-13 14:36:43 +0700
message:
  Improve Search available person UI.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRelationshipAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/female_small.png
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.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/java/org/hisp/dhis/caseentry/action/patient/SaveRelationshipAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRelationshipAction.java	2012-07-30 03:39:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRelationshipAction.java	2013-06-13 07:36:43 +0000
@@ -155,7 +155,7 @@
 
         relationship.setRelationshipType( relationshipType );
         relationshipService.saveRelationship( relationship );
-
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java	2012-06-12 07:46:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java	2013-06-13 07:36:43 +0000
@@ -123,7 +123,7 @@
     {
         return patients;
     }
-
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-06-10 08:45:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-06-13 07:36:43 +0000
@@ -749,9 +749,8 @@
 
     <action name="searchRelationshipPatient"
       class="org.hisp.dhis.caseentry.action.patient.SearchRelationshipPatientAction">
-      <result name="success" type="velocity-json">
-        /dhis-web-caseentry/responseRelationshipPatients.vm
-      </result>
+      <result name="success" type="velocity">/content.vm</result>
+      <param name="page">/dhis-web-caseentry/relationshipPatients.vm</param>
       <param name="requiredAuthorities">F_RELATIONSHIP_ADD</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm	2013-06-12 04:19:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm	2013-06-13 07:36:43 +0000
@@ -23,57 +23,37 @@
 
 <form id="relationshipSelectForm" name="relationshipSelectForm" method="post" action="showAddRelationshipForm.action">
 <input type="hidden" id="patientId" name="patientId" value="$patient.id"/>
+
 <table>
-<tr>
-    <td class='information'>
-        <table>
-			<tr>
-				<th colspan='2'>$i18n.getString('patient_profile')</th>
-			</tr>
-            <tr>
-                <td class="bold">$i18n.getString( "full_name" ):</td>
-                <td>           
-                    $encoder.htmlEncode( $patient.getFullName() )  
-                </td>
-            </tr>
-            <tr>
-                <td class="bold">$i18n.getString( "gender" ):</td>
-                <td>            
-                    #if($patient.gender=='F')
-						<img src='images/female_small.png'>
-					#else
-						<img src='images/male_small.png'>
-					#end
-                </td>
-            </tr>    
-            <tr>
-                <td class="bold">$i18n.getString( "date_of_birth" ):</td>
-                <td>            
-                    $format.formatDate( $patient.birthDate )
-                </td>
-            </tr>
-            <tr>
-                <td class="bold">$i18n.getString( "age" ):</td>
-                <td>            
-                    $encoder.htmlEncode( $patient.getAge() )
-                </td>
-            </tr>    
-            <tr>
-                <td>&nbsp;</td>
-            </tr>
-        </table>
-    </td>    
+	<tr>
+		<td class='information'>
+			<table>
+				<tr align='justify'>
+					<td colspan='2'>$patient.getFullName()
+						#if($patient.gender=='F')
+							<img src='images/female_small.png'>
+						#else
+							<img src='images/male_small.png'>
+						#end
+					</td>
+				</tr>
+				<tr>
+					<td>$i18n.getString('date_of_birth'):</td>
+					<td>$!format.formatDate($!patient.birthDate)</td>
+				</tr>
+				<tr>
+					<td>$i18n.getString('age'):</td>
+					<td>$!patient.getAge()</td>
+				</tr>
+			</table>
+		</td>
+		
     <td class='information'>
         <table>  
-			<tr>
-				<th colspan='2'>$i18n.getString('relationship_for') $patient.getFullName()</th>
-			</tr>
-            <tr>
+			 <tr>
                 <td>$encoder.htmlEncode( $patient.getFullName() ) $i18n.getString( "is" )</td>
-            </tr>
-            <tr>  
-                <td>
-                    <select id="relationshipTypeId" name="relationshipTypeId" class="{validate:{required:true}}" >
+               <td>
+                    <select id="relationshipTypeId" name="relationshipTypeId" class="{validate:{required:true}}" style='width:205px;'>
                         <option value="">[$i18n.getString( "select_relationship" )]</option>
                         #foreach( $relationshipType in $relationshipTypes )                        
                             <option value="$relationshipType.id:$encoder.htmlEncode( $relationshipType.aIsToB )" #if( $relationshipTypeId && "$relationshipType.id:$encoder.htmlEncode( $relationshipType.aIsToB )" == $relationshipTypeId ) selected="selected" #end>$encoder.htmlEncode( $relationshipType.bIsToA ) $i18n.getString("of") $encoder.htmlEncode( $relationshipType.aIsToB ) </option>
@@ -85,47 +65,28 @@
                                     
             <tr>           
                 <td>
-                    <select id="searchingAttributeId" name="searchingAttributeId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end style='width:119px'>
+                    <select id="searchingAttributeId" name="searchingAttributeId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end style='width:200px;'>
                         <option value="">$i18n.getString( "search_by_name_identifier" )</option>
                         #foreach( $attribute in $patientAttributes )
                             <option value="$attribute.id" #if( $searchingAttributeId && $attribute.id == $searchingAttributeId ) selected="selected" #end>$encoder.htmlEncode( $attribute.displayName )</option>
                         #end
                     </select> 
                     <em title="$i18n.getString( 'required' )" class="required">*</em>
-                    <input type="text" id="searchText" name="searchText" maxlength="30" onchange="validateSearchPartner();" style='width:119px'/>        
-                    <input type="button" value="$i18n.getString( 'search' )" onclick="validateSearchPartner();" class='large-button' />
+				</td>
+				<td>
+				   <input type="text" id="searchText" name="searchText" maxlength="30" style='width:200px;'/>        
+                   <input type="button" value="$i18n.getString( 'search' )" onclick="validateSearchPartner();" class='large-button' />
                 </td> 
             </tr>                  
-            <tr>  
-                <td> 
-                    $i18n.getString( "result_matching_the_search_criteria" )
-                    #if( $searchText )  
-                        $encoder.htmlEncode( $searchText ) 
-                    #end
-                </td>                               
-            </tr>  
-            <tr>
-                <td colspan='2'>
-                    <select size="15" id="availablePartnersList" name="availablePartnersList" class="{validate:{required:true}}">                        
-                        #foreach ( $partner in $patients )
-                            <option value="$partner.id"> $encoder.htmlEncode( $partner.getFullName() )</option>
-                        #end                
-                    </select>
-                </td>                     
-            </tr>
-            <tr>
-            	<td>
-					<input type="button" value="$i18n.getString( 'assign_relationship' )" onclick="javascript:validateAddRelationship()" />
-					<input type="button" value="$i18n.getString( 'cancel' )" onclick="showRelationshipList($patient.id)" />
-				</td>
-            </tr>            
         </table>
     </td>
 </tr>
-</table>       
+</table>
 </form>
 
+<div id='searchRelationshipDiv'></div>
+
 <script type="text/javascript">
-    var i18n_please_select_relationship_type = '$encoder.jsEscape( $i18n.getString( "please_select_relationship_type" ) , "'" )';
+	var i18n_please_select_relationship_type = '$encoder.jsEscape( $i18n.getString( "please_select_relationship_type" ) , "'" )';
     var i18n_please_select_partner = '$encoder.jsEscape( $i18n.getString( "please_select_partner" ) , "'" )';    
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/female_small.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/female_small.png	2013-06-11 06:36:03 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/female_small.png	2013-06-13 07:36:43 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js	2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js	2013-06-13 07:36:43 +0000
@@ -209,6 +209,7 @@
 
 function validateSearchPartner()
 {
+	hideById('searchRelationshipDiv');
 	$.ajax({
 		url: 'validateSearchRelationship.action',
 		type:"POST",
@@ -227,27 +228,13 @@
 	if( type == 'success' )
 	{
 		jQuery('#loaderDiv').show();
-		jQuery("#relationshipSelectForm :input").each(function()
-			{
-				jQuery(this).attr('disabled', 'disabled');
-			});
-			
 		$.ajax({
 			type: "GET",
 			url: 'searchRelationshipPatient.action',
 			data: getParamsForDiv('relationshipSelectForm'),
-			success: function( json ) {
-				clearListById('availablePartnersList');
-				for ( i in json.patients ) 
-				{
-					addOptionById( 'availablePartnersList', json.patients[i].id, json.patients[i].fullName );
-				} 
-				
-				jQuery("#relationshipSelectForm :input").each(function()
-					{
-						jQuery(this).removeAttr('disabled');
-					});
-					
+			success: function( html ) {
+				setInnerHTML('searchRelationshipDiv',html);
+				showById('searchRelationshipDiv');
 				jQuery('#loaderDiv').hide();
 			}
 		});
@@ -263,11 +250,9 @@
 	}
 }
 
-function validateAddRelationship()
+function validateAddRelationship(partnerId)
 {
-	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();
-	var partnerId = jQuery( '#relationshipSelectForm [id=availablePartnersList]' ).val();
-	
+	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();	
 	if( relationshipTypeId==''){
 		showWarningMessage( i18n_please_select_relationship_type );
 		return;
@@ -276,14 +261,12 @@
 		showWarningMessage( i18n_please_select_a_patient_for_setting_relationship );
 		return;
 	}
-	addRelationship();
+	addRelationship(partnerId);
 }
 
-function addRelationship() 
+function addRelationship(partnerId) 
 {
-	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();
-	var partnerId = jQuery( '#relationshipSelectForm [id=availablePartnersList]' ).val();
-	
+	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();	
 	var relTypeId = relationshipTypeId.substr( 0, relationshipTypeId.indexOf(':') );
 	var relName = relationshipTypeId.substr( relationshipTypeId.indexOf(':') + 1, relationshipTypeId.length );
 	
@@ -292,40 +275,32 @@
 		'&relationshipTypeId=' + relTypeId +
 		'&relationshipName=' + relName ;
 	
-	jQuery('#loaderDiv').show();
-	
 	$.ajax({
 		url: 'saveRelationship.action',
 		type:"POST",
 		data: params,
 		dataType: "xml",
-		success: addRelationshipCompleted
-		}); 
+		success:  function( messageElement ) {
+			messageElement = messageElement.getElementsByTagName( 'message' )[0];
+			var type = messageElement.getAttribute( 'type' );
+			var message = messageElement.firstChild.nodeValue;
+			
+			if( type == 'success' ){
+				jQuery('#searchRelationshipDiv [id=tr' + partnerId + ']').css("background-color","#C0C0C0")
+				showSuccessMessage( i18n_save_success );
+			}	
+			else if( type == 'error' ){
+				showErrorMessage( i18n_adding_relationship_failed + ':' + '\n' + message );
+			}
+			else if( type == 'input' ){
+				showWarningMessage( message );
+			}
+		}
+	}); 
 		
 	return false;
 }
 
-function addRelationshipCompleted( messageElement )
-{
-	messageElement = messageElement.getElementsByTagName( 'message' )[0];
-	var type = messageElement.getAttribute( 'type' );
-	var message = messageElement.firstChild.nodeValue;
-	
-	if( type == 'success' )
-	{
-		showSuccessMessage( i18n_save_success );
-	}	
-	else if( type == 'error' )
-	{
-		showErrorMessage( i18n_adding_relationship_failed + ':' + '\n' + message );
-	}
-	else if( type == 'input' )
-	{
-		showWarningMessage( message );
-	}
-	jQuery('#loaderDiv').hide();
-}
-
 //------------------------------------------------------------------------------
 // Remove Relationship
 //------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2013-06-12 04:19:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2013-06-13 07:36:43 +0000
@@ -28,7 +28,7 @@
 	</tr>
 	<tr>
 		<td style="background-color:#88be3b; height:26px;">&nbsp;</td>
-		<td>$i18n.getString('dob_type'):</td>
+		<td>$i18n.getString('date_of_birth'):</td>
 		<td>$!format.formatDate($!patient.birthDate)</td>
 	</tr>
 	<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-05-29 15:42:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-06-13 07:36:43 +0000
@@ -3,7 +3,7 @@
 <input type="hidden" id='hideLink' name='hideLink' value='false'>
 <input type='hidden' id='isSearchByProgram' name='isSearchByProgram' value='false' >
 
-<table style="margin-bottom:8px">    
+<table style="margin-bottom:8px" id="commonSearchDiv" name="commonSearchDiv">    
 	<tr>
 		<td>
 			<label>$i18n.getString( "registering_unit" )</label>
@@ -68,7 +68,7 @@
 	</tr>
 </table>
 
-<div id='advanced-search' class='hidden advanced-search'>
+<div id='advanced-search' name='advanced-search' class='hidden advanced-search'>
 	<table>	
 		#if( $auth.hasAccess( "dhis-web-caseentry", "searchAllFacilities" ) )
 			<tr id='searchBySelectedUnitTD'>