← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8869: mobile: minor bugfixes

 

------------------------------------------------------------
revno: 8869
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-11-05 11:43:15 +0100
message:
  mobile: minor bugfixes
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java
  dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache
  dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.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
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java	2012-10-31 18:08:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java	2012-11-05 10:43:15 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.api.webdomain.user.Recipients;
 import org.hisp.dhis.api.webdomain.user.UserAccount;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationService;
@@ -90,6 +91,9 @@
     private OrganisationUnitService organisationUnitService;
 
     @Autowired
+    private DataSetService dataSetService;
+
+    @Autowired
     private ContextUtils contextUtils;
 
     @RequestMapping( produces = {"application/json", "text/*"} )
@@ -240,9 +244,24 @@
         Forms forms = new Forms();
 
         Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
-        Set<DataSet> userDataSets = currentUser.getUserCredentials().getAllDataSets();
-
-        for ( OrganisationUnit ou : currentUser.getOrganisationUnits() )
+        Set<DataSet> userDataSets = null;
+        Set<OrganisationUnit> userOrganisationUnits = new HashSet<OrganisationUnit>( currentUser.getOrganisationUnits() );
+
+        if ( currentUser.getUserCredentials().getAllAuthorities().contains( "ALL" ) )
+        {
+            userDataSets = new HashSet<DataSet>( dataSetService.getAllDataSets() );
+
+            if ( userOrganisationUnits.isEmpty() )
+            {
+                userOrganisationUnits = new HashSet<OrganisationUnit>( organisationUnitService.getRootOrganisationUnits() );
+            }
+        }
+        else
+        {
+            userDataSets = currentUser.getUserCredentials().getAllDataSets();
+        }
+
+        for ( OrganisationUnit ou : userOrganisationUnits )
         {
             Set<DataSet> dataSets = new HashSet<DataSet>( CollectionUtils.intersection( ou.getDataSets(), userDataSets ) );
 

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache	2012-11-04 13:18:18 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache	2012-11-05 10:43:15 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# Version: 24
+# Version: 26
 
 CACHE:
 ../mobile/index

=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js	2012-10-31 18:22:26 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js	2012-11-05 10:43:15 +0000
@@ -39,6 +39,10 @@
         url      : '../api/currentUser/forms',
         dataType : 'json'
     }).success(function ( data ) {
+        // clear out old localStorage, some phones doesn't like it when you overwrite old keys
+        delete localStorage['organisationUnits'];
+        delete localStorage['forms'];
+
         if( data.organisationUnits ) {
             localStorage['organisationUnits'] = JSON.stringify(data.organisationUnits);
         } else {