← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18606: allow null periodType for program stage. If a period type is defined for a program stage then no ...

 

------------------------------------------------------------
revno: 18606
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-16 09:11:46 +0100
message:
  allow null periodType for program stage. If a period type is defined for a program stage then no need to define standard interval.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.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/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java	2015-03-16 08:11:46 +0000
@@ -33,6 +33,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.period.PeriodService;
@@ -362,8 +363,7 @@
         remindCompleted = (remindCompleted == null) ? false : remindCompleted;
         allowGenerateNextVisit = (allowGenerateNextVisit == null) ? false : allowGenerateNextVisit;
         openAfterEnrollment = (openAfterEnrollment == null) ? false : openAfterEnrollment;
-        preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID; 
-
+        preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID;
 
         ProgramStage programStage = new ProgramStage();
         Program program = programService.getProgram( id );
@@ -377,12 +377,18 @@
         programStage.setMinDaysFromStart( minDaysFromStart );
         programStage.setDisplayGenerateEventBox( displayGenerateEventBox );
         programStage.setValidCompleteOnly( validCompleteOnly );
+        
+        periodTypeName = StringUtils.trimToNull( periodTypeName );
+        
         if( periodTypeName != null )
         {
-
             PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName );
             programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) );
         }
+        else{
+            programStage.setPeriodType( null );
+        }
+        
         
         if ( program.isSingleEvent() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java	2015-03-16 08:11:46 +0000
@@ -33,6 +33,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.period.PeriodService;
@@ -379,11 +380,16 @@
         programStage.setReportDateToUse( reportDateToUse );
         programStage.setPreGenerateUID( preGenerateUID );
         
+        periodTypeName = StringUtils.trimToNull( periodTypeName );
+        
         if( periodTypeName != null )
         {
             PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName );
             programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) );
         }
+        else{
+            programStage.setPeriodType( null );
+        }
         
         if ( programStage.getProgram().isSingleEvent() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm	2015-03-16 08:11:46 +0000
@@ -43,24 +43,9 @@
 	</tr>
 	
 	<tr>
-		<td><label for="displayGenerateEventBox">$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
-		<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' checked disabled /></td>
-	</tr>
-	
-	<tr>
-		<td><label for="customStandardInterval">$i18n.getString( "custom_standard_interval" )</label></td>
-		<td><input type="checkbox" id="customStandardInterval" name="customStandardInterval" checked disabled onchange=" customStandardIntervalOnChange()" /></td>
-	</tr>
-	
-	<tr>
-		<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
-		<td><input type="text" id="standardInterval" name="standardInterval" disabled /></td>
-	</tr>
-	
-	<tr>
 		<td><label for="periodTypeName">$i18n.getString( "period_type" )</label></td>
 		<td>
-			<select id="periodTypeName" name="periodTypeName" disabled>
+			<select id="periodTypeName" name="periodTypeName" disabled onchange='periodTypeOnChange();'>
 				<option value="">[$i18n.getString("please_select")]</option>
 				#foreach( $periodType in $periodTypes )
 					  <option value="$periodType.name">$i18n.getString( $periodType.name )</option>
@@ -68,6 +53,16 @@
 			</select>
 		</td>
 	</tr>
+      	
+	<tr>
+		<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
+		<td><input type="text" id="standardInterval" name="standardInterval" disabled /></td>
+	</tr>
+	
+	<tr>
+		<td><label for="displayGenerateEventBox">$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
+		<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' checked disabled /></td>
+	</tr>
 	
 	#end
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js	2015-03-16 08:11:46 +0000
@@ -8,15 +8,7 @@
 		'beforeValidateHandler' : function()
 		{
 			selectAllById('selectedIndicators');
-		
-			var customStandardInterval = byId('customStandardInterval').checked;
-			if( customStandardInterval ){
-				setFieldValue('periodTypeName','');
-			}
-			else{
-				setFieldValue('standardInterval','');
-			}
-				
+							
 			var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
 			selectedDataElementsValidator.empty();
 			

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js	2015-03-16 08:11:46 +0000
@@ -265,34 +265,27 @@
 	var checked = byId('irregular').checked;
 	if( checked )
 	{
+		enable('standardInterval');
+		enable('periodTypeName');
 		enable('displayGenerateEventBox');
-		enable('customStandardInterval');
-		enable('periodTypeName');
 	}
 	else
 	{
+		disable('standardInterval');
+		disable('periodTypeName');
 		disable('displayGenerateEventBox');
-		disabled('customStandardInterval');
-		disabled('periodTypeName');
 	}
-	customStandardIntervalOnChange();
 }
 
-function customStandardIntervalOnChange()
-{
-	var checked = byId('customStandardInterval').checked;
-	if( checked )
-	{
+function periodTypeOnChange(){
+	var periodType = byId('periodTypeName').value;	
+	if( periodType != ''){
+		disable('standardInterval');
+	}
+	else{
 		enable('standardInterval');
-		disable('periodTypeName');
-	}
-	else
-	{
-		disable('standardInterval');
-		enable('periodTypeName');
 	}
 }
-
 // --------------------------------------------------------------------
 // Generate template message form
 // --------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js	2015-03-16 08:11:46 +0000
@@ -11,13 +11,19 @@
 		{
 			selectAllById('selectedIndicators');
 			
-			var customStandardInterval = byId('customStandardInterval').checked;
+			var periodType = byId('periodTypeName').value;	
+			if( periodType != ''){
+				setFieldValue('standardInterval','');
+			}
+	
+			
+			/*var customStandardInterval = byId('customStandardInterval').checked;
 			if( customStandardInterval ){
 				setFieldValue('periodTypeName','');
 			}
 			else{
 				setFieldValue('standardInterval','');
-			}
+			}*/
 			
 			var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
 			selectedDataElementsValidator.empty();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm	2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm	2015-03-16 08:11:46 +0000
@@ -47,35 +47,30 @@
 	
 			<tr>
 				<td><label for="irregular">$i18n.getString( "repeatable" )</label></td>
-				<td><input type="checkbox" id="irregular" name="irregular" value='true' #if( $programStage.irregular && $programStage.irregular=='true' ) checked #end onchange='repeatableOnChange();' /></td>
-			</tr>	
-
-			<tr>
-				<td><label for="displayGenerateEventBox">$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
-				<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' #if( $programStage.displayGenerateEventBox && $programStage.displayGenerateEventBox=='true' ) checked #end /></td>
-			</tr>
-
-			<tr>
-				<td><label for="customStandardInterval">$i18n.getString( "custom_standard_interval" )</label></td>
-				<td><input type="checkbox" id="customStandardInterval" name="customStandardInterval" #if($!programStage.periodType) #else checked #end #if($programStage.irregular!='true' ) disabled #end onchange=" customStandardIntervalOnChange()" /></td>
-			</tr>
+				<td><input type="checkbox" id="irregular" name="irregular" value='true' #if( $programStage.irregular && $programStage.irregular == 'true' ) checked #end onchange='repeatableOnChange();' /></td>
+			</tr>			
 			
 			<tr>
-				<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
-				<td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval'#if($programStage.irregular!='true' ) disabled #end #if($!programStage.periodType) disabled #end #if($programStage.irregular!='true' ) disabled #end  #if($programStage.irregular!='true' ) disabled checked #end /></td>
-			</tr>
-						
-			<tr>
 				<td><label for="periodTypeName">$i18n.getString( "period_type" )</label></td>
 				<td>
-					<select id="periodTypeName" name="periodTypeName" #if($!programStage.periodType) #else disabled #end  #if($programStage.irregular!='true' ) disabled checked #end >
-						<option value="">[$i18n.getString("please_select")]</option>
+					<select id="periodTypeName" name="periodTypeName" #if( $programStage.irregular !='true' ) disabled #end onchange='periodTypeOnChange();'>
+						<option value=''>[$i18n.getString('please_select')]</option>
 						#foreach( $periodType in $periodTypes )
-						<option value="$periodType.name" #if($programStage.periodType.name=="$periodType.name") selected #end >$i18n.getString( $periodType.name )</option>
-						#end
+						  <option value="$periodType.name" #if($programStage.periodType.name == "$periodType.name") selected #end>$i18n.getString( $periodType.name )</option>
+				  	    #end
 					</select>
 				</td>
 			</tr>
+				
+			<tr>
+				<td><label for="displayGenerateEventBox">$i18n.getString( "display_generate_event_box_after_completed" )</label></td>
+				<td><input type="checkbox" id="displayGenerateEventBox" name="displayGenerateEventBox" value='true' #if( $programStage.displayGenerateEventBox && $programStage.displayGenerateEventBox=='true' ) checked #end #if($programStage.irregular!='true' ) disabled checked #end /></td>
+			</tr>
+
+			<tr>
+				<td><label for="standardInterval">$i18n.getString( "standard_interval_days" )</label></td>
+				<td><input type="text" id="standardInterval" name="standardInterval" value='$!programStage.standardInterval' #if( $programStage.irregular != 'true' || $programStage.periodType && $programStage.periodType.name != '' ) disabled #end /></td>
+			</tr>
 			
 			#end