← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14708: Restricting data view org units on login

 

------------------------------------------------------------
revno: 14708
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-06 22:58:04 +0200
message:
  Restricting data view org units on login
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/action/RestrictOrganisationUnitsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm


--
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/src/main/java/org/hisp/dhis/security/action/RestrictOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/action/RestrictOrganisationUnitsAction.java	2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/action/RestrictOrganisationUnitsAction.java	2014-04-06 20:58:04 +0000
@@ -88,19 +88,24 @@
             Set<OrganisationUnit> dataCaptureOrgUnits = user.getOrganisationUnits();
             Set<OrganisationUnit> dataViewOrgUnits = user.getDataViewOrganisationUnits();
 
-            if ( dataCaptureOrgUnits.size() > 0 )
+            if ( !dataCaptureOrgUnits.isEmpty() )
             {
                 selectionManager.setRootOrganisationUnits( dataCaptureOrgUnits );
                 selectionManager.setSelectedOrganisationUnits( dataCaptureOrgUnits );
-                
+            }
+            else
+            {
+                selectionManager.resetRootOrganisationUnits();
+                selectionManager.clearSelectedOrganisationUnits();
+            }
+            
+            if ( !dataViewOrgUnits.isEmpty() )
+            {                
                 selectionTreeManager.setRootOrganisationUnits( dataViewOrgUnits );                
                 selectionTreeManager.setSelectedOrganisationUnits( dataViewOrgUnits );
             }
             else
-            {
-                selectionManager.resetRootOrganisationUnits();
-                selectionManager.clearSelectedOrganisationUnits();
-                
+            {                
                 selectionTreeManager.resetRootOrganisationUnits();                
                 selectionTreeManager.clearSelectedOrganisationUnits();
             }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java	2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java	2014-04-06 20:58:04 +0000
@@ -212,11 +212,19 @@
             {
                 selectionManager.setSelectedOrganisationUnits( user.getOrganisationUnits() );
             }
+            else
+            {
+                selectionManager.clearSelectedOrganisationUnits();
+            }
             
             if ( user.hasDataViewOrganisationUnit() )
             {
                 selectionTreeManager.setSelectedOrganisationUnits( user.getDataViewOrganisationUnits() );
             }
+            else
+            {
+                selectionTreeManager.clearSelectedOrganisationUnits();
+            }
             
             userCredentials = userService.getUserCredentials( userService.getUser( id ) );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm	2014-04-06 13:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm	2014-04-06 20:58:04 +0000
@@ -21,6 +21,10 @@
     checkValueIsExist("username", "validateUser.action");
     checkValueIsExist("openId", "validateUser.action");
 
+    selection.setMultipleSelectionAllowed( true );
+    selection.setUnselectAllowed( true );
+    selection.setAutoSelectRoot( false );
+
     jQuery("#cancel").click(function() {
       dhis2.commons.redirectCurrentPage('alluser.action');
     });

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm	2014-04-06 13:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm	2014-04-06 20:58:04 +0000
@@ -25,6 +25,11 @@
 
     checkValueIsExist("openId", "validateUser.action", { id: $userCredentials.id });
 
+    selection.clearSelected(); // Sync ouwt from server
+    selection.setMultipleSelectionAllowed( true );
+    selection.setUnselectAllowed( true );
+    selection.setAutoSelectRoot( false );
+
     jQuery("#cancel").click(function() {
       dhis2.commons.redirectCurrentPage('alluser.action');
     });