← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3903: Applied patch from Hieu. 1. Changes the data element value types to number, integer, positive int...

 

------------------------------------------------------------
revno: 3903
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-06-14 18:13:36 +0200
message:
  Applied patch from Hieu. 1. Changes the data element value types to number, integer, positive integer, negative integer. Makes the validation more robust using regex. 2. Fixes issue with deletion of orgunits. Reloading tree after an orgunit is deleted. Good work.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module_vi_VN.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module_vi_VN.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.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-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2011-05-30 18:34:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2011-06-14 16:13:36 +0000
@@ -70,9 +70,9 @@
 
     public static final String VALUE_TYPE_NUMBER = "number";
     
-    public static final String VALUE_TYPE_POSITIVE_NUMBER = "positiveNumber";
+    public static final String VALUE_TYPE_POSITIVE_INT = "positiveNumber";
     
-    public static final String VALUE_TYPE_NEGATIVE_NUMBER = "negativeNumber";
+    public static final String VALUE_TYPE_NEGATIVE_INT = "negativeNumber";
     
     
     public static final String VALUE_TYPE_BOOL = "bool";

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-05-27 04:02:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-06-14 16:13:36 +0000
@@ -270,8 +270,8 @@
 min_days														= Min days
 max_days														= Max days
 value_must_number												= Value must be an number
-value_must_positive_number										= Value must be an positive number
-value_must_negative_number										= Value must be an nagative number
+value_must_positive_integer										= Value must be an positive integer
+value_must_negative_integer										= Value must be an nagative integer
 days															= days
 please_select													= Please select
 immediate_children												= Immediate Children

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module_vi_VN.properties	2011-05-12 07:02:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module_vi_VN.properties	2011-06-14 16:13:36 +0000
@@ -14,10 +14,10 @@
 vitamina_dose1	                                                = Vitamin A ( Li\u1ec1u 1)
 visit_plan 														= K\u1ebf ho\u1ea1ch \u0111\u1ecbnh k\u1ef3
 village 														= \u0110\u01a1n v\u1ecb
-value_must_positive_number										= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean d\u01b0\u01a1ng
 value_must_number												= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t con s\u1ed1
-value_must_negative_number										= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean \u00e2m
 value_must_integer 												= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean
+value_must_negative_integer										= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean \u00e2m
+value_must_positive_integer										= Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean d\u01b0\u01a1ng
 value															= Gi\u00e1 tr\u1ecb
 use_default_form 												= D\u00f9ng m\u1eabu m\u1eb7c \u0111\u1ecbnh
 use_custom_form 												= D\u00f9ng m\u1eabu thi\u1ebft k\u1ebf

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-06-01 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-06-14 16:13:36 +0000
@@ -700,7 +700,7 @@
 
                 return;
             }
-			else if (  type == 'number' && !isNumber( field.value ))
+			else if (  type == 'number' && !isRealNumber( field.value ))
             {
                 field.style.backgroundColor = '#ffcc00';
                 window.alert( i18n_value_must_number + '\n\n' + dataElementName );
@@ -709,19 +709,19 @@
 
                 return;
             } 
-			else if (  type == 'positiveNumber' && !isPositiveNumber( field.value ))
+			else if (  type == 'positiveNumber' && !isPositiveInt( field.value ))
             {
                 field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_positive_number + '\n\n' + dataElementName );
+                window.alert( i18n_value_must_positive_integer + '\n\n' + dataElementName );
                 field.select();
                 field.focus();
 
                 return;
             } 
-			else if (  type == 'negativeNumber' && !isNegativeNumber( field.value ))
+			else if (  type == 'negativeNumber' && !isNegativeInt( field.value ))
             {
                 field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_negative_number + '\n\n' + dataElementName );
+                window.alert( i18n_value_must_negative_integer + '\n\n' + dataElementName );
                 field.select();
                 field.focus();
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2011-05-20 09:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2011-06-14 16:13:36 +0000
@@ -49,8 +49,8 @@
 	var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ) , "'")' + ']';
 	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
 	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
-	var i18n_value_must_positive_number = '$encoder.jsEscape( $i18n.getString( "value_must_positive_number" ) , "'")';
-	var i18n_value_must_negative_number = '$encoder.jsEscape( $i18n.getString( "value_must_negative_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
     var i18n_invalid_date = '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")'; 
     var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
     var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
@@ -67,4 +67,4 @@
 	var i18n_date_of_birth = '$encoder.jsEscape( $i18n.getString( "date_of_birth" ), "'")';
 	var i18n_blood_group = '$encoder.jsEscape( $i18n.getString( "blood_group" ), "'")';
 	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';
-</script>
+</script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2011-05-27 01:09:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm	2011-06-14 16:13:36 +0000
@@ -57,8 +57,8 @@
 	
 	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
 	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
-	var i18n_value_must_positive_number = '$encoder.jsEscape( $i18n.getString( "value_must_positive_number" ) , "'")';
-	var i18n_value_must_negative_number = '$encoder.jsEscape( $i18n.getString( "value_must_negative_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
     var i18n_invalid_date =   '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " 
 							+ '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" 
 							+ dateFormat.replace('yy', 'yyyy') + " '" ; 
@@ -69,6 +69,4 @@
     var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
 	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
 	var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
-</script>
-
-
+</script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-05-31 05:12:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-06-14 16:13:36 +0000
@@ -806,7 +806,7 @@
  * @param action
  *            the server action url for deleting the item.
  */
-function removeItem( itemId, itemName, confirmation, action )
+function removeItem( itemId, itemName, confirmation, action, success )
 {                
     var result = window.confirm( confirmation + "\n\n" + itemName );
     
@@ -828,6 +828,11 @@
 	                jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
 					jQuery( "table.listTable tbody" ).trigger("update");
   
+					if ( success && typeof( success) == "function" )
+					{
+						success.call();
+					}
+  
 					showSuccessMessage( i18n_delete_success );
     	    	}
     	    	else if ( json.response == "error" )
@@ -1431,18 +1436,38 @@
 // Math methods
 // -----------------------------------------------------------------------------
 
+function isInt(value)
+{
+	var regex = /^(0|-?[1-9]\d*)$/;
+	return regex.test( value );
+}
+
+function isPositiveInt( value )
+{
+	var regex = /^[1-9]\d*$/;
+	return regex.test( value );
+}
+
+function isNegativeInt( value )
+{
+	var regex = /^-[1-9]\d*$/;
+	return regex.test( value );
+}
+
+function isRealNumber( value )
+{
+	var regex = /^-?[0-9]*\.?[0-9]+$/;
+	return regex.test( value );
+}
+
+// Recommended in using this method
+// which same as name one from Ext
 function isNumber( value )
 {
 	var regex = /^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;
 	return regex.test( value );
 }
 
-function isInt(value)
-{
-	//var regex = /^\d+$/;
-	return ( parseInt(value) == value );
-}
-
 function isPositiveNumber( value )
 {
 	return isNumber( value ) && parseFloat( value ) > 0;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2011-03-20 09:29:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2011-06-14 16:13:36 +0000
@@ -110,8 +110,8 @@
 generate_min_max_success 			= Generated min/max values
 enter_digits                        = Enter digit only.
 value_must_number					= Value must be an number
-value_must_positive_number			= Value must be an positive number
-value_must_negative_number			= Value must be an negative number
+value_must_positive_integer			= Value must be an positive integer
+value_must_negative_integer			= Value must be an negative integer
 datavalue_history                   = Data value history
 max_must_be_greater_than_min		= Max must be greater than min
 next 								= Next

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module_vi_VN.properties	2011-02-22 08:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module_vi_VN.properties	2011-06-14 16:13:36 +0000
@@ -2,6 +2,8 @@
 value_of_data_element_less=Gi\u00e1 tr\u1ecb c\u1ee7a th\u00e0nh ph\u1ea7n d\u1eef li\u1ec7u th\u1ea5p h\u01a1n gi\u00e1 tr\u1ecb nh\u1ecf nh\u1ea5t cho ph\u00e9p
 value_of_data_element_greater=Gi\u00e1 tr\u1ecb c\u1ee7a th\u00e0nh ph\u1ea7n d\u1eef li\u1ec7u sau l\u1edbn h\u01a1n gi\u00e1 tr\u1ecb l\u1edbn nh\u1ea5t cho ph\u00e9p
 value_must_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean
+value_must_positive_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean d\u01b0\u01a1ng
+value_must_negative_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean \u00e2m
 value_date=Gi\u00e1 tr\u1ecb ng\u00e0y th\u00e1ng
 value=Gi\u00e1 tr\u1ecb
 validation_rule=Quy lu\u1eadt ki\u1ec3m tra t\u00ednh h\u1ee3p l\u1ec7

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2011-06-03 13:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2011-06-14 16:13:36 +0000
@@ -111,19 +111,19 @@
             	window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
                 return alertField( field );
             }  
-            else if ( type == 'number' && !isNumber( field.value ) )
+            else if ( type == 'number' && !isRealNumber( field.value ) )
             {
                 window.alert( i18n_value_must_number + '\n\n' + dataElementName );
                 return alertField( field );
             } 
-			else if ( type == 'positiveNumber' && !isPositiveNumber( field.value ) )
+			else if ( type == 'positiveNumber' && !isPositiveInt( field.value ) )
             {
-                window.alert( i18n_value_must_positive_number + '\n\n' + dataElementName );
+                window.alert( i18n_value_must_positive_integer + '\n\n' + dataElementName );
                 return alertField( field );
             } 
-			else if ( type == 'negativeNumber' && !isNegativeNumber( field.value ) )
+			else if ( type == 'negativeNumber' && !isNegativeInt( field.value ) )
             {
-                window.alert( i18n_value_must_negative_number + '\n\n' + dataElementName );
+                window.alert( i18n_value_must_negative_integer + '\n\n' + dataElementName );
                 return alertField( field );
             }
             else if ( isZeroNumber( field.value ) && significantZeros.indexOf( dataElementId ) == -1 )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-04-12 18:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-06-14 16:13:36 +0000
@@ -8,8 +8,8 @@
     var i18n_value_of_data_element_greater = '$encoder.jsEscape( $i18n.getString( "value_of_data_element_greater" ) , "'")';
 	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
 	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
-	var i18n_value_must_positive_number = '$encoder.jsEscape( $i18n.getString( "value_must_positive_number" ) , "'")';
-	var i18n_value_must_negative_number = '$encoder.jsEscape( $i18n.getString( "value_must_negative_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
 	var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
     var i18n_saving_comment_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_comment_failed_status_code" ) , "'")';
     var i18n_saving_minmax_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_minmax_failed_error_code" ) , "'")';

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2011-05-20 16:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2011-06-14 16:13:36 +0000
@@ -347,8 +347,8 @@
 move_selected                                   = Move selected
 number_value_type								= Number type
 int												= Integer
-positiveNumber									= Positive Number
-negativeNumber									= Negative Number
+positiveNumber									= Positive Integer
+negativeNumber									= Negative Integer
 view_1											= View 1
 view_2											= View 2
-store_zero_data_values							= Store Zero Data Value
+store_zero_data_values							= Store Zero Data Value
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js	2011-03-19 19:47:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js	2011-06-14 16:13:36 +0000
@@ -54,5 +54,5 @@
 
 function removeOrganisationUnit( unitId, unitName )
 {
-	removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action' );
+	removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action', subtree.refreshTree );
 }