← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 33: Comment handling for all types of DHIS dataentry forms (default, multidimension, custom)

 

------------------------------------------------------------
revno: 33
committer: abyot <abyota@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2009-03-10 15:49:13 +0530
message:
  Comment handling for all types of DHIS dataentry forms (default, multidimension, custom)
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  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/webapp/dhis-web-dataentry/form.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/multidimensional.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multidimensional/form.vm

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2009-03-10 10:19:13 +0000
@@ -27,12 +27,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.List;
+
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryComboService;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.de.comments.StandardCommentsManager;
 import org.hisp.dhis.de.history.DataElementHistory;
 import org.hisp.dhis.de.history.HistoryRetriever;
 import org.hisp.dhis.de.state.SelectedStateManager;
@@ -68,6 +73,13 @@
         this.dataElementService = dataElementService;
     }
     
+    private DataValueService dataValueService;
+
+    public void setDataValueService( DataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+    
     private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
 
     public void setDataElementCategoryOptionComboService( DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
@@ -88,6 +100,13 @@
     {
         this.selectedStateManager = selectedStateManager;
     }
+    
+    private StandardCommentsManager standardCommentsManager;
+
+    public void setStandardCommentsManager( StandardCommentsManager standardCommentsManager )
+    {
+        this.standardCommentsManager = standardCommentsManager;
+    }
 
     // -------------------------------------------------------------------------
     // Input
@@ -106,6 +125,18 @@
     {
     	this.optionComboId = optionComboId;
     }
+    
+    private Boolean showComment;
+    
+    public void setShowComment( Boolean showComment)
+    {
+    	this.showComment = showComment;
+    }
+    
+    public Boolean getShowComment()
+    {
+    	return showComment;
+    }
 
     // -------------------------------------------------------------------------
     // Output
@@ -124,6 +155,20 @@
     {
     	return isHistoryValid;
     }
+    
+    private DataValue dataValue;
+
+    public DataValue getDataValue()
+    {
+        return dataValue;
+    }
+    
+    private List<String> standardComments;
+
+    public List<String> getStandardComments()
+    {
+        return standardComments;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -132,7 +177,8 @@
     public String execute()
         throws Exception
     {
-        DataElement dataElement = dataElementService.getDataElement( dataElementId );       
+    	
+    	DataElement dataElement = dataElementService.getDataElement( dataElementId );       
         
         DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
         
@@ -151,9 +197,17 @@
         Period period = selectedStateManager.getSelectedPeriod();
 
         OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+        
+        dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
 
         dataElementHistory = historyRetriever.getHistory( dataElement, optionCombo, organisationUnit, period, HISTORY_LENGTH );
         
+        // ---------------------------------------------------------------------
+        // Make the standard comments available
+        // ---------------------------------------------------------------------
+
+        standardComments = standardCommentsManager.getStandardComments();
+        
         if( dataElementHistory == null )
         {
         	isHistoryValid = false;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java	2009-03-10 10:19:13 +0000
@@ -97,7 +97,7 @@
     
     private Integer optionComboId;
 
-    public void setOptionComboIdId( Integer optionComboId )
+    public void setOptionComboId( Integer optionComboId )
     {
         this.optionComboId = optionComboId;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java	2009-03-10 10:19:13 +0000
@@ -32,6 +32,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
@@ -82,6 +84,13 @@
     {
         this.selectedStateManager = selectedStateManager;
     }
+    
+    private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
+    
+    public void setDataElementCategoryOptionComboService( DataElementCategoryOptionComboService dataElementCategoryOptionComboService)
+    {
+    	this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;    	
+    }
 
     // -------------------------------------------------------------------------
     // Input/output
@@ -105,6 +114,13 @@
     {
         return dataElementId;
     }
+    
+    private Integer optionComboId;
+
+    public void setOptionComboId( Integer optionComboId )
+    {
+        this.optionComboId = optionComboId;
+    }
 
     private int statusCode;
 
@@ -138,6 +154,8 @@
         Period period = selectedStateManager.getSelectedPeriod();
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
+        
+        DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
 
         storedBy = currentUserService.getCurrentUsername();
 
@@ -155,7 +173,7 @@
         // Update DB
         // ---------------------------------------------------------------------
 
-        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period );
+        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
 
         if ( dataValue == null )
         {
@@ -163,7 +181,7 @@
             {
                 LOG.debug( "Adding DataValue, comment added" );
 
-                dataValue = new DataValue( dataElement, period, organisationUnit, null, storedBy, new Date(), comment );
+                dataValue = new DataValue( dataElement, period, organisationUnit, null, storedBy, new Date(), comment, optionCombo );
 
                 dataValueService.addDataValue( dataValue );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java	2009-03-10 10:19:13 +0000
@@ -97,7 +97,7 @@
     
     private Integer optionComboId;
 
-    public void setOptionComboIdId( Integer optionComboId )
+    public void setOptionComboId( Integer optionComboId )
     {
         this.optionComboId = optionComboId;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2009-03-10 10:19:13 +0000
@@ -299,7 +299,7 @@
         
         final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME' )\" onkeypress=\"return keyPress(event, this)\" style=\"text-align:center\" ";
         final String jsCodeForCombos = " $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, this )\">";
-        final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID  )' ";
+        final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
         final String calDataElementCode = " class=\"calculated\" disabled ";
 
         // ---------------------------------------------------------------------
@@ -511,7 +511,7 @@
 
         final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME', $SAVEMODE )\" onkeypress=\"return keyPress(event, this)\" style=\"text-align:center\" ";
         final String jsCodeForCombos = " $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID, this )\">";
-        final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID,  $OPTIONCOMBOID )' ";
+        final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
         final String calDataElementCode = " class=\"calculated\" disabled ";
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-03-10 10:19:13 +0000
@@ -197,6 +197,8 @@
       ref="org.hisp.dhis.datavalue.DataValueService"/>
     <property name="selectedStateManager"
       ref="org.hisp.dhis.de.state.SelectedStateManager"/>
+    <property name="dataElementCategoryOptionComboService"
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/> 
   </bean>
   
   <bean id="org.hisp.dhis.de.action.SaveMinMaxLimitsAction"
@@ -211,6 +213,9 @@
     <property name="dataElementService">
       <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
     </property>
+    <property name="dataElementCategoryOptionComboService">
+      <ref bean="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>
+    </property>
   </bean>
   
   <bean id="org.hisp.dhis.de.action.RemoveMinMaxLimitsAction"
@@ -222,6 +227,8 @@
       ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
     <property name="dataElementService"
       ref="org.hisp.dhis.dataelement.DataElementService"/>
+    <property name="dataElementCategoryOptionComboService"
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/> 
   </bean>
   
   <bean id="org.hisp.dhis.de.action.CalculateCDEsAction"
@@ -323,7 +330,11 @@
     <property name="dataElementCategoryComboService"
       ref="org.hisp.dhis.dataelement.DataElementCategoryComboService"/>
     <property name="dataElementCategoryOptionComboService"
-      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>  
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>
+    <property name="dataValueService"
+      ref="org.hisp.dhis.datavalue.DataValueService"/>
+    <property name="standardCommentsManager"
+      ref="org.hisp.dhis.de.comments.StandardCommentsManager"/>  
   </bean>
   
   <bean id="org.hisp.dhis.de.action.MinMaxGeneratingAction"

=== 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	2009-03-08 11:50:57 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2009-03-10 10:19:13 +0000
@@ -1,3 +1,4 @@
+dataelement_comment					= Comment
 please_design_a_custom_form			= Please design a custom FORM for this dataSet !!
 import_export						= Import/Export
 import_from_excel					= Import from Excel (Exported Template)

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/form.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/form.vm	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/form.vm	2009-03-10 10:19:13 +0000
@@ -63,7 +63,7 @@
 		<td>
 			<span id="value[$dataElement.id].name" title="$!encoder.htmlEncode( $dataElement.description )">
 			#if( $dataElement.type == "int" && $auth.hasAccess( "dhis-web-dataentry", "viewHistory" ) )
-				<a href="javascript:viewHistory( $dataElement.id, $optionComboId  )">
+				<a href="javascript:viewHistory( $dataElement.id, $optionComboId, false  )">
 			#end
 			#if( $useShortName )
 				$encoder.htmlEncode( $dataElement.shortName )
@@ -125,15 +125,15 @@
 		
 		##comment
 		<td>
-			<select id="value[$dataElement.id].comments" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ) ) onchange="commentSelected( $dataElement.id )" #else disabled="disabled" #end #if( $dataValue.comment && !$standardComments.contains( $dataValue.comment ) ) style="display:none; width:100%" #end#if( $locked ) disabled="disabled"#end>
+			<select id="value[$dataElement.id:$optionComboId].comments" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ) ) onchange="commentSelected( $dataElement.id, $optionComboId )" #else disabled="disabled" #end #if( $dataValue.comment && !$standardComments.contains( $dataValue.comment ) ) style="display:none; width:100%" #end#if( $locked ) disabled="disabled"#end>
 				<option value="">[$i18n.getString( "no_comment" )]</option>
 				<option value="custom">[$i18n.getString( "custom_comment" )]</option>
 			#foreach( $comment in $standardComments )
 				<option value="$encoder.htmlEncode( $comment )" #if( $encoder.htmlEncode( $comment ) == $encoder.htmlEncode( $dataValue.comment ) ) selected="selected" #end>$encoder.htmlEncode( $comment )</option>
 			#end
 			</select>
-			<input id="value[$dataElement.id].comment" type="text" value="$!encoder.htmlEncode( $dataValue.comment )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ))
-			    onblur="commentLeft( $dataElement.id )" #else disabled="disabled" #end style="width:100% #if( !$dataValue.comment || $standardComments.contains( $dataValue.comment )) ;display:none #end">
+			<input id="value[$dataElement.id:$optionComboId].comment" type="text" value="$!encoder.htmlEncode( $dataValue.comment )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ))
+			    onblur="commentLeft( $dataElement.id, $optionComboId )" #else disabled="disabled" #end style="width:100% #if( !$dataValue.comment || $standardComments.contains( $dataValue.comment )) ;display:none #end">
 		</td>
 	</tr>
 	#set( $tabIndex = $tabIndex + 1 )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2009-03-10 10:19:13 +0000
@@ -14,12 +14,26 @@
 	#set( $maxLimit = $encoder.htmlEncode( $i18n.getString( "not_set" ) ) )
 #end
 
+<h4>$i18n.getString( "dataelement_comment" )</h4>		
+#if( $showComment == 'true' )
+##comment		
+	<select id="value[$dataElementHistory.dataElement.id:$dataElementHistory.optionCombo.id].comments" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ) ) onchange="commentSelected( $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )" #else disabled="disabled" #end #if( $dataValue.comment && !$standardComments.contains( $dataValue.comment ) ) style="display:none; width:100%" #end#if( $locked ) disabled="disabled"#end>
+		<option value="">[$i18n.getString( "no_comment" )]</option>
+		<option value="custom">[$i18n.getString( "custom_comment" )]</option>
+		#foreach( $comment in $standardComments )
+			<option value="$encoder.htmlEncode( $comment )" #if( $encoder.htmlEncode( $comment ) == $encoder.htmlEncode( $dataValue.comment ) ) selected="selected" #end>$encoder.htmlEncode( $comment )</option>
+		#end
+	</select>
+	<input id="value[$dataElementHistory.dataElement.id:$dataElementHistory.optionCombo.id].comment" type="text" value="$!encoder.htmlEncode( $dataValue.comment )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ))
+	   	onblur="commentLeft( $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )" #else disabled="disabled" #end style="width:100% #if( !$dataValue.comment || $standardComments.contains( $dataValue.comment )) ;display:none #end">
+#end
+	
 #if( $isHistoryValid )
 	<h2>$encoder.htmlEncode( $i18n.getString( "dataelement_history" ) )</h2>
 	<h4>
 		$encoder.htmlEncode( $dataElementHistory.dataElement.shortName )
-		$encoder.htmlEncode( $dataElementHistory.optionCombo.shortName )		
-	</h4>
+		$encoder.htmlEncode( $dataElementHistory.optionCombo.shortName )		
+	</h4>	
 #else
 	<h2>$encoder.htmlEncode( $i18n.getString( "dataelement_history" ) )</h2>
 	<h4>$encoder.htmlEncode( $i18n.getString( "history_not_valid" ) )</h4>	
@@ -31,7 +45,7 @@
 		<td>$encoder.htmlEncode( $i18n.getString( "max_limit" ) ) </td>
 		<td><input type="text" id="maxLimit" style="width:10em" value="$maxLimit"
 			#if( $auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) && $auth.hasAccess( "dhis-web-dataentry", "removeMinMaxLimits" ))
-				onchange="saveMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id )"
+				onchange="saveMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id,  $dataElementHistory.optionCombo.id )"
 			#else disabled="disabled" #end onfocus="this.select()"></td>
 	</tr>
 	<tr>
@@ -39,7 +53,7 @@
 		<td>$encoder.htmlEncode( $i18n.getString( "min_limit" ) ) </td>
 		<td><input type="text" id="minLimit" style="width:10em" value="$minLimit"
 			#if( $auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) && $auth.hasAccess( "dhis-web-dataentry", "removeMinMaxLimits" ))
-			   onchange="saveMinLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id )"
+			   onchange="saveMinLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )"
 			#else disabled="disabled" #end onfocus="this.select()"></td>
 	</tr>
 	<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2009-03-10 10:19:13 +0000
@@ -16,9 +16,9 @@
 	}
 }
 
-function viewHistory( dataElementId, optionComboId )
-{
-    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId, '_blank', 'width=560,height=550,scrollbars=yes' );
+function viewHistory( dataElementId, optionComboId, showComment )
+{    
+    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&showComment=' + showComment, '_blank', 'width=560,height=550,scrollbars=yes' );
 }
 
 /**

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js	2009-03-10 10:19:13 +0000
@@ -21,10 +21,10 @@
 // Comments
 // -----------------------------------------------------------------------------
 
-function commentSelected( dataElementId )
-{
-    var commentSelector = document.getElementById( 'value[' + dataElementId + '].comments' );
-    var commentField = document.getElementById( 'value[' + dataElementId + '].comment' );
+function commentSelected( dataElementId, optionComboId )
+{  
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
 
     var value = commentSelector.options[commentSelector.selectedIndex].value;
     
@@ -40,16 +40,16 @@
     {
         commentField.value = value;
         
-        saveComment( dataElementId, value );
+        saveComment( dataElementId, optionComboId, value );
     }
 }
 
-function commentLeft( dataElementId )
+function commentLeft( dataElementId, optionComboId )
 {
-    var commentField = document.getElementById( 'value[' + dataElementId + '].comment' );
-    var commentSelector = document.getElementById( 'value[' + dataElementId + '].comments' );
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
 
-    saveComment( dataElementId, commentField.value );
+    saveComment( dataElementId, optionComboId, commentField.value );
 
     var value = commentField.value;
     
@@ -152,15 +152,15 @@
     valueSaver.save();
 }
 
-function saveComment( dataElementId, commentValue )
+function saveComment( dataElementId, optionComboId, commentValue )
 {
-    var field = document.getElementById( 'value[' + dataElementId + '].comment' );
-    var select = document.getElementById( 'value[' + dataElementId + '].comments' );
+    var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+    var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
     
     field.style.backgroundColor = '#ffffcc';
     select.style.backgroundColor = '#ffffcc';
     
-    var commentSaver = new CommentSaver( dataElementId, commentValue );
+    var commentSaver = new CommentSaver( dataElementId, optionComboId, commentValue );
     commentSaver.save();
 }
 
@@ -246,12 +246,13 @@
     }
 }
 
-function CommentSaver( dataElementId_, value_ )
+function CommentSaver( dataElementId_, optionComboId_, value_ )
 {
     var SUCCESS = '#ccffcc';
     var ERROR = '#ccccff';
 
     var dataElementId = dataElementId_;
+    var optionComboId = optionComboId_
     var value = value_;
     
     this.save = function()
@@ -261,7 +262,7 @@
         request.setCallbackError( handleHttpError );
         request.setResponseTypeXML( 'status' );
         request.send( 'saveComment.action?dataElementId=' +
-                dataElementId + '&comment=' + value );
+                dataElementId + '&optionComboId=' + optionComboId + '&comment=' + value );
     };
     
     function handleResponse( rootElement )
@@ -288,8 +289,8 @@
     
     function markComment( color )
     {
-        var field = document.getElementById( 'value[' + dataElementId + '].comment' );
-        var select = document.getElementById( 'value[' + dataElementId + '].comments' );
+        var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+        var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );        
 
         field.style.backgroundColor = color;
         select.style.backgroundColor = color;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2009-03-10 10:19:13 +0000
@@ -1,4 +1,112 @@
 
+// -----------------------------------------------------------------------------
+// Comments
+// -----------------------------------------------------------------------------
+
+function commentSelected( dataElementId, optionComboId )
+{  
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
+
+    var value = commentSelector.options[commentSelector.selectedIndex].value;
+    
+    if ( value == 'custom' )
+    {
+        commentSelector.style.display = 'none';
+        commentField.style.display = 'inline';
+        
+        commentField.select();
+        commentField.focus();
+    }
+    else
+    {
+        commentField.value = value;
+        
+        saveComment( dataElementId, optionComboId, value );
+    }
+}
+
+function commentLeft( dataElementId, optionComboId )
+{
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
+
+    saveComment( dataElementId, optionComboId, commentField.value );
+
+    var value = commentField.value;
+    
+    if ( value == '' )
+    {
+        commentField.style.display = 'none';
+        commentSelector.style.display = 'inline';
+
+        commentSelector.selectedIndex = 0;
+    }
+}
+
+function saveComment( dataElementId, optionComboId, commentValue )
+{
+    var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+    var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
+    
+    field.style.backgroundColor = '#ffffcc';
+    select.style.backgroundColor = '#ffffcc';
+    
+    var commentSaver = new CommentSaver( dataElementId, optionComboId, commentValue );
+    commentSaver.save();
+}
+
+function CommentSaver( dataElementId_, optionComboId_, value_ )
+{
+    var SUCCESS = '#ccffcc';
+    var ERROR = '#ccccff';
+
+    var dataElementId = dataElementId_;
+    var optionComboId = optionComboId_
+    var value = value_;
+    
+    this.save = function()
+    {
+        var request = new Request();
+        request.setCallbackSuccess( handleResponse );
+        request.setCallbackError( handleHttpError );
+        request.setResponseTypeXML( 'status' );
+        request.send( 'saveComment.action?dataElementId=' +
+                dataElementId + '&optionComboId=' + optionComboId + '&comment=' + value );
+    };
+    
+    function handleResponse( rootElement )
+    {
+        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+        var code = parseInt( codeElement.firstChild.nodeValue );
+        
+        if ( code == 0 )
+        {
+            markComment( SUCCESS );           
+        }
+        else
+        {
+            markComment( ERROR );
+            window.alert( i18n_saving_comment_failed_status_code + '\n\n' + code );
+        }
+    }
+    
+    function handleHttpError( errorCode )
+    {
+        markComment( ERROR );
+        window.alert( i18n_saving_comment_failed_error_code + '\n\n' + errorCode );
+    }
+    
+    function markComment( color )
+    {
+        var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+        var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );        
+
+        field.style.backgroundColor = color;
+        select.style.backgroundColor = color;
+    }
+}
+
 function createChart()
 {
     var canvas = document.getElementById( 'canvas' );
@@ -80,7 +188,7 @@
     g.paint();
 }
 
-function saveMinLimit( organisationUnitId, dataElementId )
+function saveMinLimit( organisationUnitId, dataElementId, optionComboId )
 {
     var minLimitField = document.getElementById( "minLimit" );
     var maxLimitField = document.getElementById( "maxLimit" );
@@ -91,7 +199,7 @@
 
     if ( minLimitField.value == '' )
     {
-        request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId );
+        request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId );
     }
     else
     {
@@ -110,7 +218,7 @@
                 maxLimit = minLimit + 1;
             }
 
-            request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
+            request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
         }
         else
         {
@@ -119,7 +227,7 @@
     }
 }
 
-function saveMaxLimit( organisationUnitId, dataElementId )
+function saveMaxLimit( organisationUnitId, dataElementId, optionComboId )
 {
     var minLimitField = document.getElementById( "minLimit" );
     var maxLimitField = document.getElementById( "maxLimit" );
@@ -130,7 +238,7 @@
 
     if ( maxLimitField.value == '' )
     {
-        request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId );
+        request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId );
     }
     else
     {
@@ -153,7 +261,7 @@
                 minLimit = maxLimit - 1;
             }
 
-            request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
+            request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
         }
         else
         {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/multidimensional.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/multidimensional.js	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/multidimensional.js	2009-03-10 10:19:13 +0000
@@ -21,10 +21,14 @@
 // Comments
 // -----------------------------------------------------------------------------
 
-function commentSelected( dataElementId )
-{
-    var commentSelector = document.getElementById( 'value[' + dataElementId + '].comments' );
-    var commentField = document.getElementById( 'value[' + dataElementId + '].comment' );
+// -----------------------------------------------------------------------------
+// Comments
+// -----------------------------------------------------------------------------
+
+function commentSelected( dataElementId, optionComboId )
+{  
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
 
     var value = commentSelector.options[commentSelector.selectedIndex].value;
     
@@ -44,12 +48,12 @@
     }
 }
 
-function commentLeft( dataElementId )
+function commentLeft( dataElementId, optionComboId )
 {
-    var commentField = document.getElementById( 'value[' + dataElementId + '].comment' );
-    var commentSelector = document.getElementById( 'value[' + dataElementId + '].comments' );
+    var commentField = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
+    var commentSelector = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
 
-    saveComment( dataElementId, commentField.value );
+    saveComment( dataElementId, optionComboId, commentField.value );
 
     var value = commentField.value;
     
@@ -159,15 +163,15 @@
 
 }
 
-function saveComment( dataElementId, commentValue )
+function saveComment( dataElementId, optionComboId, commentValue )
 {
-    var field = document.getElementById( 'value[' + dataElementId + '].comment' );
-    var select = document.getElementById( 'value[' + dataElementId + '].comments' );
+    var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+    var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
     
     field.style.backgroundColor = '#ffffcc';
     select.style.backgroundColor = '#ffffcc';
     
-    var commentSaver = new CommentSaver( dataElementId, commentValue );
+    var commentSaver = new CommentSaver( dataElementId, optionComboId, commentValue );
     commentSaver.save();
 }
 
@@ -256,12 +260,13 @@
     }
 }
 
-function CommentSaver( dataElementId_, value_ )
+function CommentSaver( dataElementId_, optionComboId_, value_ )
 {
     var SUCCESS = '#ccffcc';
     var ERROR = '#ccccff';
 
     var dataElementId = dataElementId_;
+    var optionComboId = optionComboId_
     var value = value_;
     
     this.save = function()
@@ -271,7 +276,7 @@
         request.setCallbackError( handleHttpError );
         request.setResponseTypeXML( 'status' );
         request.send( 'saveComment.action?dataElementId=' +
-                dataElementId + '&comment=' + value );
+                dataElementId + '&optionComboId=' + optionComboId + '&comment=' + value );
     };
     
     function handleResponse( rootElement )
@@ -281,8 +286,7 @@
         
         if ( code == 0 )
         {
-            markComment( SUCCESS );
-           
+            markComment( SUCCESS );           
         }
         else
         {
@@ -299,8 +303,8 @@
     
     function markComment( color )
     {
-        var field = document.getElementById( 'value[' + dataElementId + '].comment' );
-        var select = document.getElementById( 'value[' + dataElementId + '].comments' );
+        var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );                
+        var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );        
 
         field.style.backgroundColor = color;
         select.style.backgroundColor = color;
@@ -393,9 +397,9 @@
 // View history
 // -----------------------------------------------------------------------------
 
-function viewHistory( dataElementId, optionComboId )
+function viewHistory( dataElementId, optionComboId, showComment )
 {
-    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId, '_blank', 'width=560,height=550,scrollbars=yes' );
+    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&showComment=' + showComment, '_blank', 'width=560,height=550,scrollbars=yes' );
 }
 
 /**

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multidimensional/form.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multidimensional/form.vm	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multidimensional/form.vm	2009-03-10 10:19:13 +0000
@@ -129,10 +129,10 @@
 								<div id="value[$dataElement.id:$optionCombo.id].max" style="display:none">$!minMax.max</div>	
 					
 								#if( $dataElement.aggregationOperator == "sum" )
-									<input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100% #if( $minMaxError ) ;background-color:#ffcccc #end #if( $dataElement.type == "int" ) ;text-align:center #end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+									<input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100% #if( $minMaxError ) ;background-color:#ffcccc #end #if( $dataElement.type == "int" ) ;text-align:center #end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
 								#else
 									#set( $zeroValueSaveMode = true )						
-									<input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100% #if( $minMaxError ) ;background-color:#ffcccc #end #if( $dataElement.type == "int" ) ;text-align:center #end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+									<input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100% #if( $minMaxError ) ;background-color:#ffcccc #end #if( $dataElement.type == "int" ) ;text-align:center #end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
 								#end				
 							#end			
 							



--

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.