← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4615: updated attribute validations to better align with current number naming

 

------------------------------------------------------------
revno: 4615
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-09-19 09:44:36 +0200
message:
  updated attribute validations to better align with current number naming
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/messages.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.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/i18n/messages.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/messages.vm	2011-09-18 20:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/messages.vm	2011-09-19 07:44:36 +0000
@@ -68,8 +68,8 @@
 		,greaterDate: '$encoder.jsEscape($i18n.getString('closedDate_should_be_greater_than_openDate' ) , "'")'
 		,unicodechars: '$encoder.jsEscape($i18n.getString('please_unicode_chars_only' ) , "'")'
 		,unrecognizedcoordinatestring: '$encoder.jsEscape($i18n.getString('unrecognized_coordinate_string' ) , "'")'
-		,real_number: '$encoder.jsEscape($i18n.getString('please_enter_valid_real_number' ) , "'")'
-		,natural_number: '$encoder.jsEscape($i18n.getString('please_enter_valid_natural_number' ) , "'")'
-		,positive_natural_number: '$encoder.jsEscape($i18n.getString('please_enter_valid_positive_natural_number' ) , "'")'
-		,negative_natural_number: '$encoder.jsEscape($i18n.getString('please_enter_valid_negative_natural_number' ) , "'")'
+		,number: '$encoder.jsEscape($i18n.getString('please_enter_valid_number' ) , "'")'
+		,integer: '$encoder.jsEscape($i18n.getString('please_enter_valid_integer' ) , "'")'
+		,positive_integer: '$encoder.jsEscape($i18n.getString('please_enter_valid_positive_integer' ) , "'")'
+		,negative_integer: '$encoder.jsEscape($i18n.getString('please_enter_valid_negative_integer' ) , "'")'
 };

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js	2011-09-18 20:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js	2011-09-19 07:44:36 +0000
@@ -338,49 +338,21 @@
     return this.optional(element) || params[0].test(value);
 });
 
-jQuery.validator.addMethod("real_number", function(value, element, param) {
-    value = +value;
-
-    if( isNaN( value ) )
-    {
-        return false;
-    }
-
-    return true;
-}, "Please enter a valid real number.");
-
-jQuery.validator.addMethod("natural_number", function(value, element, param) {
-    value = +value;
-
-    if( isNaN( value ) || (""+value).indexOf('.') != -1 )
-    {
-        return false;
-    }
-
-    return true;
-}, "Please enter a valid natural number.");
-
-jQuery.validator.addMethod("positive_natural_number", function(value, element, param) {
-    value = +value;
-
-    if( isNaN( value ) || (""+value).indexOf('.') != -1 )
-    {
-        return false;
-    }
-
-    return value >= 0;
-}, "Please enter a valid positive natural number.");
-
-jQuery.validator.addMethod("negative_natural_number", function(value, element, param) {
-    value = +value;
-
-    if( isNaN( value ) || (""+value).indexOf('.') != -1 )
-    {
-        return false;
-    }
-
-    return value <= 0;
-}, "Please enter a valid negative natural number.");
+jQuery.validator.addMethod("number", function(value, element, param) {
+    return isRealNumber(value);
+});
+
+jQuery.validator.addMethod("integer", function(value, element, param) {
+    return isInt(value);
+});
+
+jQuery.validator.addMethod("positive_integer", function(value, element, param) {
+    return isPositiveInt(value);
+});
+
+jQuery.validator.addMethod("negative_integer", function(value, element, param) {
+    return isNegativeInt(value);
+});
 
 // Support method for date
 //Parse a string and convert it to a Date object.

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2011-09-18 20:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2011-09-19 07:44:36 +0000
@@ -158,7 +158,7 @@
 <tr>
 	<td style="width: 200px;">$!args.text</td>
 	<td>
-		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,rangelength:[2,230],alphanumeric:true}}" style="width: 240px;" />
+		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,rangelength:[2,230]}}" style="width: 240px;" />
 	</td>
 </tr>
 #end
@@ -230,7 +230,7 @@
 		name		Will use id if omitted.
 		value		
 *****************************************************#
-#macro( trDecimalInput $args )
+#macro( trNumberInput $args )
 #if( "$!args.name" == "" )
 	#set( $name = $!args.id )
 #else
@@ -240,7 +240,7 @@
 <tr>
 	<td style="width: 200px;">$!args.text</td>
 	<td>
-		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,real_number:true}}" style="width: 240px;" />
+		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,number:true}}" style="width: 240px;" />
 	</td>
 </tr>
 #end
@@ -264,7 +264,7 @@
 <tr>
 	<td style="width: 200px;">$!args.text</td>
 	<td>
-		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,natural_number:true}}" style="width: 240px;" />
+		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,integer:true}}" style="width: 240px;" />
 	</td>
 </tr>
 #end
@@ -288,7 +288,7 @@
 <tr>
 	<td style="width: 200px;">$!args.text</td>
 	<td>
-		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,positive_natural_number:true}}" style="width: 240px;" />
+		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,positive_integer:true}}" style="width: 240px;" />
 	</td>
 </tr>
 #end
@@ -312,7 +312,7 @@
 <tr>
 	<td style="width: 200px;">$!args.text</td>
 	<td>
-		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,negative_natural_number:true}}" style="width: 240px;" />
+		<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,negative_integer:true}}" style="width: 240px;" />
 	</td>
 </tr>
 #end
@@ -359,8 +359,8 @@
 			#trBooleanSelectInput( { "text": $attribute.name, "id": "booleanAttribute$attribute.id", "mandatory": $attribute.mandatory } )	
 		#elseif( $attribute.valueType == "date" )
 			#trDateInput( { "text": $attribute.name, "id": "dateAttribute$attribute.id", "mandatory": $attribute.mandatory } )	
-		#elseif( $attribute.valueType == "decimal" )
-			#trDecimalInput( { "text": $attribute.name, "id": "decimalAttribute$attribute.id", "mandatory": $attribute.mandatory } )
+		#elseif( $attribute.valueType == "number" )
+			#trNumberInput( { "text": $attribute.name, "id": "numberAttribute$attribute.id", "mandatory": $attribute.mandatory } )
 		#elseif( $attribute.valueType == "integer" )
 			#trIntegerInput( { "text": $attribute.name, "id": "integerAttribute$attribute.id", "mandatory": $attribute.mandatory } )
 		#elseif( $attribute.valueType == "positive_integer" )

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-18 20:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-19 07:44:36 +0000
@@ -376,10 +376,10 @@
 unrecognized_coordinate_string = Unrecognized coordinate string
 please_enter_a_letters_or_digits = Please enter letters or digits
 
-please_enter_valid_real_number = Please enter a valid real number.
-please_enter_valid_natural_number = Please enter a valid natural number.
-please_enter_valid_positive_natural_number = Please enter a valid positive natural number.
-please_enter_valid_negative_natural_number = Please enter a valid negative natural number.
+please_enter_valid_number = Please enter a valid number.
+please_enter_valid_integer = Please enter a valid integer.
+please_enter_valid_positive_integer = Please enter a valid positive integer.
+please_enter_valid_negative_integer = Please enter a valid negative integer.
 
 please_enter_name	        = Please enter name!
 please_select_period        = Please select period!

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2011-09-16 15:55:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2011-09-19 07:44:36 +0000
@@ -71,7 +71,7 @@
 				<option value="string">$i18n.getString( "text" )</option>
 				<option value="bool">$i18n.getString( "yes_no" )</option>
 				<option value="date">$i18n.getString( "date" )</option>
-				<option value="decimal">$i18n.getString( "decimal" )</option>
+				<option value="number">$i18n.getString( "number" )</option>
 				<option value="integer" >$i18n.getString( "integer" )</option>
 				<option value="positive_integer">$i18n.getString( "positive_integer" )</option>
 				<option value="negative_integer">$i18n.getString( "negative_integer" )</option>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2011-09-16 15:55:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2011-09-19 07:44:36 +0000
@@ -72,7 +72,7 @@
 				<option value="string" #if( $attribute.valueType == 'string') selected="selected" #end>$i18n.getString( "text" )</option>
 				<option value="bool" #if( $attribute.valueType == 'bool') selected="selected" #end>$i18n.getString( "yes_no" )</option>
 				<option value="date" #if( $attribute.valueType == 'date') selected="selected" #end>$i18n.getString( "date" )</option>
-				<option value="decimal" #if( $attribute.valueType == 'decimal') selected="selected" #end>$i18n.getString( "decimal" )</option>
+				<option value="number" #if( $attribute.valueType == 'number') selected="selected" #end>$i18n.getString( "number" )</option>
 				<option value="integer" #if( $attribute.valueType == 'integer') selected="selected" #end>$i18n.getString( "integer" )</option>
 				<option value="positive_integer" #if( $attribute.valueType == 'positive_integer') selected="selected" #end>$i18n.getString( "positive_integer" )</option>
 				<option value="negative_integer" #if( $attribute.valueType == 'negative_integer') selected="selected" #end>$i18n.getString( "negative_integer" )</option>