← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3563: Made indicator name show up as input value and title in custom form designer

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3563 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-10 22:25:25 +0200
message:
  Made indicator name show up as input value and title in custom form designer
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
  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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js


--
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-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java	2011-05-10 11:39:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java	2011-05-10 19:53:13 +0000
@@ -46,7 +46,7 @@
 
     final Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?/>)", Pattern.DOTALL );
     final Pattern IDENTIFIER_PATTERN = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
-    final Pattern INDICATOR_PATTERN = Pattern.compile( "indicatorid=\"(.*?)\"" );
+    final Pattern INDICATOR_PATTERN = Pattern.compile( "indicatorId=\"(.*?)\"" );
     final Pattern VALUE_TAG_PATTERN = Pattern.compile( "value=\"(.*?)\"", Pattern.DOTALL );
     final Pattern TITLE_TAG_PATTERN = Pattern.compile( "title=\"(.*?)\"", Pattern.DOTALL );
     

=== 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-05-10 11:24:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-05-10 20:24:39 +0000
@@ -45,6 +45,8 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
@@ -88,6 +90,13 @@
         this.dataElementService = dataElementService;
     }
     
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
+
     // ------------------------------------------------------------------------
     // Implemented Methods
     // ------------------------------------------------------------------------
@@ -168,6 +177,7 @@
             String inputHtml = inputMatcher.group();
 
             Matcher identifierMatcher = IDENTIFIER_PATTERN.matcher( inputHtml );
+            Matcher indicatorMatcher = INDICATOR_PATTERN.matcher( inputHtml );
 
             if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
             {
@@ -179,37 +189,38 @@
                 String optionComboName = optionCombo != null ? optionCombo.getName() : "";
 
                 // -------------------------------------------------------------
-                // Insert name of data element operand as value and title in
-                // the HTML code
+                // Insert name of data element operand as value and title
                 // -------------------------------------------------------------
 
-                String displayValue = "[ Data element does not exist ]";
-
-                if ( dataElement != null )
-                {
-                    displayValue = "value=\"[ " + dataElement.getShortName() + " " + optionComboName + " ]\"";
-
-                    inputHtml = inputHtml.contains( EMPTY_VALUE_TAG ) ? inputHtml.replace( EMPTY_VALUE_TAG, displayValue ) : inputHtml + " " + displayValue;
-                    
-                    StringBuilder title = new StringBuilder( "title=\"[ " ).append( dataElement.getId() ).append( " - " ).
-                        append( dataElement.getShortName() ).append( " - " ).append( optionComboId ).append( " - " ).
-                        append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( " ]\"" );
-                    
-                    inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, title ) : " " + title;                    
-                }
-                else
-                {
-                    String displayNotExisting = "value=\"" + displayValue + "\"";
-                    
-                    inputHtml = inputHtml.contains( EMPTY_VALUE_TAG ) ? inputHtml.replace( EMPTY_VALUE_TAG, displayNotExisting ) : inputHtml + displayNotExisting;
-                    
-                    displayNotExisting = "title=\"" + displayValue + "\"";
-                    
-                    inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, displayNotExisting ) : inputHtml + displayNotExisting;
-                }
+                StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
+                    append( dataElement.getShortName() ).append( " - " ).append( optionComboId ).append( " - " ).
+                    append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
+                
+                String displayValue = dataElement != null ? "value=\"[ " + dataElement.getShortName() + " " + optionComboName + " ]\"" : "[ Data element does not exist ]";
+                String displayTitle = dataElement != null ? title.toString() : "[ Data element does not exist ]";
+                
+                inputHtml = inputHtml.contains( EMPTY_VALUE_TAG ) ? inputHtml.replace( EMPTY_VALUE_TAG, displayValue ) : inputHtml + " " + displayValue;                    
+                inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, displayTitle ) : " " + displayTitle;
 
                 inputMatcher.appendReplacement( sb, inputHtml );
             }
+            else if ( indicatorMatcher.find() && indicatorMatcher.groupCount() > 0 )
+            {
+                int indicatorId = Integer.parseInt( indicatorMatcher.group( 1 ) );
+                Indicator indicator = indicatorService.getIndicator( indicatorId );
+
+                // -------------------------------------------------------------
+                // Insert name of indicator as value and title
+                // -------------------------------------------------------------
+
+                String displayValue = indicator != null ? "value=\"[ " + indicator.getName() + "]\"" : "[ Indicator does not exist ]";
+                String displayTitle = indicator != null ? "title=\"" + indicator.getName() + "\"" : "[ Indicator does not exist ]";
+
+                inputHtml = inputHtml.contains( EMPTY_VALUE_TAG ) ? inputHtml.replace( EMPTY_VALUE_TAG, displayValue ) : inputHtml + " " + displayValue;                    
+                inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, displayTitle ) : " " + displayTitle;
+
+                inputMatcher.appendReplacement( sb, inputHtml );                
+            }
         }
 
         inputMatcher.appendTail( sb );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2011-05-07 22:48:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2011-05-10 20:24:39 +0000
@@ -310,6 +310,7 @@
 	<bean id="org.hisp.dhis.dataentryform.DataEntryFormService" class="org.hisp.dhis.dataentryform.DefaultDataEntryFormService">
 		<property name="dataEntryFormStore" ref="org.hisp.dhis.dataentryform.DataEntryFormStore" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
 		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 	</bean>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-05-10 07:25:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-05-10 19:49:22 +0000
@@ -9,8 +9,7 @@
   <package name="dhis-web-caseentry" extends="dhis-web-commons"
     namespace="/dhis-web-caseentry">   
     
-    <action name="index" class="org.hisp.dhis.caseentry.action.NoAction">  
-      <interceptor-ref name="organisationUnitTreeStack"/>    
+    <action name="index" class="org.hisp.dhis.caseentry.action.NoAction">
       <result name="success" type="velocity">/main.vm</result>     
       <param name="page">/dhis-web-caseentry/index.vm</param>
       <param name="menu">/dhis-web-caseentry/menu.vm</param>             

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2011-05-10 16:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2011-05-10 20:24:39 +0000
@@ -54,7 +54,7 @@
 	{
 		var id = $option.data("id");
 		var title = $option.val();
-		var template = '<input id="indicator' + id + '" value="[ ' + title + ' ]" name="indicator" indicatorId="' + id + '" style="width:10em;text-align:center;" readonly="readonly" />';
+		var template = '<input id="indicator' + id + '" value="[ ' + title + ' ]" title="' + title + '" name="indicator" indicatorId="' + id + '" style="width:10em;text-align:center;" readonly="readonly" />';
 
 		if(!checkExisted("indicator" + id)) {
 			oEditor.insertHtml( template )