dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32927
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16741: tracker capture - improved overdue event report with paging
------------------------------------------------------------
revno: 16741
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-09-17 16:54:25 +0200
message:
tracker capture - improved overdue event report with paging
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js
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/scripts/directives.js
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/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-09-08 09:08:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-09-17 14:54:25 +0000
@@ -85,16 +85,17 @@
class="form-control"
ng-class="{'input-success': eventDateSaved}"
ng-date
- ng-model="currentEvent.eventDate"
+ ng-model="currentEvent.eventDate"
+ ng-disabled="currentEvent.status === 'SKIPPED'"
ng-required="true"
blur-or-change="saveEventDate()"/>
<span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>
</div>
<div class="col-md-6">
- <span ng-if="currentEvent.eventDate">
+ <span ng-if="currentEvent.eventDate || currentEvent.status === 'SKIPPED'">
{{'due_date'| translate}}
</span>
- <span ng-if="!currentEvent.eventDate">
+ <span ng-if="!currentEvent.eventDate && currentEvent.status !== 'SKIPPED'">
<a href ng-click="enableRescheduling()" title="{{ schedulingEnabled ? 'disable_rescheduling' : 'enable_rescheduling' | translate}}"><span class="text-primary bold">{{'due_date'| translate}}</span></a>
</span>
<input type="text"
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-09-09 12:06:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-09-17 14:54:25 +0000
@@ -171,7 +171,7 @@
//enrollment has failed
var dialogOptions = {
headerText: 'enrollment_error',
- bodyText: data.description
+ bodyText: enrollmentResponse.description
};
DialogService.showDialog({}, dialogOptions);
return;
=== 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 2014-09-11 12:35:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2014-09-17 14:54:25 +0000
@@ -5,12 +5,12 @@
$translate,
orderByFilter,
DateUtils,
- TEIService,
+ Paginator,
+ EventReportService,
TEIGridService,
TranslationService,
AttributesFactory,
ProgramFactory,
- DHIS2EventFactory,
storage) {
TranslationService.translate();
@@ -22,6 +22,9 @@
$scope.displayMode = {};
$scope.printMode = false;
+ //Paging
+ $scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};
+
//watch for selection of org unit from tree
$scope.$watch('selectedOrgUnit', function() {
$scope.reportFinished = false;
@@ -67,6 +70,7 @@
$scope.reportFinished = false;
$scope.reportStarted = false;
if (angular.isObject($scope.selectedProgram)){
+ $scope.generateGridHeader();
$scope.generateReport();
}
});
@@ -76,6 +80,7 @@
$scope.reportFinished = false;
$scope.reportStarted = false;
if (angular.isObject($scope.selectedProgram)){
+ $scope.generateGridHeader();
$scope.generateReport();
}
});
@@ -85,7 +90,55 @@
if($scope.selectedProgram && $scope.selectedOuMode){
$scope.reportFinished = false;
- $scope.reportStarted = true;
+ $scope.reportStarted = true;
+ $scope.overdueEvents = [];
+ EventReportService.getOverdueEvents($scope.selectedOrgUnit.id, $scope.selectedOuMode, $scope.selectedProgram.id, 'OVERDUE', $scope.pager).then(function(data){
+
+ if( data.pager ){
+ $scope.pager = data.pager;
+ $scope.pager.toolBarDisplay = 5;
+
+ Paginator.setPage($scope.pager.page);
+ Paginator.setPageCount($scope.pager.pageCount);
+ Paginator.setPageSize($scope.pager.pageSize);
+ Paginator.setItemCount($scope.pager.total);
+ }
+
+ angular.forEach(data.eventRows, function(row){
+ var overdueEvent = {};
+ angular.forEach(row.attributes, function(att){
+ overdueEvent[att.attribute] = att.value;
+ });
+
+ overdueEvent.dueDate = DateUtils.format(row.dueDate);
+ overdueEvent.event = row.event;
+ overdueEvent.eventName = row.eventName;
+ overdueEvent.followup = row.followup;
+ overdueEvent.program = row.program;
+ overdueEvent.programStage = row.programStage;
+ overdueEvent.trackedEntityInstance = row.trackedEntityInstance;
+ overdueEvent.orgUnitName = row.registrationOrgUnit;
+ overdueEvent.created = DateUtils.format(row.registrationDate);;
+ $scope.overdueEvents.push(overdueEvent);
+
+ });
+
+ //sort overdue events by their due dates - this is default
+ $scope.overdueEvents = orderByFilter($scope.overdueEvents, '-dueDate');
+ $scope.overdueEvents.reverse();
+
+ $scope.reportFinished = true;
+ $scope.reportStarted = false;
+
+ console.log('The data is: ', $scope.overdueEvents);
+ });
+ }
+ };
+
+ $scope.generateGridHeader = function(){
+
+ if (angular.isObject($scope.selectedProgram)){
+
$scope.programStages = [];
$scope.filterTypes = {};
$scope.filterText = {};
@@ -102,48 +155,10 @@
$scope.gridColumns.push({name: $translate('due_date'), id: 'dueDate', type: 'date', displayInListNoProgram: false, showFilter: false, show: true});
$scope.filterTypes['dueDate'] = 'date';
$scope.filterText['dueDate']= {};
- });
-
- //fetch TEIs for the selected program and orgunit/mode
- TEIService.search($scope.selectedOrgUnit.id,
- $scope.selectedOuMode,
- null,
- 'program=' + $scope.selectedProgram.id,
- null,
- $scope.pager,
- false).then(function(data){
-
- //process tei grid
- var teis = TEIGridService.format(data,true);
- $scope.overdueEvents = [];
- DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedOuMode, $scope.selectedProgram.id, null, null).then(function(eventList){
-
- angular.forEach(eventList, function(ev){
- if(ev.dueDate){
- ev.dueDate = DateUtils.format(ev.dueDate);
- if( ev.trackedEntityInstance &&
- !ev.eventDate &&
- ev.dueDate < $scope.today){
-
- var overDue = {};
- angular.copy(teis.rows[ev.trackedEntityInstance],overDue);
- angular.extend(overDue,{eventName: $scope.programStages[ev.programStage].name, dueDate: ev.dueDate, followup: ev.followup});
-
- $scope.overdueEvents.push(overDue);
- }
- }
- });
-
- //sort overdue events by their due dates - this is default
- $scope.overdueEvents = orderByFilter($scope.overdueEvents, '-dueDate');
- $scope.overdueEvents.reverse();
-
- $scope.reportFinished = true;
- $scope.reportStarted = false;
- });
});
- }
- };
+
+ }
+ };
$scope.showHideColumns = function(){
@@ -214,7 +229,7 @@
};
$scope.showDashboard = function(tei){
- $location.path('/dashboard').search({tei: tei.id,
+ $location.path('/dashboard').search({tei: tei,
program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
};
@@ -225,4 +240,18 @@
$scope.generateReportHeader = function(){
return TEIGridService.getHeader($scope.gridColumns);
};
+
+ $scope.jumpToPage = function(){
+ $scope.generateReport();
+ };
+
+ $scope.resetPageSize = function(){
+ $scope.pager.page = 1;
+ $scope.generateReport();
+ };
+
+ $scope.getPage = function(page){
+ $scope.pager.page = page;
+ $scope.generateReport();
+ };
});
\ No newline at end of file
=== 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 2014-09-11 12:35:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events.html 2014-09-17 14:54:25 +0000
@@ -118,11 +118,6 @@
onclick="javascript:window.print()">
{{'print'| translate}}
</button>
- <!--<button type="button"
- class="btn btn-success small-horizonal-spacing"
- ng-click="exportToExcel()">
- {{'excel_export'| translate}}
- </button>-->
<button type="button"
class="btn btn-success small-horizonal-spacing"
ng-csv="generateReportData()"
@@ -148,10 +143,10 @@
<!-- filter icon begins -->
<span class='pull-right not-printable'>
<span ng-show="gridColumn.type != 'date' && gridColumn.type != 'int'">
- <a href ng-click="searchInGrid(gridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter - without - content', false: 'filter - with - content'} [filterText[gridColumn.id] == undefined || filterText[gridColumn.id] == '']"><i class="fa fa-search"></i></span></a>
+ <a href ng-click="searchInGrid(gridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [filterText[gridColumn.id] == undefined || filterText[gridColumn.id] == '']"><i class="fa fa-search"></i></span></a>
</span>
<span ng-show="gridColumn.type === 'date' || gridColumn.type === 'int'">
- <a href ng-click="searchInGrid(gridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter - without - content', false: 'filter - with - content'} [(filterText[gridColumn.id].start == undefined || filterText[gridColumn.id].start == '') && (filterText[gridColumn.id].end == undefined || filterText[gridColumn.id].end == '')]"><i class="fa fa-search"></i></span></a>
+ <a href ng-click="searchInGrid(gridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [(filterText[gridColumn.id].start == undefined || filterText[gridColumn.id].start == '') && (filterText[gridColumn.id].end == undefined || filterText[gridColumn.id].end == '')]"><i class="fa fa-search"></i></span></a>
</span>
</span>
<!-- filter icon ends -->
@@ -185,7 +180,7 @@
</thead>
<tbody id="list">
<tr ng-repeat="overdueEvent in overdueEvents | orderBy:sortHeader:reverse | gridFilter:filterText:filterTypes"
- ng-click="showDashboard(overdueEvent)"
+ ng-click="showDashboard(overdueEvent.trackedEntityInstance)"
title="{{'go_to_dashboard'| translate}}">
<td ng-show="gridColumn.show"
ng-repeat="gridColumn in gridColumns" ng-if='displayMode.onlyMarkedFollowup ? overdueEvent.followup:true'>
@@ -194,6 +189,7 @@
</tr>
</tbody>
</table>
+ <serverside-paginator></serverside-paginator>
</div>
<!-- report ends -->
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-09-11 12:35:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-09-17 14:54:25 +0000
@@ -194,7 +194,7 @@
changeYear: true,
changeMonth: true,
dateFormat: 'yy-mm-dd',
- yearRange: '-120:+0',
+ yearRange: '-120:+30',
minDate: attrs.minDate,
maxDate: attrs.maxDate,
onSelect: function(date) {
=== 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 2014-09-11 12:35:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-09-17 14:54:25 +0000
@@ -591,6 +591,30 @@
};
})
+/* factory for handling event reports */
+.factory('EventReportService', function($http, $q) {
+
+ return {
+
+ getOverdueEvents: function(orgUnit, ouMode, program, status, pager){
+ var pgSize = pager ? pager.pageSize : 50;
+ var pg = pager ? pager.page : 1;
+ var promise = $http.get( '../api/events/overdue.json?' + 'orgUnit=' + orgUnit + '&ouMode='+ ouMode + '&program=' + program + '&status=' + status + '&pageSize=' + pgSize + '&page=' + pg ).then(function(response){
+ return response.data;
+ });
+ return promise;
+ },
+ getUpcomingEvents: function(orgUnit, ouMode, program, startDate, endDate, status, pager){
+ var pgSize = pager ? pager.pageSize : 50;
+ var pg = pager ? pager.page : 1;
+ var promise = $http.get( '../api/events/overdue.json?' + 'orgUnit=' + orgUnit + '&ouMode='+ ouMode + '&program=' + program + '&startDate=' + startDate + '&endDate=' + endDate + '&status=' + status + '&pageSize=' + pgSize + '&page=' + pg ).then(function(response){
+ return response.data;
+ });
+ return promise;
+ }
+ };
+})
+
.factory('OperatorFactory', function(){
var defaultOperators = ['IS', 'RANGE' ];