← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11768: Applied patch from James Chang. Adds description to custom form input fields.

 

Merge authors:
  James Chang (jamesbchang)
------------------------------------------------------------
revno: 11768 [merge]
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-08-23 13:07:06 +0200
message:
  Applied patch from James Chang. Adds description to custom form input 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	2013-08-14 11:04:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2013-08-23 11:07:06 +0000
@@ -35,6 +35,7 @@
 import java.util.Set;
 import java.util.regex.Matcher;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElement;
@@ -285,7 +286,13 @@
                 {
                     return i18n.getString( "category_option_combo_with_id" ) + ": " + optionComboId + " " + i18n.getString( "does_not_exist" );
                 }
-
+                
+                if ( dataSet.isDataElementDecoration() && dataElement.hasDescription() ) 
+                {
+                    String titleTag = " title=\"" +  StringEscapeUtils.escapeHtml( dataElement.getDisplayDescription() ) + "\" ";
+                    inputHtml = inputHtml.replaceAll( "title=\".*?\"", "" ).replace( TAG_CLOSE, titleTag + TAG_CLOSE );
+                }                
+                
                 String appendCode = "";
 
                 if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
@@ -314,11 +321,12 @@
                 }
 
                 inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
+                
                 inputHtml += "<span id=\"" + dataElement.getUid() + "-dataelement\" style=\"display:none\">" + dataElement.getFormNameFallback() + "</span>";
                 inputHtml += "<span id=\"" + categoryOptionCombo.getUid() + "-optioncombo\" style=\"display:none\">" + categoryOptionCombo.getName() + "</span>";
             }
 
-            inputMatcher.appendReplacement( sb, inputHtml );
+            inputMatcher.appendReplacement( sb, inputHtml );            
         }
 
         inputMatcher.appendTail( sb );