← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6938: local vn - Fixed bug automatically show data sets when the user lead to the entry page.

 

------------------------------------------------------------
revno: 6938
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-15 13:05:09 +0700
message:
  local vn - Fixed bug automatically show data sets when the user lead to the entry page.
removed:
  local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/PageInitAction.java
added:
  local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/ShowHospitalEntryFormAction.java
modified:
  local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java
  local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml
  local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml
  local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js
  local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/menu.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.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 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java	2012-05-11 08:58:29 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java	2012-05-15 06:05:09 +0000
@@ -98,17 +98,18 @@
         sources.add( selectionManager.getSelectedOrganisationUnit() );
 
         Collection<DataSet> _dataSets = dataSetService.getDataSetsBySources( sources );
-        
-        Collection<UserAuthorityGroup> authorityGroups = currentUserService.getCurrentUser().getUserCredentials().getUserAuthorityGroups();
-        
-        for( UserAuthorityGroup UserAuthorityGroup : authorityGroups )
+
+        Collection<UserAuthorityGroup> authorityGroups = currentUserService.getCurrentUser().getUserCredentials()
+            .getUserAuthorityGroups();
+
+        for ( UserAuthorityGroup UserAuthorityGroup : authorityGroups )
         {
             _dataSets.retainAll( UserAuthorityGroup.getDataSets() );
         }
 
         dataSets.addAll( _dataSets );
         Collections.sort( dataSets, new DataSetNameComparator() );
-        
+
         return SUCCESS;
     }
 

=== removed file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/PageInitAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/PageInitAction.java	2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/PageInitAction.java	1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
-package org.hisp.dhis.de.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-
-/**
- * @author Lars Helge Overland
- */
-public class PageInitAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        selectionManager.clearSelectedOrganisationUnits();
-
-        return SUCCESS;
-    }
-}

=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/ShowHospitalEntryFormAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/ShowHospitalEntryFormAction.java	1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/ShowHospitalEntryFormAction.java	2012-05-15 06:05:09 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.de.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ShowHospitalEntryFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private OrganisationUnitSelectionManager selectionManager;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnit unit;
+
+    public OrganisationUnit getUnit()
+    {
+        return unit;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        unit = selectionManager.getSelectedOrganisationUnit();
+
+        return SUCCESS;
+    }
+}

=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml	2012-05-11 08:28:02 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml	2012-05-15 06:05:09 +0000
@@ -11,9 +11,8 @@
 
   <!-- Actions -->
 
-  <bean id="org.hisp.dhis.de.action.PageInitAction" class="org.hisp.dhis.de.action.PageInitAction" scope="prototype">
-    <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-  </bean>
+  <bean id="org.hisp.dhis.de.action.ShowHospitalEntryFormAction" class="org.hisp.dhis.de.action.ShowHospitalEntryFormAction"
+	  scope="prototype"/>
 
   <bean id="org.hisp.dhis.de.action.GetMetaDataAction" class="org.hisp.dhis.de.action.GetMetaDataAction"
       scope="prototype">

=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml'
--- local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml	2012-05-10 16:18:43 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml	2012-05-15 06:05:09 +0000
@@ -8,7 +8,7 @@
 
   <package name="dhis-web-dataentry-hospital" extends="dhis-web-commons" namespace="/dhis-web-dataentry-hospital">
 
-    <action name="index" class="org.hisp.dhis.de.action.PageInitAction">
+    <action name="index" class="org.hisp.dhis.de.action.ShowHospitalEntryFormAction">
       <interceptor-ref name="organisationUnitTreeStack" />
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-dataentry-hospital/select.vm</param>

=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js	2012-05-11 03:39:22 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js	2012-05-15 06:05:09 +0000
@@ -31,6 +31,9 @@
 // Currently selected organisation unit identifier
 var currentOrganisationUnitId = null;
 
+// The current selected orgunit name
+var currentOrganisationUnitName = "";
+
 // Currently selected data set identifier
 var currentDataSetId = null;
 
@@ -68,42 +71,53 @@
  * download updated forms from server
  */
 
-function organisationUnitSelected( orgUnits, orgUnitNames )
+function organisationUnitSelectedHospitals( orgUnits, orgUnitNames )
 {
 	clearEntryForm();
-	
+
     currentOrganisationUnitId = orgUnits[0];
-    var organisationUnitName = orgUnitNames[0];
-
-    $( '#selectedOrganisationUnit' ).html( organisationUnitName );
-    $( '#currentOrganisationUnit' ).html( organisationUnitName );
+    currentOrganisationUnitName = orgUnitNames[0];
+
+	loadDataSets( currentOrganisationUnitName );
+}
+
+selection.setListenerFunction( organisationUnitSelectedHospitals );
+
+function loadDataSets( _unitName )
+{
+	if ( _unitName )
+	{
+		jQuery( '#selectedOrganisationUnit' ).html( _unitName );
+		jQuery( '#currentOrganisationUnit' ).html( _unitName );
 	
-	$.ajax({
-    	url: 'loadDataSet.action',
-    	dataType: 'json',
-    	success: function( json )
-	    {
-			var dataSetList = json.dataSets;
-
-			$( '#selectedDataSetId' ).removeAttr( 'disabled' );
-
-			var dataSetId = $( '#selectedDataSetId option:selected' ).val();
-			var periodId = $( '#selectedPeriodId option:selected' ).val();
-
-			clearListById( 'selectedDataSetId' );
-			//addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-
-			var dataSetValid = false;
-
-			for ( i in dataSetList )
+		jQuery.ajax({
+			type: 'GET',
+			url: 'loadDataSet.action',
+			dataType: 'json',
+			//async: false,
+			success: function( json )
 			{
-				$('#selectedDataSetId').append('<option value=' + dataSetList[i].id  + ' formType="'+ dataSetList[i].formType + '" periodType="' + dataSetList[i].periodType + '" >' + dataSetList[i].name + '</option>');
+				var dataSetList = json.dataSets;
+
+				$( '#selectedDataSetId' ).removeAttr( 'disabled' );
+
+				var dataSetId = $( '#selectedDataSetId option:selected' ).val();
+				var periodId = $( '#selectedPeriodId option:selected' ).val();
+
+				clearListById( 'selectedDataSetId' );
+				//addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+
+				var dataSetValid = false;
+
+				for ( i in dataSetList )
+				{
+					$('#selectedDataSetId').append('<option value=' + dataSetList[i].id  + ' formType="'+ dataSetList[i].formType + '" periodType="' + dataSetList[i].periodType + '" >' + dataSetList[i].name + '</option>');
+				}
+				
+				enable('selectedDataSetId');
 			}
-			
-			enable('selectedDataSetId');
-		}
-		
-	});
+		});
+	}
 }
 
 function addEventListeners()

=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/menu.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/menu.vm	2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/menu.vm	2012-05-15 06:05:09 +0000
@@ -1,6 +1,7 @@
 <script type="text/javascript">
 jQuery(document).ready(function() {
-	selection.setListenerFunction( organisationUnitSelected );
+	currentOrganisationUnitName = '$!unit.name';
+	loadDataSets( currentOrganisationUnitName );
 });
 </script>
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-05-12 15:59:33 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-05-15 06:05:09 +0000
@@ -25,26 +25,31 @@
 
 function getExportReportsByGroup( selectedOrgUnitName ) {
 
+	var groupId = getFieldValue( 'group' );
+
 	if ( selectedOrgUnitName )
 	{
 		setInnerHTML( "selectedOrganisationUnit", selectedOrgUnitName );
-		
-		jQuery.postJSON( 'getExportReportsByGroup.action',
-		{
-			group: getFieldValue( 'group' )
-		},
-		function ( json )
-		{
-			jQuery('#exportReport').empty();
-			jQuery.each( json.exportReports, function(i, item){
-				addOptionById( 'exportReport', item.id + '_' + item.periodType + '_' + item.reportType, item.name );
+
+		if ( groupId )
+		{
+			jQuery.postJSON( 'getExportReportsByGroup.action',
+			{
+				group: groupId
+			},
+			function ( json )
+			{
+				jQuery('#exportReport').empty();
+				jQuery.each( json.exportReports, function(i, item){
+					addOptionById( 'exportReport', item.id + '_' + item.periodType + '_' + item.reportType, item.name );
+				});
+
+				currentPeriodOffset = 0;
+
+				reportSelected();
+				displayPeriodsInternal();
 			});
-
-			currentPeriodOffset = 0;
-
-			reportSelected();
-			displayPeriodsInternal();
-		});
+		}
 	}
 }