← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13845: Data entry, impl support for option sets for predefined comments

 

------------------------------------------------------------
revno: 13845
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-01-24 17:20:17 +0200
message:
  Data entry, impl support for option sets for predefined comments
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java
  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/history.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-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java	2014-01-23 11:54:46 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java	2014-01-24 15:20:17 +0000
@@ -40,6 +40,7 @@
 import org.hisp.dhis.datavalue.DataValueAudit;
 import org.hisp.dhis.datavalue.DataValueAuditService;
 import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
@@ -202,6 +203,13 @@
     {
         return storedBy;
     }
+    
+    private OptionSet commentOptionSet;
+
+    public OptionSet getCommentOptionSet()
+    {
+        return commentOptionSet;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -242,12 +250,10 @@
 
         minMaxInvalid = !DataElement.VALUE_TYPE_INT.equals( dataElement.getType() );
 
-        // ---------------------------------------------------------------------
-        // Data Value Audit
-        // ---------------------------------------------------------------------
-
         dataValueAudits = dataValueAuditService.getDataValueAuditByDataValue( dataValue );
 
+        commentOptionSet = dataElement.getCommentOptionSet();
+        
         return SUCCESS;
     }
 }

=== 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	2014-01-03 09:14:06 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2014-01-24 15:20:17 +0000
@@ -1,6 +1,10 @@
 <script type="text/javascript">
 var currentDataElementId = '$!{dataElementId}';
 var currentOptionComboId = '$!{optionComboId}';
+
+$( document ).ready( function() {
+    dhis2.de.insertCommentOptionSet( '$!{commentOptionSet.uid}' );
+} );
 </script>
 
 #set( $width = 40 * $dataElementHistory.historyLength )
@@ -27,7 +31,8 @@
     </tr>
     <tr>
 		<td valign="top">
-			<textarea id="commentTextArea" maxlength="360" style="height:130px;width:240px">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
+			<div id="commentOptionDiv" style="display:none;"><input type="text" id="commentOptionSet" style="width:240px"></div>
+			<textarea id="commentTextArea" maxlength="360" style="height:130px; width:240px;">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
 			<input type="button" value="$i18n.getString( 'save_comment' )" style="width:130px" onclick="saveComment()">
 		</td>		
         <td valign="top">

=== 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	2014-01-24 13:32:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-01-24 15:20:17 +0000
@@ -506,7 +506,7 @@
 
         $( this ).focus( valueFocus );
         $( this ).blur( valueBlur );
-
+        
         $( this ).change( function()
         {
             saveVal( dataElementId, optionComboId, id );
@@ -514,7 +514,7 @@
 
         if ( formType != FORMTYPE_CUSTOM ) 
         {
-            $( this ).css( 'width', '80%' );
+            $( this ).css( 'width', '85%' );
             $( this ).css( 'text-align', 'center' );
         }
     } );
@@ -2659,7 +2659,6 @@
         return;
     }
 
-    input.css( 'width', '85%' );
     input.autocomplete( {
         delay: 0,
         minLength: 0,

=== 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	2014-01-23 14:09:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-01-24 15:20:17 +0000
@@ -1,9 +1,8 @@
-// -----------------------------------------------------------------------------
-// Comments
-// -----------------------------------------------------------------------------
 
 function saveComment()
 {
+	$( '#commentOptionSet' ).val( '' );
+	
     var commentValue = $( '#commentTextArea' ).val();
     var periodId = $( '#selectedPeriodId' ).val();
 
@@ -197,3 +196,18 @@
 	    }
 	} );
 }
+
+dhis2.de.insertCommentOptionSet = function( optionSetId )
+{
+	$optSet = $( '#commentOptionSet' );
+	
+	$optSet.change( function() {
+		$( '#commentTextArea' ).val( $optSet.val() );
+		$optSet.val( '' );
+	} );
+	
+	if ( optionSetId ) {
+		$( '#commentOptionDiv' ).show();
+		dhis2.de.autocompleteOptionSetField( 'commentOptionSet', optionSetId );
+	}
+};