← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8972: Fix for display details of program-validation-rule.

 

------------------------------------------------------------
revno: 8972
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-11-12 14:21:17 +0700
message:
  Fix for display details of program-validation-rule.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramValidation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.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-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramValidation.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramValidation.vm	2011-09-28 07:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramValidation.vm	2012-11-12 07:21:17 +0000
@@ -2,8 +2,11 @@
   {
     "id": "${validation.id}",
 	"description": "$!encoder.htmlEncode( ${validation.description} )",
-	"leftSide": "$!encoder.htmlEncode( ${validation.leftSide} )",
-	"rightSide": "$!encoder.htmlEncode( ${validation.rightSide} )",
+	"operator": "$!encoder.htmlEncode( ${validation.operator} )",
+	"leftSideDescription": "$!encoder.htmlEncode( ${validation.leftSide.description} )",
+	"leftSideExpression": "$!encoder.htmlEncode( ${validation.leftSide.expression} )",
+	"rightSideDescription": "$!encoder.htmlEncode( ${validation.rightSide.description} )",
+	"rightSideExpression": "$!encoder.htmlEncode( ${validation.leftSide.expression} )",
 	"program": "$!encoder.htmlEncode( ${validation.program.name} )"
   }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2012-11-12 07:04:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js	2012-11-12 07:21:17 +0000
@@ -15,24 +15,49 @@
 {
     jQuery.getJSON( 'getProgramValidation.action', { validationId: programValidationId }, function ( json ) {
 		setInnerHTML( 'descriptionField', json.validation.description );
-		setInnerHTML( 'leftSideField', json.validation.leftSide );
-		if( json.validation.rightSide != '1==1')
-		{
-			setInnerHTML( 'leftSideTitle', i18n_left_side );
-			setInnerHTML( 'rightSideField', json.validation.rightSide );
-			showById('rightSideDiv');
-		}
-		else
-		{
-			setInnerHTML( 'leftSideTitle', i18n_condition );
-			hideById('rightSideDiv');
-		}
-		setInnerHTML( 'programField', json.validation.program );
+		
+		var operator = json.validation.operator;
+		setInnerHTML( 'operatorField', i18nalizeOperator( operator ) );
+		
+		setInnerHTML( 'leftSideDescriptionField', json.validation.leftSideDescription );
+		setInnerHTML( 'leftSideExpressionField', json.validation.leftSideExpression );
+		setInnerHTML( 'rightSideDescriptionField', json.validation.rightSideDescription );
+		setInnerHTML( 'rightSideExpressionField', json.validation.rightSideExpression );
 		
 		showDetails();
 	});
 }
 
+function i18nalizeOperator( operator )
+{
+    if ( operator == "equal_to" )
+    {
+        return i18n_equal_to;
+    }
+    else if ( operator == "not_equal_to" )
+    {
+        return i18n_not_equal_to;
+    }
+    else if ( operator == "greater_than" )
+    {
+        return i18n_greater_than;       
+    }
+    else if ( operator == "greater_than_or_equal_to" )
+    {
+        return i18n_greater_than_or_equal_to;
+    }
+    else if ( operator == "less_than" )
+    {
+        return i18n_less_than;
+    }
+    else if ( operator == "less_than_or_equal_to" )
+    {
+        return i18n_less_than_or_equal_to;
+    }
+    
+    return null;
+}
+
 // -----------------------------------------------------------------------------
 // Remove ProgramValidation
 // -----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-11-12 07:04:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-11-12 07:21:17 +0000
@@ -15,7 +15,6 @@
 					$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
 				</td>
 				<td align="right">
-					<!-- input type="button" value="$i18n.getString( "add_multi_rule" )" onclick="window.location.href='showAddMultiProgramValidationForm.action?id=$program.id'" style="width:100px" -->
 					<input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='program.action'" style="width:100px">
 					<input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddSingleProgramValidationForm.action?id=$program.id'" style="width:100px">
 				</td>
@@ -40,7 +39,6 @@
 					<td onclick="showProgramValidationDetails( $validation.id )">$validation.description</td>
 					<td>
 						<a href="showUpdateSingleProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-						<!-- a href="showUpdateMultiProgramValidationForm.action?validationId=$validation.id&id=$program.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a -->
 						<a href="javascript:removeProgramValidation( '$validation.id', '$encoder.jsEncode( $validation.description )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
 					  <a href="javascript:showProgramValidationDetails( $validation.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
 					</td>
@@ -56,15 +54,17 @@
 					<a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"></a>
 				</div>			
 				<p><label class="bold">$i18n.getString( "name" ):</label><br><span id="descriptionField"></span></p>
-				<p><label class="bold" id='leftSideTitle'>$i18n.getString( "left_side" ):</label><br><span id="leftSideField"></span></p>
-				<p id='rightSideDiv'><label class="bold">$i18n.getString( "right_side" ):</label><br><span id="rightSideField"></span></p>
+				<p><label class="bold">$i18n.getString( "operator" ):</label><br><span id="operatorField"></span></p>
+				<p><label class="bold">$i18n.getString( "left_side_description" ):</label><br><span id="leftSideDescriptionField"></span></p>
+				<p><label class="bold">$i18n.getString( "left_side_expression" ):</label><br><span id="leftSideExpressionField"></span></p>
+				<p><label class="bold">$i18n.getString( "right_side_description" ):</label><br><span id="rightSideDescriptionField"></span></p>
+				<p><label class="bold">$i18n.getString( "right_side_expression" ):</label><br><span id="rightSideExpressionField"></span></p>
 			</div>
 
 		</td>
   </tr>
 </table>
 
-
 <script type="text/javascript">
 	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_attribute" ) , "'" )';
 	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';	
@@ -79,4 +79,10 @@
 	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
 	var i18n_left_side = '$encoder.jsEscape( $i18n.getString( "left_side" ) , "'")';
 	var i18n_condition = '$encoder.jsEscape( $i18n.getString( "condition" ) , "'")';
+	var i18n_equal_to = '$encoder.jsEscape( $i18n.getString( "equal_to" ) , "'")';
+	var i18n_not_equal_to = '$encoder.jsEscape( $i18n.getString( "not_equal_to" ) , "'")';
+	var i18n_greater_than = '$encoder.jsEscape( $i18n.getString( "greater_than" ) , "'")';
+	var i18n_greater_than_or_equal_to = '$encoder.jsEscape( $i18n.getString( "greater_than_or_equal_to" ) , "'")';
+	var i18n_less_than = '$encoder.jsEscape( $i18n.getString( "less_than" ) , "'")';
+	var i18n_less_than_or_equal_to = '$encoder.jsEscape( $i18n.getString( "less_than_or_equal_to" ) , "'")';
 </script>