dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12608
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3921: Applied the patch file from Jason into data entry. And make a validation on inputting Zero value.
------------------------------------------------------------
revno: 3921
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-16 16:24:02 +0700
message:
Applied the patch file from Jason into data entry. And make a validation on inputting Zero value.
modified:
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
--
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/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-06-16 09:24:02 +0000
@@ -1436,27 +1436,57 @@
// Math methods
// -----------------------------------------------------------------------------
+/**
+ * Allow Zero likes 0 and 0.0x
+ * In which, x is Multiple leading zero.
+ */
+function isValidZeroNumber( value )
+{
+ var regex = /^0(?:\.0*)?$/;
+ return regex.test( value );
+}
+
+/**
+ * For example: Zero without decimal sign.
+ */
+function isPureZero( value )
+{
+ return (value.indexOf(".") == -1);
+}
+
+/**
+ * Allow only integers or a single Zero. No thousands seperators
+ */
function isInt(value)
{
var regex = /^(0|-?[1-9]\d*)$/;
return regex.test( value );
}
+/**
+ * Allow only positive integers, not Zero and no thousands seperators
+ */
function isPositiveInt( value )
{
var regex = /^[1-9]\d*$/;
return regex.test( value );
}
+/**
+ * Allow only negative integers, not Zero and no thousands seperators
+ */
function isNegativeInt( value )
{
var regex = /^-[1-9]\d*$/;
return regex.test( value );
}
+/**
+ * Allow any real number,optionally with a sign, no thousands seperators and a single decimal point.
+ */
function isRealNumber( value )
{
- var regex = /^-?[0-9]*\.?[0-9]+$/;
+ var regex = /^-?(0|[1-9]\d*)(\.\d+)?$/;
return regex.test( value );
}
@@ -1486,4 +1516,4 @@
function getRandomNumber()
{
return Math.floor( 1000000 * Math.random() );
-}
+}
\ No newline at end of file
=== 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-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2011-06-16 09:24:02 +0000
@@ -45,7 +45,7 @@
minimum_value_must_integer = The minimum value must be an integer
maximum_value_must_integer = The maximum value must be an integer
minimum_must_less_than_maximum = The minimum value must be less than the maximum value
-value_must_integer = Value must be an integer
+value_must_integer = Value must be an integer and maximum length not exceeds 255 characters
saving_value_failed_status_code = Saving value failed with status code
saving_value_failed_error_code = Saving value failed with error code
saving_comment_failed_status_code = Saving comment failed with status code
@@ -109,9 +109,10 @@
data_element_order = Data Element Order
generate_min_max_success = Generated min/max values
enter_digits = Enter digit only.
-value_must_number = Value must be an number
-value_must_positive_integer = Value must be an positive integer
-value_must_negative_integer = Value must be an negative integer
+value_must_number = Value must be an number and maximum length not exceeds 255 characters
+value_must_positive_integer = Value must be an positive integer and maximum length not exceeds 255 characters
+value_must_negative_integer = Value must be an negative integer and maximum length not exceeds 255 characters
+field_unallowed_save_zero = This element unallowed to save Zero. The original value won\'t be effect.
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-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module_vi_VN.properties 2011-06-16 09:24:02 +0000
@@ -1,9 +1,11 @@
value_type=Lo\u1ea1i gi\u00e1 tr\u1ecb
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_must_number=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 th\u1ef1c v\u00e0 \u0111\u1ed9 \u0111\u00e0i d\u01b0\u1edbi 255 k\u00fd t\u1ef1\.
+value_must_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean v\u00e0 \u0111\u1ed9 \u0111\u00e0i d\u01b0\u1edbi 255 k\u00fd t\u1ef1\.
+value_must_positive_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean d\u01b0\u01a1ng v\u00e0 \u0111\u1ed9 \u0111\u00e0i d\u01b0\u1edbi 255 k\u00fd t\u1ef1\.
+value_must_negative_integer=Gi\u00e1 tr\u1ecb ph\u1ea3i l\u00e0 m\u1ed9t s\u1ed1 nguy\u00ean \u00e2m v\u00e0 \u0111\u1ed9 \u0111\u00e0i d\u01b0\u1edbi 255 k\u00fd t\u1ef1\.
+field_unallowed_save_zero=Ph\u1ea7n t\u1eed n\u00e0y kh\u00f4ng l\u01b0u gi\u00e1 tr\u1ecb 0\. Gi\u00e1 tr\u1ecb c\u0169 kh\u00f4ng b\u1ecb \u1ea3nh h\u01b0\u1edfng\.
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-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-06-16 09:24:02 +0000
@@ -106,33 +106,37 @@
{
if ( type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' )
{
- if ( type == 'int' && !isInt( field.value ) )
+ if ( isValidZeroNumber( field.value ) )
+ {
+ // If value is 0 and zero is not significant for data element, then skip value
+ if ( significantZeros.indexOf( dataElementId ) == -1 )
+ {
+ window.alert( i18n_field_unallowed_save_zero + '\n\n' + dataElementName );
+ return alertField( field );
+ }
+
+ field.value = isPureZero( field.value ) ? "0" : "0.0";
+ }
+ else if ( type == 'int' && !isInt( field.value ) && ( field.value.length >= 255 ) )
{
window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
return alertField( field );
}
- else if ( type == 'number' && !isRealNumber( field.value ) )
+ else if ( type == 'number' && !isRealNumber( field.value ) && ( field.value.length >= 255 ) )
{
window.alert( i18n_value_must_number + '\n\n' + dataElementName );
return alertField( field );
}
- else if ( type == 'positiveNumber' && !isPositiveInt( field.value ) )
+ else if ( type == 'positiveNumber' && !isPositiveInt( field.value ) && ( field.value.length >= 255 ) )
{
window.alert( i18n_value_must_positive_integer + '\n\n' + dataElementName );
return alertField( field );
}
- else if ( type == 'negativeNumber' && !isNegativeInt( field.value ) )
+ else if ( type == 'negativeNumber' && !isNegativeInt( field.value ) && ( field.value.length >= 255 ) )
{
window.alert( i18n_value_must_negative_integer + '\n\n' + dataElementName );
return alertField( field );
}
- else if ( isZeroNumber( field.value ) && significantZeros.indexOf( dataElementId ) == -1 )
- {
- // If value is 0 and zero is not significant for data element, then skip value
-
- field.style.backgroundColor = COLOR_GREEN;
- return;
- }
else
{
var minString = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].min' ).innerHTML;
@@ -164,7 +168,7 @@
return;
}
}
- }
+ }
}
}
=== 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-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-06-16 09:24:02 +0000
@@ -10,6 +10,7 @@
var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_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_field_unallowed_save_zero = '$encoder.jsEscape( $i18n.getString( "field_unallowed_save_zero" ) , "'")';
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" ) , "'")';