← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7750: Exception when setting a relationship for person.

 

------------------------------------------------------------
revno: 7750
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-30 10:39:34 +0700
message:
  Exception when setting a relationship for person.
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/resources/org/hisp/dhis/caseentry/i18n_module.properties
  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/javascript/relationshipPatient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.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	2011-09-14 06:36:13 +0000
+++ 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
@@ -146,20 +146,16 @@
         {
             relationship.setPatientA( partner );
             relationship.setPatientB( patient );
-
-            relationship.setRelationshipType( relationshipType );
-            relationshipService.saveRelationship( relationship );
-
         }
         else if ( relationshipType.getbIsToA().equalsIgnoreCase( relationshipName ) )
         {
             relationship.setPatientA( patient );
             relationship.setPatientB( partner );
-
-            relationship.setRelationshipType( relationshipType );
-            relationshipService.saveRelationship( relationship );
         }
 
+        relationship.setRelationshipType( relationshipType );
+        relationshipService.saveRelationship( relationship );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-07-28 13:37:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-07-30 03:39:34 +0000
@@ -384,4 +384,6 @@
 incomplete_confirm_message=Are you sure this event is incompleted ?
 incomplete = Incomplete
 remove_empty_events_success = Remove empty events successfully
-confirm_remove_empty_events = Are you sure you want to remove empty events ?
\ No newline at end of file
+confirm_remove_empty_events = Are you sure you want to remove empty events ?
+please_select_relationship_type = Please select a relationship type
+please_select_a_patient_for_setting_relationship = Please select a person for setting relationship
\ No newline at end of file

=== 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	2012-07-04 05:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm	2012-07-30 03:39:34 +0000
@@ -1,5 +1,5 @@
 <script>
-	jQuery('#relationshipSelectForm').ready(	function(){
+	jQuery('#relationshipSelectForm').ready(function(){
 		
 		jQuery('name').focus();
 			
@@ -103,7 +103,7 @@
             </tr>
             <tr>
             	<td>
-					<input type="button" value="$i18n.getString( 'assign_relationship' )" onclick="javascript:addRelationship()" />
+					<input type="button" value="$i18n.getString( 'assign_relationship' )" onclick="javascript:validateAddRelationship()" />
 					<input type="button" value="$i18n.getString( 'back_to_relationship' )" onclick="showRelationshipList($patient.id)" />
 				</td>
             </tr>            

=== 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-06-25 02:11:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js	2012-07-30 03:39:34 +0000
@@ -259,9 +259,25 @@
 	}
 }
 
+function validateAddRelationship()
+{
+	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();
+	var partnerId = jQuery( '#relationshipSelectForm [id=availablePartnersList]' ).val();
+	
+	if( relationshipTypeId==''){
+		showWarningMessage( i18n_please_select_relationship_type );
+		return;
+	}
+	if( partnerId==null){
+		showWarningMessage( i18n_please_select_a_patient_for_setting_relationship );
+		return;
+	}
+	addRelationship();
+}
+
 function addRelationship() 
 {
-	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId]' ).val();
+	var relationshipTypeId = jQuery( '#relationshipSelectForm [id=relationshipTypeId] option:selected' ).val();
 	var partnerId = jQuery( '#relationshipSelectForm [id=availablePartnersList]' ).val();
 	
 	var relTypeId = relationshipTypeId.substr( 0, relationshipTypeId.indexOf(':') );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-07-26 09:48:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2012-07-30 03:39:34 +0000
@@ -99,6 +99,9 @@
 	var i18n_male = '$encoder.jsEscape( $i18n.getString( "male" ) , "'")';
 	var i18n_female = '$encoder.jsEscape( $i18n.getString( "female" ) , "'")';
 	var i18n_transgender = '$encoder.jsEscape( $i18n.getString( "transgender" ) , "'")';
+	var i18n_add_person_successfully = '$encoder.jsEscape( $i18n.getString( "add_person_successfully" ) , "'")';
+	var i18n_please_select_relationship_type = '$encoder.jsEscape( $i18n.getString( "please_select_relationship_type" ) , "'")';
+	var i18n_please_select_a_patient_for_setting_relationship = '$encoder.jsEscape( $i18n.getString( "please_select_a_patient_for_setting_relationship" ) , "'")';
 	
 	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
 	var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';