← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10127: Error when to load favorite in the first time in tabular report.

 

------------------------------------------------------------
revno: 10127
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-03-11 13:04:54 +0700
message:
  Error when to load favorite in the first time in tabular report.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitsAction.java
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.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
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitsAction.java	2013-03-11 06:04:54 +0000
@@ -0,0 +1,88 @@
+package org.hisp.dhis.caseentry.action.report;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class GetOrganisationUnitsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Collection<String> ids;
+
+    public void setIds( Collection<String> ids )
+    {
+        this.ids = ids;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+    
+    private Collection<OrganisationUnit> object = new ArrayList<OrganisationUnit>();
+
+    public Collection<OrganisationUnit> getObject()
+    {
+        return object;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        object = organisationUnitService.getOrganisationUnitsByUid( ids );
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-03-11 03:26:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-03-11 06:04:54 +0000
@@ -934,6 +934,15 @@
 		<property name="tabularReportService"
 			ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
 	</bean>
+	
+	
+  <bean id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
+    class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
+    scope="prototype">
+    <property name="organisationUnitService"
+      ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+  </bean>
+	
 
 	<!-- Patient Aggregate Report -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-03-11 03:26:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-03-11 06:04:54 +0000
@@ -204,6 +204,12 @@
       <result name="success" type="velocity-json">/dhis-web-caseentry/jsonUsernames.vm
       </result>
     </action>
+    
+   	<action name="getOrganisationUnitPaths"
+		class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction">
+		<result name="success" type="velocity-json">
+			/dhis-web-caseentry/jsonminOrganisationUnitPaths.vm</result>
+	</action>
 
     <!-- save value -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-03-08 16:09:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-03-11 06:04:54 +0000
@@ -59,6 +59,7 @@
             aggregatefavorite_delete: 'deleteAggregateReport.action',
 			generateaggregatereport_get: 'generateAggregateReport.action',
 			username_dataelement_get: 'getUsernameList.action',
+			organisationunit_getbyids: 'getOrganisationUnitPaths.action',
 			redirect: 'index.action'
         },
         params: {
@@ -1050,11 +1051,10 @@
 								var treepanel = TR.cmp.params.organisationunit.treepanel;
 								treepanel.getSelectionModel().deselectAll();
 								TR.state.orgunitIds = [];
-								treepanel.numberOfRecords = f.orgunitIds.length;
 								for (var i = 0; i < f.orgunitIds.length; i++) {
-									treepanel.multipleExpand(f.orgunitIds[i].id, f.orgunitIds[i].path);
 									TR.state.orgunitIds.push( f.orgunitIds[i].localid );
 								}
+								treepanel.selectByIds(TR.state.orgunitIds);
 								
 								 // Patient properties
 								 Ext.getCmp('filterPropPanel').removeAll();
@@ -1244,9 +1244,9 @@
 								TR.state.orgunitIds = [];
 								treepanel.numberOfRecords = f.orgunitIds.length;
 								for (var i = 0; i < f.orgunitIds.length; i++) {
-									treepanel.multipleExpand(f.orgunitIds[i].id, f.orgunitIds[i].path);
 									TR.state.orgunitIds.push( f.orgunitIds[i].localid );
 								}
+								treepanel.selectByIds(TR.state.orgunitIds);
 								
 								// Selected data elements
 								
@@ -3873,17 +3873,12 @@
 														this.rendered = true;
 													},
 													afterrender: function( treePanel, eOpts ){
-														treePanel.getSelectionModel().select( treePanel.getRootNode() );
 														TR.state.orgunitIds = [];
-														var orgunitid = treePanel.getSelectionModel().getSelection()[0].data.localid;
-														if(orgunitid==0){
-															for( var i in TR.init.system.rootnodes){
-																 TR.state.orgunitIds.push( TR.init.system.rootnodes[i].localid );
-															}
+														for( var i in TR.init.system.rootnodes){
+															TR.state.orgunitIds.push( TR.init.system.rootnodes[i].localid );
+															var node = TR.cmp.params.organisationunit.treepanel.getRootNode().findChild('id', TR.init.system.rootnodes[i].id, true);
+															TR.cmp.params.organisationunit.treepanel.getSelectionModel().select(node);
 														}
-														else{
-															TR.state.orgunitIds.push( orgunitid );
-														}													
 													},
 													itemclick : function(view,rec,item,index,eventObj){
 														TR.state.orgunitIds = [];
@@ -3935,6 +3930,7 @@
 											},
 											expand: function() {
 												TR.cmp.params.organisationunit.treepanel.setHeight(TR.cmp.params.organisationunit.panel.getHeight() - TR.conf.layout.west_fill_accordion_organisationunit - 60 );
+												TR.cmp.params.organisationunit.treepanel.selectRootIf();
 											}
 										}
 									},