← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2127: Improved display mode selection

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 2127 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2010-11-21 16:52:39 +0100
message:
  Improved display mode selection
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/SelectedStateManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java	2010-11-18 12:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java	2010-11-21 15:52:10 +0000
@@ -106,6 +106,12 @@
             {
                 period.setName( format.formatPeriod( period ) );
             }
+
+            // -----------------------------------------------------------------
+            // Clear display mode when loading new data set
+            // -----------------------------------------------------------------
+
+            selectedStateManager.clearSelectedDisplayMode();
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2010-11-20 11:38:25 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2010-11-21 15:52:10 +0000
@@ -292,6 +292,11 @@
         return (String) getSession().get( SESSION_KEY_SELECTED_DISPLAY_MODE );
     }
     
+    public void clearSelectedDisplayMode()
+    {
+        getSession().remove( SESSION_KEY_SELECTED_DISPLAY_MODE );
+    }
+    
     public boolean displayModeIsValid( String displayMode )
     {
         DataSet dataSet = getSelectedDataSet();

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/SelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/SelectedStateManager.java	2010-11-20 11:38:25 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/SelectedStateManager.java	2010-11-21 15:52:10 +0000
@@ -92,6 +92,8 @@
     
     String getSelectedDisplayMode();
     
+    void clearSelectedDisplayMode();
+    
     boolean displayModeIsValid( String displayMode );
     
     String getDisplayMode();

=== 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	2010-11-21 15:05:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2010-11-21 15:52:10 +0000
@@ -55,7 +55,8 @@
     		$( '#selectedDataSetId' ).val( dataSetId );
     		
     		if ( json.periodValid ) {
-    			displayEntryFormInternal( false );
+    			showLoader();
+    			$( '#contentDiv' ).load( 'select.action', displayEntryFormCompleted );
     		}
     	}
     	else {
@@ -122,8 +123,9 @@
 	    	}
 	    	
 	    	if ( json.periodValid && periodIndex != null ) {
-	    		$( '#selectedPeriodIndex' ).val( periodIndex );	    		
-	    		displayEntryFormInternal( true );
+	    		showLoader();	    		
+	    		$( '#selectedPeriodIndex' ).val( periodIndex );
+    			$( '#contentDiv' ).load( 'select.action', setDisplayModes );
 	    	}
 	    	else {
 	    		clearEntryForm();
@@ -138,7 +140,11 @@
 
 function displayModeSelected()
 {
-	displayEntryFormInternal( false );
+	showLoader();
+	
+	var url = 'select.action?displayMode=' + $("input[name='displayMode']:checked").val();
+	
+	$( '#contentDiv' ).load( url, displayEntryFormCompleted );
 }
 
 // -----------------------------------------------------------------------------
@@ -150,27 +156,13 @@
 	var periodName = $( '#selectedPeriodIndex :selected' ).text();
 	
 	$( '#currentPeriod' ).html( periodName );
-	
-	displayEntryFormInternal( true );
-}
-
-function displayEntryFormInternal( updateDisplayModes )
-{
-	showLoader();
-	
+		
 	var periodIndex = $( '#selectedPeriodIndex' ).val();
 	
-	if ( periodIndex && periodIndex != -1 )
-	{
+	if ( periodIndex && periodIndex != -1 )	{
+		showLoader();
 		var url = 'select.action?selectedPeriodIndex=' + periodIndex;
-		
-		var displayMode = $("input[name='displayMode']:checked").val();
-		
-		url += displayMode ? '&displayMode=' + displayMode : '';
-		
-		var callback = updateDisplayModes ? setDisplayModes : displayEntryFormCompleted;
-		
-		$( '#contentDiv' ).load( url, callback );
+		$( '#contentDiv' ).load( url, setDisplayModes );
 	}
 }
 
@@ -400,15 +392,13 @@
             
             setInnerHTML('value[' + deId + ':' + ocId + '].min', getElementValue( dataElements[i], 'minLimit'));
             setInnerHTML('value[' + deId + ':' + ocId + '].max', getElementValue( dataElements[i], 'maxLimit'));
-        }
-        
+        }        
     }
     
     function handleHttpError( errorCode )
     {
         window.alert( i18n_saving_minmax_failed_error_code + '\n\n' + errorCode );
-    }   
-   
+    }
     
     function getElementValue( parentElement, childElementName )
     {