← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7629: [mobile] ignore OrgUnit selection if there's only one OrgUnit

 

------------------------------------------------------------
revno: 7629
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-07-18 11:43:02 +0700
message:
  [mobile] ignore OrgUnit selection if there's only one OrgUnit
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml


--
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-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java	2012-04-10 06:49:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java	2012-07-18 04:43:02 +0000
@@ -41,7 +41,7 @@
 public class GetBeneficiaryRegistrationOrganisationUnitAction
     implements Action
 {
-
+    public static final String REDIRECT = "redirect";
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -63,6 +63,20 @@
     {
         return organisationUnits;
     }
+    
+    private Integer orgUnitId;
+    
+    public Integer getOrgUnitId()
+    {
+        return orgUnitId;
+    }
+
+    public void setOrgUnitId( Integer orgUnitId )
+    {
+        this.orgUnitId = orgUnitId;
+    }
+
+
 
     @Override
     public String execute()
@@ -74,6 +88,11 @@
         {
             organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
             Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE );
+            if ( organisationUnits.size() == 1 )
+            {
+                orgUnitId = organisationUnits.get( 0 ).getId();
+                return REDIRECT;
+            }
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java	2012-04-10 06:49:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java	2012-07-18 04:43:02 +0000
@@ -40,7 +40,8 @@
 public class GetNamebasedOrganisationUnitsAction
     implements Action
 {
-
+    public static final String REDIRECT = "redirect";
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -62,6 +63,21 @@
     {
         return organisationUnits;
     }
+    
+    private Integer orgUnitId;
+    
+    public Integer getOrgUnitId()
+    {
+        return orgUnitId;
+    }
+
+
+    public void setOrgUnitId( Integer orgUnitId )
+    {
+        this.orgUnitId = orgUnitId;
+    }
+
+
 
     @Override
     public String execute()
@@ -73,6 +89,11 @@
         {
             organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
             Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE );
+            
+            if (organisationUnits.size() == 1) {
+                orgUnitId = organisationUnits.get( 0 ).getId();
+                return REDIRECT;
+            }
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-07-15 08:11:32 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-07-18 04:43:02 +0000
@@ -79,6 +79,7 @@
     </action>
     <action name="selectNamebasedOrganisationUnit"
         class="org.hisp.dhis.light.namebaseddataentry.action.GetNamebasedOrganisationUnitsAction">
+		<result name="redirect" type="redirect">/light/selectActivityType.action?orgUnitId=${orgUnitId}</result>
       <result name="success" type="velocity">/dhis-web-light/main.vm</result>
       <param name="page">/dhis-web-light/namebased/selectNamebasedOrganisationUnits.vm</param>
     </action>
@@ -209,6 +210,7 @@
 
     <action name="selectRegistrationOrganisationUnit"
         class="org.hisp.dhis.light.beneficiaryregistration.action.GetBeneficiaryRegistrationOrganisationUnitAction">
+	  <result name="redirect" type="redirect">/light/registerBeneficiary.action?orgUnitId=${orgUnitId}</result>	
       <result name="success" type="velocity">/dhis-web-light/main.vm</result>
       <param name="page">/dhis-web-light/registration/selectRegistrationOrganisationUnits.vm</param>
     </action>