← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21948: tracker-capture: by default select the first program in TEI search page

 

------------------------------------------------------------
revno: 21948
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-02-11 14:25:22 +0100
message:
  tracker-capture: by default select the first program in TEI search page
modified:
  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/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html


--
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/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2016-01-15 13:45:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2016-02-11 13:25:22 +0000
@@ -27,7 +27,7 @@
                 TEIGridService,
                 TEIService,
                 EventReportService,
-                ModalService,$q) {  
+                $q) {  
     $scope.maxOptionSize = 30;
     $scope.eventsTodayFilters = [{name: $translate.instant('events_today_all'), value: 'all'},{name: $translate.instant('events_today_completeoractive'),value: 'completedOrActive', status:['COMPLETED', 'ACTIVE']},{name: $translate.instant('events_today_skipped') , value: 'skipped', status:['SKIPPED']},{name: $translate.instant('events_today_scheduled'), value: 'scheduled', status:['SCHEDULE']}];
     $scope.selectedEventsTodayFilter = $scope.eventsTodayFilters[0];

=== 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	2016-02-04 10:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-02-11 13:25:22 +0000
@@ -243,7 +243,7 @@
 })
 
 /* Factory to fetch programs */
-.factory('ProgramFactory', function($q, $rootScope, SessionStorageService, TCStorageService) { 
+.factory('ProgramFactory', function($q, $rootScope, SessionStorageService, TCStorageService, orderByFilter) { 
     
     var userHasValidRole = function(program, userRoles){
         
@@ -304,6 +304,8 @@
                         }
                     });
                     
+                    programs = orderByFilter(programs, '-name').reverse();
+                    
                     if(programs.length === 0){
                         selectedProgram = null;
                     }
@@ -324,6 +326,10 @@
                             }
                         }
                     }
+                                        
+                    if(!selectedProgram && programs.legth > 0){
+                        selectedProgram = programs[0];
+                    }
                     
                     $rootScope.$apply(function(){
                         def.resolve({programs: programs, selectedProgram: selectedProgram});
@@ -360,6 +366,8 @@
                         }
                     });
                     
+                    programs = orderByFilter(programs, '-name').reverse();
+                    
                     if(programs.length === 0){
                         selectedProgram = null;
                     }
@@ -380,6 +388,10 @@
                             }
                         }
                     }
+                                        
+                    if(!selectedProgram || angular.isUndefined(selectedProgram) && programs.legth > 0){
+                        selectedProgram = programs[0];
+                    }
                     
                     $rootScope.$apply(function(){
                         def.resolve({programs: programs, selectedProgram: selectedProgram});

=== 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	2016-01-14 13:41:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2016-02-11 13:25:22 +0000
@@ -68,7 +68,7 @@
                         on-select="getProgramAttributes(model.selectedProgram)"
                         style="width:100%;">
                     <ui-select-match allow-clear="true" class="form-control-ui-select" placeholder="{{'select_or_search' | translate}}">{{$select.selected.name  || $select.selected}}</ui-select-match>
-                    <ui-select-choices  repeat="program in programs | orderBy: 'name' | filter: $select.search | limitTo:maxOptionSize">
+                    <ui-select-choices  repeat="program in programs | filter: $select.search | limitTo:maxOptionSize">
                         <span ng-bind-html="program.name | highlight: $select.search"></span>
                     </ui-select-choices>
                 </ui-select>