=== 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-12-03 14:08:06 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-12-03 16:03:04 +0000 @@ -30,6 +30,8 @@ $scope.maxOptionSize = 30; $scope.model = {}; + $scope.trackerCapture = {displayMode: 'SEARCH'}; + //Selection $scope.ouModes = [{name: 'SELECTED'}, {name: 'CHILDREN'}, {name: 'DESCENDANTS'}, {name: 'ACCESSIBLE'}]; $scope.selectedOuMode = $scope.ouModes[0]; @@ -38,18 +40,11 @@ $scope.treeLoaded = false; $scope.searchOuTree = false; $scope.teiListMode = {onlyActive: false}; - $scope.enrollmentStatus = 'ALL'; - - //Paging - $scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5}; - - //EntityList - $scope.showTrackedEntityDiv = false; - + $scope.enrollmentStatus = 'ALL'; + //Searching $scope.showSearchDiv = false; $scope.searchText = null; - $scope.emptySearchText = false; $scope.searchFilterExists = false; $scope.defaultOperators = OperatorFactory.defaultOperators; $scope.boolOperators = OperatorFactory.boolOperators; @@ -57,10 +52,21 @@ $scope.searchMode = { listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED' }; $scope.optionSets = null; $scope.attributesById = null; - $scope.doSearch = true; - - //Registration - $scope.showRegistrationDiv = false; + $scope.doSearch = true; + + function resetParams(){ + $scope.trackedEntityList = null; + $scope.sortColumn = {}; + $scope.emptySearchText = false; + $scope.emptySearchAttribute = false; + $scope.showRegistrationDiv = false; + $scope.showTrackedEntityDiv = false; + $scope.teiFetched = false; + $scope.queryUrl = null; + $scope.programUrl = null; + $scope.attributeUrl = {url: null, hasValue: false}; + $scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5}; + } //watch for selection of org unit from tree $scope.$watch('selectedOrgUnit', function() { @@ -119,6 +125,7 @@ $scope.settingsLabel = $translate.instant('settings'); $scope.displayModeLabel = $translate.instant('display_mode'); + resetParams(); $scope.loadPrograms($scope.selectedOrgUnit); } }); @@ -162,6 +169,7 @@ }; $scope.getProgramAttributes = function(program){ + resetParams(); $scope.selectedProgram = program; $scope.trackedEntityList = null; $scope.processAttributes(); @@ -175,7 +183,7 @@ $scope.doSearch = false; } - if($scope.doSearch){ + if($scope.doSearch && $scope.trackerCapture.displayMode === 'LIST'){ $scope.search($scope.searchMode); } }); @@ -205,21 +213,12 @@ }; //$scope.searchParam = {bools: []}; - $scope.search = function(mode){ + $scope.search = function(mode){ + resetParams() var grid = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name); $scope.gridColumns = grid.columns; - $scope.selectedSearchMode = mode; - $scope.emptySearchText = false; - $scope.emptySearchAttribute = false; - $scope.showRegistrationDiv = false; - $scope.showTrackedEntityDiv = false; - $scope.teiFetched = false; - $scope.trackedEntityList = null; - - $scope.queryUrl = null; - $scope.programUrl = null; - $scope.attributeUrl = {url: null, hasValue: false}; + $scope.selectedSearchMode = mode; if($scope.selectedProgram){ $scope.programUrl = 'program=' + $scope.selectedProgram.id; @@ -228,10 +227,13 @@ //check search mode if( $scope.selectedSearchMode === $scope.searchMode.freeText ){ - if( $scope.searchText ){ - $scope.queryUrl = 'query=LIKE:' + $scope.searchText; - } - + if(!$scope.searchText){ + $scope.emptySearchText = true; + $scope.teiFetched = false; + return; + } + + $scope.queryUrl = 'query=LIKE:' + $scope.searchText; $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment); $scope.searchingOrgUnit = $scope.selectedOrgUnit; } @@ -320,8 +322,7 @@ }; $scope.showRegistration = function(){ - $scope.showRegistrationDiv = !$scope.showRegistrationDiv; - + $scope.showRegistrationDiv = !$scope.showRegistrationDiv; if($scope.showRegistrationDiv){ $scope.showTrackedEntityDiv = false; $scope.showSearchDiv = false; @@ -329,15 +330,6 @@ $rootScope.$broadcast('registrationWidget', {registrationMode: 'REGISTRATION'}); }, 200); } - else{ - $scope.doSearch = true; - if(!$scope.trackedEntityList){ - if($scope.doSearch){ - $scope.search($scope.searchMode); - } - } - $scope.showTrackedEntityDiv = true; - } }; $scope.showDisplayMode = function(){ === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2015-12-03 14:08:06 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2015-12-03 16:03:04 +0000 @@ -123,6 +123,7 @@