← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6150: Fixed bug with selection of report params page

 

------------------------------------------------------------
revno: 6150
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-02 12:49:40 +0100
message:
  Fixed bug with selection of report params page
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.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-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2012-03-02 09:08:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js	2012-03-02 11:49:40 +0000
@@ -40,10 +40,15 @@
 	{
 		return selectedOrganisationUnit;
 	};
+	
+	this.isSelected = function()
+	{
+		return selectedOrganisationUnit && selectedOrganisationUnit.length > 0;
+	}
 
     this.select = function( unitId )
     {
-        if ( onSelectFunction )
+       if ( onSelectFunction )
         {
             onSelectFunction();
         }
@@ -88,11 +93,6 @@
 
     function responseReceived( json )
     {
-        if ( !listenerFunction )
-        {
-            return;
-        }       
-
 		selectedOrganisationUnit = new Array();
 
 		var unitIds = new Array();
@@ -104,7 +104,11 @@
         }
 
         jQuery("body").trigger("oust.selected", selectedOrganisationUnit);
-        listenerFunction( unitIds );
+        
+        if ( listenerFunction )
+        {
+        	listenerFunction( unitIds );
+        }
     }
 
     function getTagId( unitId )
@@ -123,8 +127,7 @@
     {
     	$.ajax({ 
     		url: selectionTreePath + "clearSelectedOrganisationUnits.action",
-			async: false,
-			dataType: "xml"
+			async: false
     	});
     };
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2012-02-12 12:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2012-03-02 11:49:40 +0000
@@ -1,13 +1,17 @@
 
 <script type="text/javascript">
-	jQuery(document).ready(function() {
-		#if( !$!reportParams.isSet() )
-		viewReport( '' );
-		#end
-	});
+jQuery(document).ready(function() {
+	#if( !$!reportParams.isSet() )
+	viewReport( '' );
+	#end
+	
+	selectionTreeSelection.setMultipleSelectionAllowed( false );
+	selectionTree.clearSelectedOrganisationUnits();
+	selectionTree.buildSelectionTree();
+});
 
-    var i18n_process_completed = '$encoder.jsEscape( $i18n.getString( "process_completed" ), "'")';
-	var i18n_please_select_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
+var i18n_process_completed = '$encoder.jsEscape( $i18n.getString( "process_completed" ), "'")';
+var i18n_please_select_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
 </script>
 
 <h3>$i18n.getString( "report_table_parameters" )</h3>
@@ -48,13 +52,7 @@
     </tr>
     <tr>
 	    <td>
-			<div id="selectionTree" style="width:325px; height:200px"></div>	            
-			<script type="text/javascript">
-				selectionTreeSelection.setMultipleSelectionAllowed( false );
-				selectionTreeSelection.setListenerFunction( paramOrganisationUnitSet );
-				selectionTree.clearSelectedOrganisationUnits();
-			    selectionTree.buildSelectionTree();
-			</script>
+			<div id="selectionTree" style="width:325px; height:210px"></div>
 	    </td>
 	</tr>
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2012-02-12 12:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2012-03-02 11:49:40 +0000
@@ -2,23 +2,12 @@
 var MODE_TABLE = "table";
 
 // -----------------------------------------------------------------------------
-// Report params
-// -----------------------------------------------------------------------------
-
-var paramOrganisationUnit = null;
-
-function paramOrganisationUnitSet( id )
-{
-    paramOrganisationUnit = id;
-}
-
-// -----------------------------------------------------------------------------
 // Validation
 // -----------------------------------------------------------------------------
 
 function validationError()
 {
-    if ( $( "#selectionTree" ).length && paramOrganisationUnit == null )
+    if ( $( "#selectionTree" ).length && !selectionTreeSelection.isSelected() )
     {
         setMessage( i18n_please_select_unit );
         return true;
@@ -63,9 +52,9 @@
         url += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
     }
 
-    if ( paramOrganisationUnit != null )
+    if ( selectionTreeSelection.isSelected() )
     {
-        url += "&organisationUnitId=" + paramOrganisationUnit;
+        url += "&organisationUnitId=" + selectedOrganisationUnit[0];
     }
 
     return url;