← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21424: OUWT. Using user org units as parents, no selected org unit

 

------------------------------------------------------------
revno: 21424
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-11 14:03:56 +0100
message:
  OUWT. Using user org units as parents, no selected org unit
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java


--
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/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2015-04-10 06:41:31 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2015-12-11 13:03:56 +0000
@@ -684,7 +684,6 @@
                         selection.setPartialOrganisationUnits( all ).done(function() {
                             $.extend( organisationUnits, data.organisationUnits );
                             selection.findByName();
-                            $( '#searchField' ).css( 'background-color', '#ffc5c5' );
                         });
                     });
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java	2015-09-09 08:59:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java	2015-12-11 13:03:56 +0000
@@ -29,14 +29,13 @@
  */
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitQueryParams;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
@@ -57,8 +56,8 @@
     private OrganisationUnitService organisationUnitService;
     
     @Autowired
-    private OrganisationUnitSelectionManager selectionManager;
-
+    private CurrentUserService currentUserService;
+    
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -91,11 +90,16 @@
     {
         term = term.toLowerCase();
 
-        Set<OrganisationUnit> parents = new HashSet<OrganisationUnit>( selectionManager.getSelectedOrganisationUnits() );
-        
+        User user = currentUserService.getCurrentUser();
+
         OrganisationUnitQueryParams params = new OrganisationUnitQueryParams();
+        
+        if ( user != null && user.hasOrganisationUnit() )
+        {
+            params.setParents( user.getOrganisationUnits() );
+        }        
+        
         params.setQuery( term );
-        params.setParents( parents );
         params.setMax( MAX );
         
         organisationUnits = organisationUnitService.getOrganisationUnitsByQuery( params );