← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19172: Fixed bug - The relationshipType cannot be removed from an program.

 

------------------------------------------------------------
revno: 19172
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-05-21 23:37:34 +0700
message:
  Fixed bug - The relationshipType cannot be removed from an program.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/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-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java	2015-03-31 11:41:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java	2015-05-21 16:37:34 +0000
@@ -274,20 +274,23 @@
             program.setIgnoreOverdueEvents( false );
         }
 
-        if ( relatedProgramId != null )
-        {
-            Program relatedProgram = programService.getProgram( relatedProgramId );
-            program.setRelatedProgram( relatedProgram );
-        }
-
         if ( relationshipTypeId != null )
         {
             RelationshipType relationshipType = relationshipTypeService.getRelationshipType( relationshipTypeId );
             program.setRelationshipType( relationshipType );
-        }
-
-        program.setRelationshipFromA( relationshipFromA );
-        program.setRelationshipText( relationshipText );
+            program.setRelationshipFromA( relationshipFromA );
+            program.setRelationshipText( relationshipText ); 
+            
+            Program relatedProgram = programService.getProgram( relatedProgramId );
+            program.setRelatedProgram( relatedProgram );
+        }
+        else
+        {
+            program.setRelationshipType( null );
+            program.setRelationshipFromA( null );
+            program.setRelationshipText( null );
+            program.setRelatedProgram( null );
+        }
 
         if ( trackedEntityId != null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java	2015-05-21 16:37:34 +0000
@@ -297,20 +297,23 @@
             program.setIgnoreOverdueEvents( false );
         }
 
-        if ( relatedProgramId != null )
-        {
-            Program relatedProgram = programService.getProgram( relatedProgramId );
-            program.setRelatedProgram( relatedProgram );
-        }
-
         if ( relationshipTypeId != null )
         {
             RelationshipType relationshipType = relationshipTypeService.getRelationshipType( relationshipTypeId );
             program.setRelationshipType( relationshipType );
-        }
-
-        program.setRelationshipFromA( relationshipFromA );
-        program.setRelationshipText( relationshipText );
+            program.setRelationshipFromA( relationshipFromA );
+            program.setRelationshipText( relationshipText ); 
+            
+            Program relatedProgram = programService.getProgram( relatedProgramId );
+            program.setRelatedProgram( relatedProgram );
+        }
+        else
+        {
+            program.setRelationshipType( null );
+            program.setRelationshipFromA( null );
+            program.setRelationshipText( null );
+            program.setRelatedProgram( null );
+        }
 
         if ( trackedEntityId != null )
         {
@@ -345,11 +348,6 @@
             index++;
         }
 
-        if ( relatedProgramId != null )
-        {
-            Program relatedProgram = programService.getProgram( relatedProgramId );
-            program.setRelatedProgram( relatedProgram );
-        }
 
         program.increaseVersion(); //TODO make more fine-grained
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm	2015-04-24 10:20:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm	2015-05-21 16:37:34 +0000
@@ -166,11 +166,6 @@
 		<tr name='nonAnonymous'>
 			<th colspan="2">$i18n.getString( "dashboard_shortcut_to_add_relative" )</th>
 		</tr>
-		
-		<tr name='nonAnonymous'>
-			<td><label for="relationshipText">$i18n.getString("shortcut_link_label_eg_add_child")</label></td>
-			<td><input type='text' id='relationshipText' name='relationshipText' ></td>
-		</tr>
 
 		<tr name='nonAnonymous'>
 			<td><label for="relationshipTypeId">$i18n.getString("relationship_description")</label></td>
@@ -185,16 +180,21 @@
 		</tr>
 
 		<tr name='nonAnonymous'>
+			<td><label for="relationshipText">$i18n.getString("shortcut_link_label_eg_add_child") <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type='text' id='relationshipText' name='relationshipText' disabled class="{validate:{required:true}}" ></td>
+		</tr>
+		
+		<tr name='nonAnonymous'>
 			<td><label for="relationshipFromA">$i18n.getString("who_is_the_new_relative_to_the_existing_tracked_entity_instance")</label></td>
 			<td>
-				<select type='text' id='relationshipFromA' name='relationshipFromA'></select>
+				<select type='text' id='relationshipFromA' name='relationshipFromA' disabled></select>
 			</td>
 		</tr>
 		
 		<tr name='nonAnonymous'>
-			<td><label for="relatedProgramId">$i18n.getString("program_for_new_relative_to_be_enrolled_in")</label></td>
+			<td><label for="relatedProgramId">$i18n.getString("program_for_new_relative_to_be_enrolled_in") <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td>
-				<select type='text' id='relatedProgramId' name='relatedProgramId' >
+				<select type='text' id='relatedProgramId' name='relatedProgramId' class="{validate:{required:true}}" disabled>
 					<option value=''>[$i18n.getString("please_select")]</option>
 					#foreach($program in $programs)
 						<option value='$program.id'>$program.name</option>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-04-11 13:18:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-05-21 16:37:34 +0000
@@ -92,16 +92,31 @@
 }
 
 function relationshipTypeOnchange() {
-  clearListById('relationshipSide');
+  
+  clearListById('relationshipFromA');
+  var relationshipSide = jQuery("#relationshipFromA");
   var relationshipType = jQuery('#relationshipTypeId option:selected');
   if( relationshipType.val() != "" ) {
+  
+	enable('relationshipFromA');
+	enable('relatedProgramId');
+	enable('relationshipText');
+	
     var aIsToB = relationshipType.attr('aIsToB');
     var bIsToA = relationshipType.attr('bIsToA');
 
-    var relationshipSide = jQuery("#relationshipFromA");
     relationshipSide.append('<option value="false">' + aIsToB + '</option>');
     relationshipSide.append('<option value="true">' + bIsToA + '</option>');
   }
+  else
+  {
+	clearListById('relationshipFromA'); 
+	jQuery('#relatedProgramId').val(""); 
+	
+	disable('relationshipFromA');
+	disable('relatedProgramId');
+	disable('relationshipText');
+  }
 }
 
 function programOnChange() {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm	2015-04-24 10:20:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm	2015-05-21 16:37:34 +0000
@@ -2,13 +2,14 @@
 	jQuery( document ).ready( function()
 	{
 		validation2( 'updateProgramForm', function( form )
-		{
+		{	
 			enable('dateOfEnrollmentDescription');
 			enable('dateOfIncidentDescription');
 			form.submit();
 		},{
 			'beforeValidateHandler' : function()
 			{
+		
 				#tblDynamicAttributesJavascript()
 
 				var selectedPropertyIds = jQuery( "#selectedPropertyIds" );
@@ -51,6 +52,7 @@
 				else{
 					compulsaryIdentifier.append( "<option value='0' selected='true'></option>");
 				}
+				
 			},
 			'rules' : getValidationRules( "program" )
 		});
@@ -177,11 +179,6 @@
 		</tr>
 		
 		<tr name='nonAnonymous'>
-			<td><label for="relationshipText">$i18n.getString("shortcut_link_label_eg_add_child")</label></td>
-			<td><input type='text' id='relationshipText' name='relationshipText' value='$!program.relationshipText' ></td>
-		</tr>
-		
-		<tr name='nonAnonymous'>
 			<td><label for="relationshipTypeId">$i18n.getString("relationship_description")</label></td>
 			<td>
 				<select type='text' id='relationshipTypeId' name='relationshipTypeId' onchange='relationshipTypeOnchange()' >
@@ -194,21 +191,26 @@
 		</tr>
 		
 		<tr name='nonAnonymous'>
+			<td><label for="relationshipText">$i18n.getString("shortcut_link_label_eg_add_child") <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type='text' id='relationshipText' name='relationshipText' value='$!program.relationshipText' #if($program.relationshipType) #else disabled #end class="{validate:{required:true}}" ></td>
+		</tr>
+		
+		<tr name='nonAnonymous'>
 			<td><label for="relationshipFromA">$i18n.getString("who_is_the_new_relative_to_the_existing_tracked_entity_instance")</label></td>
 			<td>
-				<select id='relationshipFromA' name='relationshipFromA'>
+				<select id='relationshipFromA' name='relationshipFromA' #if($program.relationshipType) #else disabled #end>
 					#if($!program.relationshipType)
-						<option value='false' #if($!program.relationshipFromA=='true') selected #end>$!program.relationshipType.aIsToB</option>
-						<option value='true' #if($!program.relationshipFromA=='false') selected #end>$!program.relationshipType.bIsToA</option>
+						<option value='false' #if($!program.relationshipFromA=='false') selected #end>$!program.relationshipType.aIsToB</option>
+						<option value='true' #if($!program.relationshipFromA=='true') selected #end>$!program.relationshipType.bIsToA</option>
 					#end
 				</select>
 			</td>
 		</tr>
 		
 		<tr name='nonAnonymous'>
-			<td><label for="relatedProgramId">$i18n.getString("program_for_new_relative_to_be_enrolled_in")</label></td>
+			<td><label for="relatedProgramId">$i18n.getString("program_for_new_relative_to_be_enrolled_in") <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td>
-				<select type='text' id='relatedProgramId' name='relatedProgramId' >
+				<select type='text' id='relatedProgramId' name='relatedProgramId' class="{validate:{required:true}}" #if($program.relationshipType) #else disabled #end >
 					<option value=''>[$i18n.getString("please_select")]</option>
 					#set( $relatedProgram = $program.relatedProgram)
 					#foreach($program in $programs)