← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8723: Add validation in Add/Update program-stage-section. A section has to have at least one data element.

 

------------------------------------------------------------
revno: 8723
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-26 10:49:36 +0700
message:
  Add validation in Add/Update program-stage-section. A section has to have at least one data element.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageSectionForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.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-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageSectionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageSectionForm.vm	2012-10-26 03:26:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageSectionForm.vm	2012-10-26 03:49:36 +0000
@@ -3,6 +3,11 @@
 {
 	validation( 'programStageSectionForm', function(form){
 		form.submit();
+	}, function(){
+		selectAllById('dataElementIds');
+		if(jQuery("#dataElementIds option").length > 0 ){
+			setFieldValue('hasDataElement', 'true');
+		}
 	});
 	checkValueIsExist( "name", "validateProgramStageSection.action");
 	byId('name').focus();
@@ -11,11 +16,11 @@
 
 <h3>$i18n.getString( "create_new_program_stage_section" )</h3>
 
-</h4>$programStage.name</h4>
+<h4>$programStage.name</h4>
 																		
-<form id="programStageSectionForm" name="programStageSectionForm" onsubmit="selectAllById('dataElementIds');" action="addProgramStageSection.action" method="post">
-	<input type="hidden" id="programStageId" name="programStageId" value="$programStage.id"/>
+<form id="programStageSectionForm" name="programStageSectionForm" method="post">
 
+<input type="hidden" id="programStageId" name="programStageId" value="$programStage.id"/>
 <table>
 	<thead>
 		<tr><th colspan="2">$i18n.getString( "program_stage_details" )</th></tr>
@@ -33,7 +38,10 @@
       <tr>        
         <th>$i18n.getString( "available_data_elements" )</th>
         <th></th>
-        <th>$i18n.getString( "selected_data_elements" )</th>
+        <th>
+			$i18n.getString( "selected_data_elements" )
+			<input type='hidden' id='hasDataElement' name='hasDataElement' class="{validate:{required:true}}">
+		</th>
       </tr>
     </thead>
   
@@ -67,7 +75,7 @@
 </table>
 <p>
 	<input type="submit" value="$i18n.getString( 'add' )"/>
-	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStageSectionList.action?id=$programStageId'" />
+	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStageSectionList.action?id=$programStage.id'" />
 </p>
 
 </form> 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm	2012-10-26 03:26:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm	2012-10-26 03:49:36 +0000
@@ -2,7 +2,12 @@
 jQuery( document ).ready( function()
 {
 	validation( 'programStageSectionForm', function(form){
+		selectAllById('dataElementIds');
 		form.submit();
+	}, function(){
+		if(jQuery("#dataElementIds option").length > 0 ){
+			setFieldValue('hasDataElement', 'true');
+		}
 	});
 		
 	checkValueIsExist( "name", "validateProgramStageSection.action", {id:getFieldValue('id')});	
@@ -12,9 +17,9 @@
 
 <h3>$i18n.getString( "update_program_stage_section" )</h3>
 			
-</h4>$programStage.name</h4>
+<h4>$programStage.name</h4>
 			
-<form id="programStageSectionForm" name="programStageSectionForm" onsubmit="selectAllById('dataElementIds');" action="updateProgramStageSection.action" method="post">
+<form id="programStageSectionForm" name="programStageSectionForm" method="post">
 	<input type="hidden" id="programStageId" name="programStageId" value="$programStage.id"/>
 	<input type="hidden" id="id" name="id" value="$section.id"/>
 
@@ -35,7 +40,10 @@
       <tr>        
         <th>$i18n.getString( "available_data_elements" )</th>
         <th></th>
-        <th>$i18n.getString( "selected_data_elements" )</th>
+        <th>
+			$i18n.getString( "selected_data_elements" )
+			<input type='hidden' id='hasDataElement' name='hasDataElement' class="{validate:{required:true}}">
+		</th>
       </tr>
     </thead>
   
@@ -73,7 +81,7 @@
 </table>
 <p>
 	<input type="submit" value="$i18n.getString( 'update' )"/>
-	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStageSectionList.action?id=$programStageId'" />
+	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStageSectionList.action?id=$programStage.id'" />
 </p>
 
 </form>