← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3103: disabling dataentry for calculated dataelements (only for default and section forms).

 

------------------------------------------------------------
revno: 3103
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-03-20 20:16:57 +0100
message:
  disabling dataentry for calculated dataelements (only for default and section forms).
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.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/webapp/dhis-web-dataentry/defaultForm.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm


--
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/SelectAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java	2011-01-25 14:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java	2011-03-20 19:16:57 +0000
@@ -27,10 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
 import java.util.Date;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.CalculatedDataElement;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
@@ -55,6 +58,13 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+    
     private DataSetLockService dataSetLockService;
 
     public void setDataSetLockService( DataSetLockService dataSetLockService )
@@ -132,6 +142,13 @@
     {
         return registrationDate;
     }
+    
+    private Collection<CalculatedDataElement> calculatedDataElements;
+
+    public Collection<CalculatedDataElement> getCalculatedDataElements()
+    {
+        return calculatedDataElements;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -185,6 +202,13 @@
         }
         
         // ---------------------------------------------------------------------
+        // Get CalculatedDataElement info
+        // ---------------------------------------------------------------------
+
+        calculatedDataElements = dataElementService.getCalculatedDataElementsByDataElements( selectedDataSet.getDataElements() );       
+
+        
+        // ---------------------------------------------------------------------
         // Get data set completeness info
         // ---------------------------------------------------------------------
 

=== 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	2011-02-15 20:05:26 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2011-03-20 19:16:57 +0000
@@ -50,6 +50,7 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.de.action.SelectAction" class="org.hisp.dhis.de.action.SelectAction" scope="prototype">
+	    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
 		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
 		<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2011-03-20 09:29:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2011-03-20 19:16:57 +0000
@@ -33,8 +33,9 @@
   #set( $mark = 0 )
   #else
   #set( $mark = 1 )
-  #end
-
+  #end  
+  #set( $calculated = false )
+  #set( $calculated = ( $calculatedDataElements.contains( $dataElement ) ) )
   #set( $count = $count + 1 )
   <tr>
     <td  style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
@@ -62,8 +63,12 @@
       <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
     </select>
     #else
-    <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#end" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
-    #end
+        #if ( $calculated )
+            <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" disabled="disabled" onkeyup="return keyPress(event,this)" class="entryField" tabindex="$tabIndex">
+        #else    
+            <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#end" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
+        #end
+    #end    
     </td>
     #set( $tabIndex = $tabIndex + 1 )
     #end

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2011-03-20 09:29:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2011-03-20 19:16:57 +0000
@@ -52,6 +52,8 @@
       #else
       #set( $mark = 1 )
       #end
+      #set( $calculated = false )
+      #set( $calculated = ( $calculatedDataElements.contains( $dataElement ) ) )
       #set( $count = $count + 1 )
       <tr>
         <td  style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
@@ -81,7 +83,11 @@
           <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
         </select>
         #else
-        <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#elseif( $locked || $greyedField ) grey#end" tabindex="$tabIndex" #if( $locked || $greyedField )disabled="disabled"#end>
+            #if ( $calculated )
+                <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" disabled="disabled" onkeyup="return keyPress(event,this)" class="entryField" tabindex="$tabIndex">
+            #else
+                <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#elseif( $locked || $greyedField ) grey#end" tabindex="$tabIndex" #if( $locked || $greyedField )disabled="disabled"#end>
+            #end                
         #end
       </td>
       #set( $tabIndex = $tabIndex + 1 )