← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21973: tracker-capture: use select2 for programs in reports

 

------------------------------------------------------------
revno: 21973
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-15 16:47:13 +0100
message:
  tracker-capture: use select2 for programs in reports
removed:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/reportForm.html
added:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/report-form.html
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html
  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/components/report/overdue-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js	2016-02-15 15:47:13 +0000
@@ -19,6 +19,9 @@
     $scope.report = {};
     $scope.displayMode = {};
     $scope.printMode = false;
+    $scope.maxOptionSize = 30;
+    $scope.model = {};
+    
     
     //get optionsets
     $scope.optionSets = CurrentSelection.getOptionSets();
@@ -60,18 +63,18 @@
     //load programs associated with the selected org unit.
     $scope.loadPrograms = function() {
         if (angular.isObject($scope.selectedOrgUnit)){
-            ProgramFactory.getAllForUser($scope.selectedProgram).then(function(response){
+            ProgramFactory.getAllForUser($scope.model.selectedProgram).then(function(response){
                 $scope.programs = response.programs;
-                $scope.selectedProgram = response.selectedProgram;
+                $scope.model.selectedProgram = response.selectedProgram;
             });
         }
     };
     
     //watch for selection of program
-    $scope.$watch('selectedProgram', function() {   
+    $scope.$watch('model.selectedProgram', function() {   
         $scope.reportFinished = false;
         $scope.reportStarted = false;        
-        if (angular.isObject($scope.selectedProgram)){
+        if (angular.isObject($scope.model.selectedProgram)){
             $scope.generateGridHeader();
             $scope.generateReport();
         }
@@ -81,7 +84,7 @@
     $scope.$watch('selectedOuMode', function() {   
         $scope.reportFinished = false;
         $scope.reportStarted = false;
-        if (angular.isObject($scope.selectedProgram)){
+        if (angular.isObject($scope.model.selectedProgram)){
             $scope.generateGridHeader();
             $scope.generateReport();
         }
@@ -89,13 +92,13 @@
     
     $scope.generateReport = function(){
         
-        if($scope.selectedProgram && $scope.selectedOuMode){
+        if($scope.model.selectedProgram && $scope.selectedOuMode){
             
             $scope.reportFinished = false;
             $scope.reportStarted = true;            
             $scope.overdueEvents = [];
             
-            EventReportService.getEventReport($scope.selectedOrgUnit.id, $scope.selectedOuMode, $scope.selectedProgram.id, null, null, 'ACTIVE','OVERDUE', $scope.pager).then(function(data){                
+            EventReportService.getEventReport($scope.selectedOrgUnit.id, $scope.selectedOuMode, $scope.model.selectedProgram.id, null, null, 'ACTIVE','OVERDUE', $scope.pager).then(function(data){                
                 if( data ) {
                     if( data.pager ){
                         $scope.pager = data.pager;
@@ -128,7 +131,7 @@
 
                     //sort overdue events by their due dates - this is default
                     if(!$scope.sortColumn.id){                                      
-                        $scope.sortGrid({id: 'dueDate', name: $translate.instant('due_date'), valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true});
+                        $scope.sortGrid({id: 'dueDate', displayName: $translate.instant('due_date'), valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true});
                         $scope.reverse = false;
                     }
                 }                
@@ -140,7 +143,7 @@
     
     $scope.generateGridHeader = function(){
         
-        if (angular.isObject($scope.selectedProgram)){
+        if (angular.isObject($scope.model.selectedProgram)){
             
             $scope.programStages = [];
             $scope.sortColumn = {};
@@ -148,15 +151,15 @@
             $scope.filterText = {};
             $scope.reverse = false;
 
-            angular.forEach($scope.selectedProgram.programStages, function(stage){
+            angular.forEach($scope.model.selectedProgram.programStages, function(stage){
                 $scope.programStages[stage.id] = stage;
             });
 
-            AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){            
+            AttributesFactory.getByProgram($scope.model.selectedProgram).then(function(atts){            
                 var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode,true);
                 $scope.gridColumns = [];
-                $scope.gridColumns.push({name: $translate.instant('due_date'), id: 'dueDate', valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
-                $scope.gridColumns.push({name: $translate.instant('event_name'), id: 'eventName', valueType: 'TEXT', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
+                $scope.gridColumns.push({displayName: $translate.instant('due_date'), id: 'dueDate', valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
+                $scope.gridColumns.push({displayName: $translate.instant('event_name'), id: 'eventName', valueType: 'TEXT', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
                 $scope.gridColumns = $scope.gridColumns.concat(grid.columns);
                 
                 $scope.filterTypes['eventName'] = 'TEXT';                
@@ -250,7 +253,7 @@
     
     $scope.showDashboard = function(tei){
         $location.path('/dashboard').search({tei: tei,                                            
-                                            program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
+                                            program: $scope.model.selectedProgram ? $scope.model.selectedProgram.id: null});
     };
     
     $scope.generateReportData = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html	2016-02-15 10:16:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html	2016-02-15 15:47:13 +0000
@@ -55,12 +55,13 @@
                             {{'program'| translate}}
                         </td>
                         <td>
-                            <select ng-model="selectedProgram"
-                                    class="form-control"
-                                    ng-options="program as program.displayName for program in programs | orderBy: 'displayName'" 
-                                    ng-disabled="programs.length < 1">
-                                <option value="">{{programs.length > 0 ? 'please_select_a_program' : 'no_program_exists'| translate}}</option>
-                            </select>
+                            <ui-select ng-model="model.selectedProgram" 
+                                    theme="select2" style="width:100%;">
+                                <ui-select-match allow-clear="true" class="form-control-ui-select" placeholder="{{'select_or_search' | translate}}">{{$select.selected.displayName  || $select.selected}}</ui-select-match>
+                                <ui-select-choices  repeat="program in programs | filter: $select.search | limitTo:maxOptionSize">
+                                    <span ng-bind-html="program.displayName | highlight: $select.search"></span>
+                                </ui-select-choices>
+                            </ui-select>
                         </td>
                     </tr>
                     <tr>
@@ -89,7 +90,7 @@
                 <div class="alert alert-warning">{{'no_program_exists_report'| translate}}</div> 
             </div>
         </div>
-        <div class="row" ng-if="programs.length > 0 && !selectedProgram">        
+        <div class="row" ng-if="programs.length > 0 && !model.selectedProgram">        
             <div class="col-sm-8 col-md-6 vertical-spacing">
                 <div class="alert alert-warning">{{'please_select_program_report'| translate}}</div> 
             </div>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js	2015-11-23 14:50:42 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js	2016-02-15 15:47:13 +0000
@@ -11,6 +11,8 @@
     $scope.ouModes = [{name: 'SELECTED'}, {name: 'CHILDREN'}, {name: 'DESCENDANTS'}, {name: 'ACCESSIBLE'}];         
     $scope.selectedOuMode = $scope.ouModes[0];
     $scope.report = {};
+    $scope.maxOptionSize = 30;
+    $scope.model = {};
     
     $scope.displayMode = {};
     $scope.printMode = false;
@@ -25,7 +27,7 @@
     //watch for selection of org unit from tree
     $scope.$watch('selectedOrgUnit', function() {      
         resetParams();
-        $scope.selectedProgram = null;
+        $scope.model.selectedProgram = null;
         if( angular.isObject($scope.selectedOrgUnit)){        
             $scope.loadPrograms($scope.selectedOrgUnit);
         }
@@ -35,16 +37,16 @@
     $scope.loadPrograms = function(orgUnit) {        
         $scope.selectedOrgUnit = orgUnit;        
         if (angular.isObject($scope.selectedOrgUnit)){
-            ProgramFactory.getProgramsByOu($scope.selectedOrgUnit, $scope.selectedProgram).then(function(response){
+            ProgramFactory.getProgramsByOu($scope.selectedOrgUnit, $scope.model.selectedProgram).then(function(response){
                 $scope.programs = response.programs;
-                $scope.selectedProgram = response.selectedProgram;
+                $scope.model.selectedProgram = response.selectedProgram;
             });
         }        
     };    
     
     //watch for selection of program
-    $scope.$watch('selectedProgram', function() {   
-        if( angular.isObject($scope.selectedProgram)){            
+    $scope.$watch('model.selectedProgram', function() {   
+        if( angular.isObject($scope.model.selectedProgram)){            
             resetParams();
         }
     });
@@ -63,13 +65,13 @@
 
     $scope.generateReport = function(program, report, ouMode){
         
-        $scope.selectedProgram = program;
+        $scope.model.selectedProgram = program;
         $scope.report = report;
         $scope.selectedOuMode = ouMode;
 
         //check for form validity
         $scope.outerForm.submitted = true;        
-        if( $scope.outerForm.$invalid || !$scope.selectedProgram){
+        if( $scope.outerForm.$invalid || !$scope.model.selectedProgram){
             return false;
         }
         
@@ -79,7 +81,7 @@
 
         $scope.enrollments = {active: 0, completed: 0, cancelled: 0};
         $scope.enrollmentList = [];
-        EnrollmentService.getByStartAndEndDate($scope.selectedProgram.id,
+        EnrollmentService.getByStartAndEndDate($scope.model.selectedProgram.id,
                                         $scope.selectedOrgUnit.id, 
                                         $scope.selectedOuMode.name,
                                         DateUtils.formatFromUserToApi($scope.report.startDate), 
@@ -104,7 +106,7 @@
                                         {key: 'Active', y: $scope.enrollments.active},
                                         {key: 'Cancelled', y: $scope.enrollments.cancelled}];
 
-                DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedOuMode.name, $scope.selectedProgram.id, null, null).then(function(data){
+                DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedOuMode.name, $scope.model.selectedProgram.id, null, null).then(function(data){
                     
                     if( data ) {
                         $scope.dhis2Events = {completed: 0, active: 0, skipped: 0, overdue: 0, ontime: 0};

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics.html	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics.html	2016-02-15 15:47:13 +0000
@@ -23,10 +23,10 @@
     
 </div>
 
-<div id="mainPage" class="bordered-div">
+<div id="mainPage" class="bordered-div page">
     <h2>{{'program_statistics_report'| translate}}</h2>
     <form name="outerForm" novalidate>               
-        <div ng-include="'components/report/reportForm.html'"></div>
+        <div ng-include="'components/report/report-form.html'"></div>
     </form>    
     <img src="../images/ajax-loader-bar.gif" ng-if="!dataReady && reportStarted"/>
     <div ng-if="dataReady">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js	2016-02-15 15:47:13 +0000
@@ -16,6 +16,8 @@
     $scope.ouModes = [{name: 'SELECTED'}, {name: 'CHILDREN'}, {name: 'DESCENDANTS'}, {name: 'ACCESSIBLE'}];         
     $scope.selectedOuMode = $scope.ouModes[0];
     $scope.report = {};
+    $scope.maxOptionSize = 30;
+    $scope.model = {};
     
     $scope.optionSets = CurrentSelection.getOptionSets();
     if(!$scope.optionSets){
@@ -30,7 +32,7 @@
     
     //watch for selection of org unit from tree
     $scope.$watch('selectedOrgUnit', function() {      
-        $scope.selectedProgram = null;
+        $scope.model.selectedProgram = null;
         $scope.reportStarted = false;
         $scope.dataReady = false;  
         $scope.programStages = null;
@@ -44,20 +46,20 @@
     $scope.loadPrograms = function(orgUnit) {        
         $scope.selectedOrgUnit = orgUnit;        
         if (angular.isObject($scope.selectedOrgUnit)){
-            ProgramFactory.getProgramsByOu($scope.selectedOrgUnit, $scope.selectedProgram).then(function(response){
+            ProgramFactory.getProgramsByOu($scope.selectedOrgUnit, $scope.model.selectedProgram).then(function(response){
                 $scope.programs = response.programs;
-                $scope.selectedProgram = response.selectedProgram;
+                $scope.model.selectedProgram = response.selectedProgram;
             });
         }        
     };
     
-    $scope.$watch('selectedProgram', function() {        
+    $scope.$watch('model.selectedProgram', function() {        
         $scope.programStages = null;
         $scope.stagesById = [];
-        if( angular.isObject($scope.selectedProgram)){            
+        if( angular.isObject($scope.model.selectedProgram)){            
             $scope.reportStarted = false;
             $scope.dataReady = false;            
-            ProgramStageFactory.getByProgram($scope.selectedProgram).then(function(stages){
+            ProgramStageFactory.getByProgram($scope.model.selectedProgram).then(function(stages){
                 $scope.programStages = stages;
                 $scope.stagesById = [];
                 angular.forEach(stages, function(stage){
@@ -69,27 +71,27 @@
     
     $scope.generateReport = function(program, report, ouMode){
         
-        $scope.selectedProgram = program;
+        $scope.model.selectedProgram = program;
         $scope.report = report;
         $scope.selectedOuMode = ouMode;
         
         //check for form validity
         $scope.outerForm.submitted = true;        
-        if( $scope.outerForm.$invalid || !$scope.selectedProgram){
+        if( $scope.outerForm.$invalid || !$scope.model.selectedProgram){
             return false;
         }
         
         $scope.reportStarted = true;
         $scope.dataReady = false;
             
-        AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){            
+        AttributesFactory.getByProgram($scope.model.selectedProgram).then(function(atts){            
             var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name,true);   
             $scope.gridColumns = grid.columns;
         });  
         
         EventReportService.getEventReport($scope.selectedOrgUnit.id, 
                                         $scope.selectedOuMode.name, 
-                                        $scope.selectedProgram.id, 
+                                        $scope.model.selectedProgram.id, 
                                         DateUtils.formatFromUserToApi($scope.report.startDate), 
                                         DateUtils.formatFromUserToApi($scope.report.endDate), 
                                         null,
@@ -102,7 +104,7 @@
                 angular.forEach(data.eventRows, function(ev){
                     if(ev.trackedEntityInstance){
                         ev.name = $scope.stagesById[ev.programStage].name;
-                        ev.programName = $scope.selectedProgram.displayName;
+                        ev.programName = $scope.model.selectedProgram.displayName;
                         ev.statusColor = EventUtils.getEventStatusColor(ev); 
                         ev.eventDate = DateUtils.formatFromApiToUser(ev.eventDate);
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html	2016-02-15 15:47:13 +0000
@@ -23,10 +23,10 @@
     
 </div>
 
-<div id="mainPage" class="bordered-div">
+<div id="mainPage" class="bordered-div page">
     <h2>{{'program_summary_report'| translate}}</h2>
     <form name="outerForm" novalidate>               
-        <div ng-include="'components/report/reportForm.html'"></div>
+        <div ng-include="'components/report/report-form.html'"></div>
     </form>    
     <img src="../images/ajax-loader-bar.gif" ng-if="!dataReady && reportStarted"/>
     <div ng-if="dataReady">

=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/report-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/report-form.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/report-form.html	2016-02-15 15:47:13 +0000
@@ -0,0 +1,78 @@
+<div class="row">
+    <div class="col-sm-8 col-md-6">
+        <table class="table table-borderless table-striped">
+            <tr>
+                <td>{{'org_unit' | translate}}</td>
+                <td>
+                    <input type="text" class="form-control" value="{{selectedOrgUnit.displayName|| 'please_select'| translate}}" ng-disabled="true">                                                                                        
+                </td>
+            </tr>
+            <tr>
+                <td class='col-sm-4 col-md-3 vertical-center'>
+                    {{'program'| translate}}
+                </td>
+                <td class='col-sm-4 col-md-3'>
+                    <ui-select ng-model="model.selectedProgram" 
+                            theme="select2" style="width:100%;">
+                        <ui-select-match allow-clear="true" class="form-control-ui-select" placeholder="{{'select_or_search' | translate}}">{{$select.selected.displayName  || $select.selected}}</ui-select-match>
+                        <ui-select-choices  repeat="program in programs | filter: $select.search | limitTo:maxOptionSize">
+                            <span ng-bind-html="program.displayName | highlight: $select.search"></span>
+                        </ui-select-choices>
+                    </ui-select>
+                </td>
+            </tr>            
+            <tr>
+                <td class='col-sm-4 col-md-3 vertical-center'>{{'org_unit_scope'| translate}}</td>
+                <td class='col-sm-4 col-md-3'>                 
+                    <label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
+                    <label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
+                    <label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
+                </td>
+            </tr>            
+        </table>
+    </div>
+</div>
+<div class="row">
+    <div class="col-sm-8 col-md-6">
+        <table class="table-borderless">
+            <tr>
+                <td>
+                    <input type="text" 
+                           name="reportStartDate" 
+                           placeholder="{{'start_date'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})" 
+                           class="form-control" 
+                           d2-date 
+                           ng-model="report.startDate" 
+                           max-date="0"
+                           ng-required="true"/> 
+                    <span ng-show="outerForm.submitted && outerForm.reportStartDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})</span>
+                </td>
+                <td>
+                    <input type="text" 
+                           name="reportEndDate" 
+                           placeholder="{{'end_date'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})" 
+                           class="form-control" 
+                           d2-date 
+                           ng-model="report.endDate" 
+                           max-date="0" 
+                           ng-required="true"/>
+                    <span ng-show="outerForm.submitted && outerForm.reportEndDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})</span>
+                </td>
+            </tr>
+        </table>                
+    </div>
+    <div class="col-md-6 trim">
+        <button type="button" class="btn btn-primary" ng-click="generateReport(model.selectedProgram, report, selectedOuMode)" ng-disabled="!model.selectedProgram">{{'go'| translate}}</button>               
+    </div>
+</div>
+
+<div class="row" ng-if="programs.length < 1">        
+    <div class="col-sm-8 col-md-6 vertical-spacing">
+        <div class="alert alert-warning">{{'no_program_exists_report'| translate}}</div> 
+    </div>
+</div>
+<div class="row" ng-if="programs.length > 0 && !model.selectedProgram">        
+    <div class="col-sm-8 col-md-6 vertical-spacing">
+        <div class="alert alert-warning">{{'please_select_program_report'| translate}}</div> 
+    </div>
+</div>
\ No newline at end of file

=== removed file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/reportForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/reportForm.html	2016-02-15 10:16:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/reportForm.html	1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
-<div class="row">
-    <div class="col-sm-8 col-md-6">
-        <table class="table table-borderless table-striped">
-            <tr>
-                <td>{{'org_unit' | translate}}</td>
-                <td>
-                    <input type="text" class="form-control" value="{{selectedOrgUnit.name|| 'please_select'| translate}}" ng-disabled="true">                                                                                        
-                </td>
-            </tr>            
-            <tr>
-                <td class='col-sm-4 col-md-3 vertical-center'>{{'org_unit_scope'| translate}}</td>
-                <td class='col-sm-4 col-md-3'>                 
-                    <label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
-                    <label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
-                    <label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
-                </td>
-            </tr>
-            <tr>
-                <td class='col-sm-4 col-md-3 vertical-center'>
-                    {{'program'| translate}}
-                </td>
-                <td class='col-sm-4 col-md-3'>
-                    <select ng-model="selectedProgram"
-                            class="form-control"
-                            ng-options="program as program.displayName for program in programs | orderBy: 'displayName'"
-                            ng-disabled="programs.length < 1">
-                        <option value="">{{programs.length > 0 ? 'please_select' : 'no_program_exists'| translate}}</option>
-                    </select>
-                </td>
-            </tr>
-        </table>
-    </div>
-</div>
-<div class="row">
-    <div class="col-sm-8 col-md-6">
-        <table class="table-borderless">
-            <tr>
-                <td>
-                    <input type="text" 
-                           name="reportStartDate" 
-                           placeholder="{{'start_date'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})" 
-                           class="form-control" 
-                           d2-date 
-                           ng-model="report.startDate" 
-                           max-date="0"
-                           ng-required="true"/> 
-                    <span ng-show="outerForm.submitted && outerForm.reportStartDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})</span>
-                </td>
-                <td>
-                    <input type="text" 
-                           name="reportEndDate" 
-                           placeholder="{{'end_date'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})" 
-                           class="form-control" 
-                           d2-date 
-                           ng-model="report.endDate" 
-                           max-date="0" 
-                           ng-required="true"/>
-                    <span ng-show="outerForm.submitted && outerForm.reportEndDate.$invalid" style="color:red;font-size:12px">{{'required'| translate}} ({{dhis2CalendarFormat.keyDateFormat}})</span>
-                </td>
-            </tr>
-        </table>                
-    </div>
-    <div class="col-md-6 trim">
-        <button type="button" class="btn btn-primary" ng-click="generateReport(selectedProgram, report, selectedOuMode)" ng-disabled="!selectedProgram">{{'go'| translate}}</button>               
-    </div>
-</div>
-
-<div class="row" ng-if="programs.length < 1">        
-    <div class="col-sm-8 col-md-6 vertical-spacing">
-        <div class="alert alert-warning">{{'no_program_exists_report'| translate}}</div> 
-    </div>
-</div>
-<div class="row" ng-if="programs.length > 0 && !selectedProgram">        
-    <div class="col-sm-8 col-md-6 vertical-spacing">
-        <div class="alert alert-warning">{{'please_select_program_report'| translate}}</div> 
-    </div>
-</div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js	2016-02-15 15:47:13 +0000
@@ -1,3 +1,5 @@
+/* global trackerCapture */
+
 trackerCapture.controller('UpcomingEventsController',
          function($scope,
                 $modal,
@@ -14,11 +16,12 @@
                 MetaDataFactory) {
     $scope.today = DateUtils.getToday();
     
+    $scope.maxOptionSize = 30;
     $scope.selectedOuMode = 'SELECTED';
     $scope.report = {};
     $scope.displayMode = {};
     $scope.printMode = false;
-    
+    $scope.model = {};
     //get optionsets
     $scope.optionSets = CurrentSelection.getOptionSets();
     if(!$scope.optionSets){
@@ -57,19 +60,19 @@
     //load programs associated with the selected org unit.
     $scope.loadPrograms = function() {
         if (angular.isObject($scope.selectedOrgUnit)){
-            ProgramFactory.getAllForUser($scope.selectedProgram).then(function(response){
+            ProgramFactory.getAllForUser($scope.model.selectedProgram).then(function(response){
                 $scope.programs = response.programs;
-                $scope.selectedProgram = response.selectedProgram;
+                $scope.model.selectedProgram = response.selectedProgram;
             });
         }        
     };
     
     //watch for selection of program
-    $scope.$watchCollection('[selectedProgram, selectedOuMode]', function () {
+    $scope.$watchCollection('[model.selectedProgram, selectedOuMode]', function () {
         $scope.reportFinished = false;
         $scope.reportStarted = false;
         
-        if (angular.isObject($scope.selectedProgram)){
+        if (angular.isObject($scope.model.selectedProgram)){
             $scope.generateGridHeader();
         }
     });
@@ -78,7 +81,7 @@
         
         //check for form validity
         $scope.outerForm.submitted = true;        
-        if( $scope.outerForm.$invalid || !$scope.selectedProgram){
+        if( $scope.outerForm.$invalid || !$scope.model.selectedProgram){
             return false;
         }
         
@@ -88,7 +91,7 @@
         $scope.upcomingEvents = [];
         EventReportService.getEventReport($scope.selectedOrgUnit.id, 
                                         $scope.selectedOuMode, 
-                                        $scope.selectedProgram.id, 
+                                        $scope.model.selectedProgram.id, 
                                         DateUtils.formatFromUserToApi($scope.report.startDate), 
                                         DateUtils.formatFromUserToApi($scope.report.endDate), 
                                         'ACTIVE',
@@ -127,7 +130,7 @@
 
                 //sort upcoming events by their due dates - this is default
                 if(!$scope.sortColumn.id){                                      
-                    $scope.sortGrid({id: 'dueDate', name: $translate.instant('due_date'), valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true});
+                    $scope.sortGrid({id: 'dueDate', displayName: $translate.instant('due_date'), valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true});
                     $scope.reverse = false;
                 }
             }
@@ -139,7 +142,7 @@
     
     $scope.generateGridHeader = function(){
         
-        if (angular.isObject($scope.selectedProgram)){
+        if (angular.isObject($scope.model.selectedProgram)){
             
             $scope.programStages = [];
             $scope.sortColumn = {};
@@ -147,17 +150,17 @@
             $scope.filterText = {};
             $scope.reverse = false;;
 
-            angular.forEach($scope.selectedProgram.programStages, function(stage){
+            angular.forEach($scope.model.selectedProgram.programStages, function(stage){
                 $scope.programStages[stage.id] = stage;
             });
 
             
-            AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){            
+            AttributesFactory.getByProgram($scope.model.selectedProgram).then(function(atts){            
                 var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode, true);
                 
                 $scope.gridColumns = [];
-                $scope.gridColumns.push({name: $translate.instant('due_date'), id: 'dueDate', valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
-                $scope.gridColumns.push({name: $translate.instant('event_name'), id: 'eventName', valueType: 'TEXT', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
+                $scope.gridColumns.push({displayName: $translate.instant('due_date'), id: 'dueDate', valueType: 'DATE', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
+                $scope.gridColumns.push({displayName: $translate.instant('event_name'), id: 'eventName', valueType: 'TEXT', displayInListNoProgram: false, showFilter: false, show: true, eventCol: true});
                 $scope.gridColumns = $scope.gridColumns.concat(grid.columns);
                 
                 $scope.filterTypes['eventName'] = 'TEXT';                
@@ -248,7 +251,7 @@
     
     $scope.showDashboard = function(tei){
         $location.path('/dashboard').search({tei: tei,                                            
-                                            program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
+                                            program: $scope.model.selectedProgram ? $scope.model.selectedProgram.id: null});
     };
     
     $scope.generateReportData = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html	2016-02-15 10:16:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events.html	2016-02-15 15:47:13 +0000
@@ -54,13 +54,14 @@
                         <td>
                             {{'program'| translate}}
                         </td>
-                        <td>
-                            <select ng-model="selectedProgram"
-                                    class="form-control"
-                                    ng-options="program as program.displayName for program in programs | orderBy: 'displayName'"
-                                    ng-disabled="programs.length < 1" ng-selected="programs.length === 1">
-                                <option ng-if="programs.length !== 1" value="">{{programs.length > 1 ? 'please_select_a_program' : 'no_program_exists'| translate}}</option>
-                            </select>
+                        <td>                          
+                            <ui-select ng-model="model.selectedProgram" 
+                                    theme="select2" style="width:100%;">
+                                <ui-select-match allow-clear="true" class="form-control-ui-select" placeholder="{{'select_or_search' | translate}}">{{$select.selected.displayName  || $select.selected}}</ui-select-match>
+                                <ui-select-choices  repeat="program in programs | filter: $select.search | limitTo:maxOptionSize">
+                                    <span ng-bind-html="program.displayName | highlight: $select.search"></span>
+                                </ui-select-choices>
+                            </ui-select>
                         </td>
                     </tr>
                     <tr>
@@ -127,7 +128,7 @@
                 </table>                
             </div>
             <div class="col-md-6 trim">
-                <button type="button" class="btn btn-primary" ng-click="generateReport()" ng-disabled="!selectedProgram">{{'go'| translate}}</button>
+                <button type="button" class="btn btn-primary" ng-click="generateReport()" ng-disabled="!model.selectedProgram">{{'go'| translate}}</button>
                 <button type="button"
                         class="btn btn-success small-horizonal-spacing"
                         ng-if="upcomingEvents.length > 0"
@@ -150,7 +151,7 @@
                 <div class="alert alert-warning">{{'no_program_exists_report'| translate}}</div> 
             </div>
         </div>
-        <div class="row" ng-if="programs.length > 0 && !selectedProgram">        
+        <div class="row" ng-if="programs.length > 0 && !model.selectedProgram">        
             <div class="col-sm-8 col-md-6 vertical-spacing">
                 <div class="alert alert-warning">{{'please_select_program_report'| translate}}</div> 
             </div>

=== 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-15 12:05:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-02-15 15:47:13 +0000
@@ -304,7 +304,7 @@
                         }
                     });
                     
-                    programs = orderByFilter(programs, '-name').reverse();
+                    programs = orderByFilter(programs, '-displayName').reverse();
                     
                     if(programs.length === 0){
                         selectedProgram = null;
@@ -326,8 +326,8 @@
                             }
                         }
                     }
-                                        
-                    if(!selectedProgram && programs.legth > 0){
+                        
+                    if(!selectedProgram || angular.isUndefined(selectedProgram) && programs.legth > 0){
                         selectedProgram = programs[0];
                     }