← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4764: (mobile) made validation messages a bit simpler

 

------------------------------------------------------------
revno: 4764
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-29 12:23:26 +0200
message:
  (mobile) made validation messages a bit simpler
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.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-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2011-09-28 10:34:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2011-09-29 10:23:26 +0000
@@ -88,6 +88,11 @@
         this.sectionFormUtils = sectionFormUtils;
     }
 
+    public SectionFormUtils getSectionFormUtils()
+    {
+        return sectionFormUtils;
+    }
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-09-28 10:44:46 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-09-29 10:23:26 +0000
@@ -129,6 +129,11 @@
         this.sectionFormUtils = sectionFormUtils;
     }
 
+    public SectionFormUtils getSectionFormUtils()
+    {
+        return sectionFormUtils;
+    }
+
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java	2011-09-28 10:34:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java	2011-09-29 10:23:26 +0000
@@ -164,4 +164,44 @@
 
         return dataValueMap;
     }
+
+    // -------------------------------------------------------------------------
+    // Static Utils
+    // -------------------------------------------------------------------------
+
+    public static boolean valueHigher( String value, int max )
+    {
+        int integerValue;
+
+        try
+        {
+            integerValue = Integer.parseInt( value );
+
+            if(integerValue > max)
+            {
+                return true;
+            }
+        } catch ( NumberFormatException e )
+        { }
+
+        return false;
+    }
+
+    public static boolean valueLower( String value, int min )
+    {
+        int integerValue;
+
+        try
+        {
+            integerValue = Integer.parseInt( value );
+
+            if(integerValue < min)
+            {
+                return true;
+            }
+        } catch ( NumberFormatException e )
+        { }
+
+        return false;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm	2011-09-28 19:31:03 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm	2011-09-29 10:23:26 +0000
@@ -1,4 +1,6 @@
 
+#set( $Integer = 0 )
+
 <h2>$dataSet.name</h2>
 
 <form action="saveSectionForm.action" method="POST">
@@ -18,9 +20,17 @@
 				<label>$dataElement.name $optionCombo.name</label>
 
 				#if( $validationErrors.get( $key ) )
-				#set( $validationError = $validationErrors.get( $key ) ) 
-				<br /><span style="color: red;">Value is out of bounds [ $validationError.min, $validationError.max ]</span>
-				#end
+				#set( $validationError = $validationErrors.get( $key ) )
+
+                #if( $sectionFormUtils.valueHigher( $validationError.value, $validationError.max ) )
+                    <br /><span style="color: red;">Too high (max $validationError.max)</span>
+                #elseif( $sectionFormUtils.valueLower( $validationError.value, $validationError.min ) )
+                    <br /><span style="color: red;">Too low (min $validationError.min)</span>
+                #else
+                    <br /><span style="color: red;">Not a number</span>
+                #end
+
+                #end
 
 				<input type="number" size="24" name="$key" value="$!dataValues.get($key)" /> <br />
 			#end