← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3407: added target line validation

 

------------------------------------------------------------
revno: 3407
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-04-15 15:48:42 +0200
message:
  added target line validation
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js


--
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-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-04-15 13:48:42 +0000
@@ -64,6 +64,8 @@
 must_select_at_least_one_indictor_data_element_data_set = Please select at least one indicator, data element or data set
 must_select_at_least_one_unit= Please select at least one organisation unit
 must_select_at_least_one_period= Please select at least one period
+target_line_value_must_be_provided = Target line value must be provided when target lines are enabled.
+target_line_value_must_be_number = Target line value must be a number.
 cannot_include_more_organisation_unit_regression = Cannot include more that one organisation unit with regression
 cannot_select_orgunit_and_parent_orgunit_param= Cannot select both current and parent organisation unit parameter
 must_enter_name= Please enter a name

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm	2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm	2011-04-15 13:48:42 +0000
@@ -13,6 +13,8 @@
     var i18n_must_select_at_least_one_indicator = '$encoder.jsEscape( $i18n.getString( "must_select_at_least_one_indicator" ), "'")';
     var i18n_must_select_at_least_one_unit = '$encoder.jsEscape( $i18n.getString( "must_select_at_least_one_unit" ), "'")';
     var i18n_must_select_at_least_one_period = '$encoder.jsEscape( $i18n.getString( "must_select_at_least_one_period" ), "'")';
+	var i18n_target_line_value_must_be_provided = '$encoder.jsEscape( $i18n.getString( "target_line_value_must_be_provided" ), "'")';
+	var i18n_target_line_value_must_be_number = '$encoder.jsEscape( $i18n.getString( "target_line_value_must_be_number" ), "'")';
 </script>
 
 #macro ( getHeader )

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js	2011-04-08 10:48:03 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js	2011-04-15 13:48:42 +0000
@@ -46,7 +46,7 @@
 
 function saveChart()
 {
-    if ( validateCollections() )
+    if ( validateTargetLine() && validateCollections() )
     {
         var url = "validateChart.action?id=" + getFieldValue( "id" ) + "&title=" + getFieldValue( "title" );
 
@@ -96,6 +96,32 @@
 	return $("#selectedIndicators option").length;
 }
 
+function validateTargetLine()
+{
+    var targetLine = $("#targetLine").attr("checked");
+
+    if( targetLine )
+    {
+        var targetLineValue = $("#targetLineValue").val(); 
+        
+        if( targetLineValue.length == 0)
+        {
+            setMessage( i18n_target_line_value_must_be_provided );
+
+            return false;
+        }
+
+        if( isNaN( targetLineValue ) )
+        {
+            setMessage( i18n_target_line_value_must_be_number );
+
+            return false;
+        }
+    }
+
+    return true;
+}
+
 function validateCollections()
 {
     if ( !hasElements( "selectedIndicators" ) )
@@ -118,6 +144,6 @@
         
         return false;
     }
-     
+
     return true;
 }