=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-04-08 07:46:59 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-04-15 11:15:07 +0000 @@ -211,7 +211,7 @@ $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributes, $scope.enrollment); - if(!$scope.attributeUrl.hasValue && !$scope.selectedProgram){ + if(!$scope.attributeUrl.hasValue){ $scope.emptySearchAttribute = true; $scope.teiFetched = false; $scope.teiCount = null; @@ -369,7 +369,7 @@ }; //Get orgunits for the logged in user - OrgUnitFactory.getRoot().then(function(response) { + OrgUnitFactory.getSearchTreeRoot().then(function(response) { $scope.orgUnits = response.organisationUnits; $scope.selectedSearchingOrgUnit = $scope.orgUnits && $scope.orgUnits.length && $scope.orgUnits[0] ? $scope.orgUnits[0] : null; angular.forEach($scope.orgUnits, function(ou){ === 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-03-30 13:21:20 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-04-15 11:15:07 +0000 @@ -433,8 +433,9 @@ }) /* Factory for fetching OrgUnit */ -.factory('OrgUnitFactory', function($http) { - var orgUnit, orgUnitPromise, rootOrgUnitPromise, myOrgUnitsPromise; +.factory('OrgUnitFactory', function($http, SessionStorageService) { + var orgUnit, orgUnitPromise, rootOrgUnitPromise; + var roles = SessionStorageService.get('USER_ROLES'); return { get: function(uid){ if( orgUnit !== uid ){ @@ -444,28 +445,29 @@ }); } return orgUnitPromise; - }, - getRoot: function(){ + }, + getSearchTreeRoot: function(){ if(!rootOrgUnitPromise){ - rootOrgUnitPromise = $http.get( '../api/organisationUnits.json?filter=level:eq:1&fields=id,name,children[id,name,children[id,name]]&paging=false' ).then(function(response){ + + 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; - }, - getMine: function(){ - if(!myOrgUnitsPromise){ - myOrgUnitsPromise = $http.get('../api/me/organisationUnits').then(function(response){ - return response.data; - }); - } - return myOrgUnitsPromise; } }; }) /* service to deal with TEI registration and update */ -.service('RegistrationService', function(DialogService, TEIService, $q){ +.service('RegistrationService', function(TEIService, $q){ return { registerOrUpdate: function(tei, optionSets, attributesById){ if(tei){ === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html 2015-02-12 10:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html 2015-04-15 11:15:07 +0000 @@ -103,11 +103,7 @@ class="btn btn-primary" ng-click="search(searchMode.attributeBased)"> {{'search'| translate}} - - - + + + \ No newline at end of file