← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4063: Fixed bug: When reloading dataentry form, no-colour fills into the min-max violated fields.

 

------------------------------------------------------------
revno: 4063
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-04 15:15:11 +0700
message:
  Fixed bug: When reloading dataentry form, no-colour fills into the min-max violated fields.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-06-27 11:06:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-07-04 08:15:11 +0000
@@ -62,6 +62,7 @@
 {    
     private static final String EMPTY_VALUE_TAG = "value=\"\"";
     private static final String EMPTY_TITLE_TAG = "title=\"\"";
+    private static final String STYLE_TAG = "style=\"";
     private static final String TAG_CLOSE = "/>";
     private static final String EMPTY = "";
     
@@ -331,7 +332,9 @@
                 // persisting to output code, and insert value and type for
                 // fields
                 // -------------------------------------------------------------
-
+                
+                String backgroundColor = "style=\"";
+                
                 String appendCode = "";
 
                 if ( dataElement.getType().equals( VALUE_TYPE_BOOL ) )
@@ -367,6 +370,14 @@
                     if ( dataElement.getType().equals( VALUE_TYPE_INT ) )
                     {
                         appendCode += historyCode;
+                        if ( minMaxDataElement != null && !dataElementValue.equals( EMPTY ) )
+                        {
+                            double value = Double.parseDouble( dataElementValue );
+                            if ( value < minMaxDataElement.getMin() || value > minMaxDataElement.getMax() )
+                            {
+                                backgroundColor = "style=\"background-color:#ff6600;";
+                            }
+                        }
                     }
 
                     appendCode += TAG_CLOSE;
@@ -380,6 +391,7 @@
                 inputHtml = inputHtml.replace( "$DATAELEMENTTYPE", dataElementValueType );
                 inputHtml = inputHtml.replace( "$OPTIONCOMBOID", String.valueOf( optionComboId ) );
                 inputHtml = inputHtml.replace( "$DISABLED", disabled );
+                inputHtml = inputHtml.replace( STYLE_TAG, backgroundColor );
 
                 if ( minMaxDataElement == null )
                 {