← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21154: minor fix, checking F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS didnt work in advanced search

 

------------------------------------------------------------
revno: 21154
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-11-22 19:47:25 +0100
message:
  minor fix, checking F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS didnt work in advanced search
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.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-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-11-21 11:27:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-11-22 18:47:25 +0000
@@ -442,22 +442,24 @@
             return orgUnitPromise;
         },    
         getSearchTreeRoot: function(){
-            if(!rootOrgUnitPromise){
-                
-                var url = '../api/me.json?fields=organisationUnits[id,name,children[id,name,children[id,name]]]&paging=false';
-                
-                if( roles && roles.userCredentials && roles.userCredentials.userRoles && roles.userCredentials.userRoles.authorities ){
-                    if( roles.userCredentials.userRoles.authorities.indexOf('ALL') !== -1 || 
-                            roles.userCredentials.userRoles.authorities.indexOf('F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS') !== -1 ){                        
-                        url = '../api/organisationUnits.json?filter=level:eq:1&fields=id,name,children[id,name,children[id,name]]&paging=false';                        
-                    }
-                }                
-                rootOrgUnitPromise = $http.get( url ).then(function(response){
-                    return response.data;
-                });
-            }
-            return rootOrgUnitPromise;
-        }
+           if(!rootOrgUnitPromise){
+               var url = '../api/me.json?fields=organisationUnits[id,name,children[id,name,children[id,name]]]&paging=false';
+               if( roles && roles.userCredentials && roles.userCredentials.userRoles){
+                   var userRoles = roles.userCredentials.userRoles;
+                   for(var i=0; i<userRoles.length; i++){
+                       if(userRoles[i].authorities.indexOf('ALL') !== -1 || 
+                         userRoles[i].authorities.indexOf('F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS') !== -1 ){                        
+                         url = '../api/organisationUnits.json?filter=level:eq:1&fields=id,name,children[id,name,children[id,name]]&paging=false';
+                         i=userRoles.length;
+                       }
+                   }  
+               }             
+               rootOrgUnitPromise = $http.get( url ).then(function(response){
+                   return response.data;
+               });
+           }
+           return rootOrgUnitPromise;
+       }
     }; 
 })