← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5: A filter made to enforce users design a custom dataentry form when having datalements of differen...

 

------------------------------------------------------------
revno: 5
committer: abyot <abyota@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2009-03-08 17:20:57 +0530
message:
  A filter made to enforce users design a custom dataentry form when having datalements of different dimensions.
modified:
  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/resources/org/hisp/dhis/de/i18n_module.properties
  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/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-03-08 11:50:57 +0000
@@ -294,6 +294,13 @@
     {
         return zeroValueSaveMode;
     }
+    
+    private Boolean disableDefaultForm;
+
+    public Boolean getDisableDefaultForm()
+    {
+        return disableDefaultForm;
+    } 
 
     // -------------------------------------------------------------------------
     // Input/output
@@ -331,7 +338,10 @@
 
     public String execute()
         throws Exception
-    {    	
+    {      	
+    	
+    	disableDefaultForm = false;
+    	
     	zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );   	
     	
     	OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
@@ -512,14 +522,26 @@
 
         dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet );
         
-        cdeFormExists = (dataEntryForm != null);
+        cdeFormExists = ( dataEntryForm != null );
         
         if ( cdeFormExists )
         {            
             customDataEntryFormCode = dataEntryScreenManager.populateCustomDataEntryScreenForMultiDimensional( dataEntryForm.getHtmlCode(), 
                 dataValues, calculatedValueMap, minMaxMap, disabled, zeroValueSaveMode, i18n );
-        }     
+        }        
         
+        if( dataEntryScreenManager.hasMixOfDimensions( dataSet ) )
+        {        
+    		disableDefaultForm = true;  		
+    	
+    		if ( !cdeFormExists )
+            {    			
+    			customDataEntryFormCode = i18n.getString( "please_design_a_custom_form" );
+    			
+    			return SUCCESS;
+            }        	        	
+        }   
+        	
         // ---------------------------------------------------------------------
         // Working on the display of dataelements
         // ---------------------------------------------------------------------

=== 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-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DataEntryScreenManager.java	2009-03-08 11:50:57 +0000
@@ -18,7 +18,9 @@
  */
 public interface DataEntryScreenManager 
 {	    
-    String getScreenType( DataSet dataSet );    
+    String getScreenType( DataSet dataSet );
+    
+    boolean hasMixOfDimensions( DataSet dataset );
     
     boolean hasMultiDimensionalDataElement( DataSet dataSet );
     

=== 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-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2009-03-08 11:50:57 +0000
@@ -33,6 +33,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -41,6 +42,7 @@
 import org.hisp.dhis.dataelement.CalculatedDataElement;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -101,6 +103,29 @@
     // -------------------------------------------------------------------------
     // DataEntryScreenManager implementation
     // -------------------------------------------------------------------------
+    
+    public boolean hasMixOfDimensions( DataSet dataSet )
+    {      	
+    	
+    	if ( dataSet.getDataElements().size() > 0 )
+        {       
+        	Iterator<DataElement> dataElementIterator = dataSet.getDataElements().iterator();
+        	
+        	DataElementCategoryCombo catCombo = dataElementIterator.next().getCategoryCombo();       	
+
+            for ( DataElement de : dataSet.getDataElements() )
+            {           	
+            	
+            	if( catCombo != de.getCategoryCombo() )
+            	{            		
+            		return true;
+            	}                
+            }
+        }
+
+        return false;
+        
+    }
 
     public boolean hasMultiDimensionalDataElement( DataSet dataSet )
     {

=== 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-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2009-03-08 11:50:57 +0000
@@ -1,3 +1,4 @@
+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)
 export_entry_template				= Export Entry screen as Excel

=== 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-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multidimensional/form.vm	2009-03-08 11:50:57 +0000
@@ -1,13 +1,22 @@
 <script>
     customDataEntryFormExists = "false";
-    #if ( $customDataEntryFormExists)
+    #if ( $customDataEntryFormExists )
         customDataEntryFormExists = "true";
     #end
 </script>
 
 #parse( "/dhis-web-dataentry/select.vm" )
 
-#if ( $customDataEntryFormExists && !$useDefaultForm )
+#if ( !$cdeFormExists && $disableDefaultForm )
+	
+	<div style="text-align:center">
+	
+    	<h2> $customDataEntryFormCode </h2>
+    	
+	</div>
+
+		
+#elseif ( $customDataEntryFormExists && !$useDefaultForm )
 	
 		#foreach( $optionCombo in $orderdCategoryOptionCombos )
 			
@@ -93,10 +102,10 @@
 					<span id="value[option$optionCombo.id].name" style="display:none">$optionComboNames.get( $optionCombo.id )</span>	
 					
 					#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  )" #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  )" #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  )" #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  )" #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.