← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17913: bugfix for ouwt, clear out selected when version/user is changed

 

------------------------------------------------------------
revno: 17913
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-01-08 17:24:18 +0700
message:
  bugfix for ouwt, clear out selected when version/user is changed
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTreePartial.vm
  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/commons/action/GetOrganisationUnitTreeAction.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/ajax/jsonOrganisationUnitTreePartial.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTreePartial.vm	2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTreePartial.vm	2015-01-08 10:24:18 +0000
@@ -1,6 +1,7 @@
 {
 "version":"$!encoder.jsonEncode( $version )"
 ,"username":"$!encoder.jsonEncode( $username )"
+,"roots": [ #foreach( $root in $rootOrganisationUnits )"$!encoder.jsonEncode($root.uid)"#if( $velocityCount < $rootOrganisationUnits.size() ),#end#end ]
 ,"organisationUnits": {
 #foreach( $unit in $organisationUnits )
 "$!encoder.jsonEncode($unit.uid)":{"id":"$!encoder.jsonEncode($unit.uid)","n":"$!encoder.jsonEncode( ${unit.name} )",#if( $unit.parent )"pid":"$!encoder.jsonEncode($unit.parent.uid)",#end"c":[#foreach( $child in $unit.sortedChildren )"$!encoder.jsonEncode($child.uid)"#if( $velocityCount < $unit.children.size() ),#end#end]}

=== 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	2014-11-20 06:13:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2015-01-08 10:24:18 +0000
@@ -382,6 +382,8 @@
                     selection.setVersion( data.version );
                     selection.setUsername( data.username );
 
+                    selection.clearSelected();
+
                     selection.clearOrganisationUnits().always(function() {
                       selection.setOrganisationUnits( data.organisationUnits ).done(function() {
                           sync_and_reload();

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java	2014-11-20 06:13:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java	2015-01-08 10:24:18 +0000
@@ -174,6 +174,21 @@
 
         username = currentUserService.getCurrentUsername();
 
+        Collection<OrganisationUnit> userOrganisationUnits = new ArrayList<>();
+
+        User user = currentUserService.getCurrentUser();
+
+        if ( user != null && user.hasOrganisationUnit() )
+        {
+            userOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
+            rootOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
+        }
+        else if ( currentUserService.currentUserIsSuper() || user == null )
+        {
+            userOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
+            rootOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
+        }
+
         if ( byName != null )
         {
             List<OrganisationUnit> organisationUnitByName = organisationUnitService.getOrganisationUnitByName( byName );
@@ -229,21 +244,6 @@
             return "partial";
         }
 
-        Collection<OrganisationUnit> userOrganisationUnits = new ArrayList<>();
-
-        User user = currentUserService.getCurrentUser();
-
-        if ( user != null && user.hasOrganisationUnit() )
-        {
-            userOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
-            rootOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
-        }
-        else if ( currentUserService.currentUserIsSuper() || user == null )
-        {
-            userOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
-            rootOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
-        }
-
         if ( !versionOnly && !rootOrganisationUnits.isEmpty() )
         {
             OrganisationUnitLevel offlineOrgUnitLevel = offlineLevel != null ? new OrganisationUnitLevel( offlineLevel, "<no-name>" )