← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 49: More control on mix max for different types of dataentry screens.

 

------------------------------------------------------------
revno: 49
committer: abyot <abyota@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-03-12 17:10:58 +0530
message:
  More control on mix max for different types of dataentry screens.
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DataEntryScreenManager.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/webapp/dhis-web-dataentry/form.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

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2009-03-12 11:40:58 +0000
@@ -262,7 +262,12 @@
     public String execute()
         throws Exception
     {    	
-    	zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );   	
+    	zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );
+    	
+    	if( zeroValueSaveMode == null )
+    	{
+    		zeroValueSaveMode = false;
+    	}
     	
     	OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
@@ -343,7 +348,7 @@
         
         if ( cdeFormExists )
         {        	
-        	customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreen( dataEntryForm.getHtmlCode(), dataValues, calculatedValueMap, minMaxMap, disabled, i18n );
+        	customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreen( dataEntryForm.getHtmlCode(), dataValues, calculatedValueMap, minMaxMap, disabled, zeroValueSaveMode, i18n );
         }            
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	2009-03-12 11:40:58 +0000
@@ -102,8 +102,8 @@
 
     public String execute()
         throws Exception
-    {
-        minMaxDataElements = new ArrayList<MinMaxDataElement>();
+    {    	
+    	minMaxDataElements = new ArrayList<MinMaxDataElement>();
 
         Period period = selectedStateManager.getSelectedPeriod();
 
@@ -115,20 +115,19 @@
             .getOrderedDataElements( dataSet ) );
 
         for ( DataElement dataelement : dataElements )
-        {
+        {        	
             if ( dataelement.getType().equals( DataElement.TYPE_INT ) )
-            {
+            {            	
                 for( DataElementCategoryOptionCombo optionCombo : dataelement.getCategoryCombo().getOptionCombos() )
-                {
+                {                	
                 	DataElementHistory dataElementHistory = historyRetriever.getHistory( dataelement, optionCombo, organisationUnit,
-                            period, HISTORY_LENGTH );
-
-                        setMinMaxLimits( dataElementHistory, organisationUnit, dataelement, optionCombo );
+                            period, HISTORY_LENGTH );                	
+                    setMinMaxLimits( dataElementHistory, organisationUnit, dataelement, optionCombo );
                 }
             	
             }
-        }
-
+        }        
+        
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-03-12 11:40:58 +0000
@@ -342,8 +342,13 @@
     	
     	disableDefaultForm = false;
     	
-    	zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );   	
+    	zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );
     	
+    	if( zeroValueSaveMode == null )
+    	{
+    		zeroValueSaveMode = false;
+    	}
+    	   	
     	OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         DataSet dataSet = selectedStateManager.getSelectedDataSet();

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DataEntryScreenManager.java	2009-03-09 19:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DataEntryScreenManager.java	2009-03-12 11:40:58 +0000
@@ -32,7 +32,7 @@
     
     Map<CalculatedDataElement, Integer> populateValuesForCalculatedDataElements( OrganisationUnit organisationUnit, DataSet dataSet, Period period );
     
-    String populateCustomDataEntryScreen( String dataEntryFormCode, Collection<DataValue> dataValues, Map<CalculatedDataElement,Integer> calculatedValueMap, Map<Integer, MinMaxDataElement> minMaxMap, String disabled, I18n i18n );
+    String populateCustomDataEntryScreen( String dataEntryFormCode, Collection<DataValue> dataValues, Map<CalculatedDataElement,Integer> calculatedValueMap, Map<Integer, MinMaxDataElement> minMaxMap, String disabled, Boolean saveMode, I18n i18n );
     
     String populateCustomDataEntryScreenForMultiDimensional( String dataEntryFormCode, Collection<DataValue> dataValues, Map<CalculatedDataElement,Integer> calculatedValueMap, Map<String, MinMaxDataElement> minMaxMap, String disabled, Boolean saveMode, I18n i18n );
 

=== 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-10 10:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2009-03-12 11:40:58 +0000
@@ -291,14 +291,14 @@
 
     public String populateCustomDataEntryScreen( String dataEntryFormCode, Collection<DataValue> dataValues,
         Map<CalculatedDataElement, Integer> calculatedValueMap, Map<Integer, MinMaxDataElement> minMaxMap,
-        String disabled, I18n i18n )
+        String disabled, Boolean saveMode, I18n i18n )
     {
         // ---------------------------------------------------------------------
         // Inline Javascript to add to HTML before outputting.
-        // ---------------------------------------------------------------------
-        
-        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 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, true )' ";
         final String calDataElementCode = " class=\"calculated\" disabled ";
 
@@ -308,8 +308,8 @@
         
         final String metaDataCode = "<span id=\"value[$DATAELEMENTID].name\" style=\"display:none\">$DATAELEMENTNAME</span>"
             + "<span id=\"value[$DATAELEMENTID].type\" style=\"display:none\">$DATAELEMENTTYPE</span>"
-            + "<div id=\"value[$DATAELEMENTID].min\" style=\"display:none\">$MIN</div>"
-            + "<div id=\"value[$DATAELEMENTID].max\" style=\"display:none\">$MAX</div>";
+            + "<div id=\"value[$DATAELEMENTID:$OPTIONCOMBOID].min\" style=\"display:none\">$MIN</div>"
+            + "<div id=\"value[$DATAELEMENTID:$OPTIONCOMBOID].max\" style=\"display:none\">$MAX</div>";
 
         // Buffer to contain the final result.
         StringBuffer sb = new StringBuffer();
@@ -398,10 +398,6 @@
                         dataElementCode = dataElementCode.replace( "value=\"\"", "value=\"" + dataElementValue + "\"" );
                     else
                         dataElementCode += "value=\"" + dataElementValue + "\"";
-
-                    dataElementCode = dataElementCode.replace( "value[" + dataElementId + "].value:value["
-                        + optionComboId + "].value", "value[" + dataElementId + "].value" );
-
                 }
 
                 // ---------------------------------------------------------------------
@@ -468,12 +464,18 @@
 
                     appendCode += " />";
                 }
-
+                
+                if( ! dataElement.getAggregationOperator().equalsIgnoreCase( DataElement.AGGREGATION_OPERATOR_SUM ) )
+                {
+                	saveMode = true;
+                }
+					
                 appendCode += metaDataCode;
                 appendCode = appendCode.replace( "$DATAELEMENTID", String.valueOf( dataElementId ) );
                 appendCode = appendCode.replace( "$OPTIONCOMBOID", String.valueOf( optionComboId ) );
                 appendCode = appendCode.replace( "$DATAELEMENTNAME", dataElement.getName() );
                 appendCode = appendCode.replace( "$DATAELEMENTTYPE", dataElementType );
+                appendCode = appendCode.replace( "$SAVEMODE", "" + saveMode + "" );
                 appendCode = appendCode.replace( "$DISABLED", disabled );
 
                 if ( minMaxDataElement == null )
@@ -705,6 +707,11 @@
 
                     appendCode += " />";
                 }
+                
+                if( ! dataElement.getAggregationOperator().equalsIgnoreCase( DataElement.AGGREGATION_OPERATOR_SUM ) )
+                {
+                	saveMode = true;
+                }
 
                 appendCode += metaDataCode;
                 appendCode = appendCode.replace( "$DATAELEMENTID", String.valueOf( dataElementId ) );

=== 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-10 10:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/form.vm	2009-03-12 11:40:58 +0000
@@ -90,7 +90,7 @@
 		<td>				
 				
 		#if( $dataElement.type == "bool" )
-			<select name="entryselect" id="value[$dataElement.id].value" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" )) onchange="saveBoolean( $dataElement.id, this )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>				
+			<select name="entryselect" id="value[$dataElement.id].value" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" )) onchange="saveBoolean( $dataElement.id, $optionComboId, this )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>				
 				<option value="">[$i18n.getString( "no_value" )]</option>
 				<option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
 				<option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>

=== 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-10 10:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2009-03-12 11:40:58 +0000
@@ -188,6 +188,15 @@
     }
 }
 
+// -----------------------------------------------------------------------------
+// View history
+// -----------------------------------------------------------------------------
+
+function viewHistory( dataElementId, optionComboId, showComment )
+{
+    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&showComment=' + showComment, '_blank', 'width=560,height=550,scrollbars=yes' );
+}
+
 /**
  * Set min/max limits for dataelements that has one or more values, and no 
  * manually entred min/max limits.

=== 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-10 10:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/general.js	2009-03-12 11:40:58 +0000
@@ -144,11 +144,11 @@
 
 }
 
-function saveBoolean( dataElementId, selectedOption )
+function saveBoolean( dataElementId, optionComboId, selectedOption )
 {
     selectedOption.style.backgroundColor = '#ffffcc';
     
-    var valueSaver = new ValueSaver( dataElementId, selectedOption.options[selectedOption.selectedIndex].value, '#ccffcc', selectedOption );
+    var valueSaver = new ValueSaver( dataElementId, optionComboId, selectedOption.options[selectedOption.selectedIndex].value, '#ccffcc', selectedOption );
     valueSaver.save();
 }
 



--

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.