dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36278
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18583: tracker-capture: sort list of TEIs using attributes and previous/next tei browsing from TEI dashb...
------------------------------------------------------------
revno: 18583
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-03-11 16:02:58 +0100
message:
tracker-capture: sort list of TEIs using attributes and previous/next tei browsing from TEI dashboard. Note: this works only for current page.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-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/program-summary-controller.js
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/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/styles/style.css
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.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/components/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-09 15:56:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-11 15:02:58 +0000
@@ -21,6 +21,26 @@
$scope.selectedTeiId = ($location.search()).tei;
$scope.selectedProgramId = ($location.search()).program;
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
+
+ $scope.sortedTeiIds = CurrentSelection.getSortedTeiIds();
+
+ $scope.previousTeiExists = false;
+ $scope.nextTeiExists = false;
+
+ if($scope.sortedTeiIds && $scope.sortedTeiIds.length > 0){
+ var current = $scope.sortedTeiIds.indexOf($scope.selectedTeiId);
+
+ if(current !== -1){
+ if($scope.sortedTeiIds.length-1 > current){
+ $scope.nextTeiExists = true;
+ }
+
+ if(current > 0){
+ $scope.previousTeiExists = true;
+ }
+ }
+ }
+
$scope.selectedProgram;
$scope.selectedTei;
@@ -317,4 +337,17 @@
$rootScope.closeOpenWidget = function(widget){
saveDashboardLayout();
};
+
+ $scope.fetchTei = function(mode){
+ var current = $scope.sortedTeiIds.indexOf($scope.selectedTeiId);
+ var pr = ($location.search()).program;
+ var tei = null;
+ if(mode === 'NEXT'){
+ tei = $scope.sortedTeiIds[current+1];
+ }
+ else{
+ tei = $scope.sortedTeiIds[current-1];
+ }
+ $location.path('/dashboard').search({tei: tei, program: pr ? pr: null});
+ };
});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html 2015-02-24 17:47:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html 2015-03-11 15:02:58 +0000
@@ -3,6 +3,10 @@
<button type="button" class="btn btn-default" ng-click="back()">{{'back'| translate}}</button>
+ <button ng-disabled="!previousTeiExists" type="button" class="btn btn-default small-horizonal-spacing" ng-click="fetchTei('PREV')" title="{{'prv_rcrd'| translate}}"><i class="fa fa-backward"></i></button>
+
+ <button ng-disabled="!nextTeiExists" type="button" class="btn btn-default small-horizonal-spacing" ng-click="fetchTei('NEXT')" title="{{'nxt_rcrd'| translate}}"><i class="fa fa-forward"></i></button>
+
<select ng-model="selectedProgram"
class="form-control-program"
ng-options="program as program.name for program in programs | orderBy: 'name'"
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-11 11:21:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-11 15:02:58 +0000
@@ -1,3 +1,5 @@
+/* global angular, trackerCapture */
+
trackerCapture.controller('DataEntryController',
function($scope,
$modal,
=== 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 2015-03-06 15:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2015-03-11 15:02:58 +0000
@@ -154,7 +154,8 @@
});
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode);
+ var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode);
+ $scope.gridColumns = grid.columns;
$scope.gridColumns.push({name: $translate('event_orgunit_name'), id: 'orgUnitName', type: 'string', displayInListNoProgram: false, showFilter: false, show: true});
$scope.filterTypes['orgUnitName'] = 'string';
=== 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 2015-03-06 15:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2015-03-11 15:02:58 +0000
@@ -78,7 +78,8 @@
});
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
+ var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
+ $scope.gridColumns = grid.columns;
});
//fetch TEIs for the selected program and orgunit/mode
=== 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 2015-03-06 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js 2015-03-11 15:02:58 +0000
@@ -154,7 +154,8 @@
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode);
+ var grid = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode);
+ $scope.gridColumns = grid.columns;
$scope.gridColumns.push({name: $translate('event_orgunit_name'), id: 'eventOrgUnitName', type: 'string', displayInListNoProgram: false, showFilter: false, show: true});
$scope.filterTypes['orgUnitName'] = 'string';
=== 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-03-10 07:49:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-03-11 15:02:58 +0000
@@ -1,3 +1,5 @@
+/* global angular */
+
'use strict';
/* Controllers */
@@ -8,8 +10,11 @@
function($scope,
$modal,
$location,
+ $translate,
+ $filter,
Paginator,
storage,
+ DateUtils,
OptionSetService,
OrgUnitFactory,
OperatorFactory,
@@ -134,12 +139,36 @@
};
$scope.processAttributes = function(){
-
+ $scope.sortColumn = {};
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
$scope.attributes = $scope.generateAttributeFilters(atts);
- $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
+ var grid = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
+ $scope.gridColumns = grid.columns;
});
};
+
+ //sortGrid
+ $scope.sortGrid = function(gridHeader){
+ if ($scope.sortColumn && $scope.sortColumn.id === gridHeader.id){
+ $scope.reverse = !$scope.reverse;
+ return;
+ }
+ $scope.sortColumn = gridHeader;
+ if($scope.sortColumn.valueType === 'date'){
+ $scope.reverse = true;
+ }
+ else{
+ $scope.reverse = false;
+ }
+ };
+
+ $scope.d2Sort = function(tei){
+ if($scope.sortColumn && $scope.sortColumn.valueType === 'date'){
+ var d = tei[$scope.sortColumn.id];
+ return DateUtils.getDate(d);
+ }
+ return tei[$scope.sortColumn.id];
+ };
//$scope.searchParam = {bools: []};
$scope.search = function(mode){
@@ -228,6 +257,10 @@
$scope.showTrackedEntityDiv = true;
$scope.teiFetched = true;
$scope.doSearch = true;
+
+ if(!$scope.sortColumn.id){
+ $scope.sortGrid({id: 'created', name: $translate('registration_date'), valueType: 'date', displayInListNoProgram: false, showFilter: false, show: true});
+ }
});
};
@@ -305,7 +338,17 @@
});
};
- $scope.showDashboard = function(currentEntity){
+ $scope.showDashboard = function(currentEntity){
+ var sortedTei = $filter('orderBy')($scope.trackedEntityList.rows, function(tei) {
+ return $scope.d2Sort(tei);
+ }, $scope.reverse);
+
+ var sortedTeiIds = [];
+ angular.forEach(sortedTei, function(tei){
+ sortedTeiIds.push(tei.id);
+ });
+
+ CurrentSelection.setSortedTeiIds(sortedTeiIds);
$location.path('/dashboard').search({tei: currentEntity.id,
program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
};
=== 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-11 11:21:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-03-11 15:02:58 +0000
@@ -1,3 +1,5 @@
+/* global angular */
+
'use strict';
/* Services */
@@ -1079,6 +1081,7 @@
this.optionSets = null;
this.attributesById = null;
this.ouLevels = null;
+ this.sortedTeiIds = [];
this.set = function(currentSelection){
this.currentSelection = currentSelection;
@@ -1114,6 +1117,13 @@
this.getOuLevels = function(){
return this.ouLevels;
};
+
+ this.setSortedTeiIds = function(sortedTeiIds){
+ this.sortedTeiIds = sortedTeiIds;
+ };
+ this.getSortedTeiIds = function(){
+ return this.sortedTeiIds;
+ };
})
.service('TEIGridService', function(OrgUnitService, OptionSetService, DateUtils, $translate, AttributesFactory){
@@ -1192,6 +1202,7 @@
},
generateGridColumns: function(attributes, ouMode){
+ var filterTypes = {}, filterText = {};
var columns = attributes ? angular.copy(attributes) : [];
//also add extra columns which are not part of attributes (orgunit for example)
@@ -1200,16 +1211,20 @@
//generate grid column for the selected program/attributes
angular.forEach(columns, function(column){
- if(column.id === 'orgUnitName' && ouMode !== 'SELECTED'){
+ column.show = false;
+ if( (column.id === 'orgUnitName' && ouMode !== 'SELECTED') ||
+ column.displayInListNoProgram ||
+ column.displayInList ||
+ column.id === 'created'){
column.show = true;
+ }
+ column.showFilter = false;
+ filterTypes[column.id] = column.valueType;
+ if(column.valueType === 'date' || column.valueType === 'number' ){
+ filterText[column.id]= {};
}
-
- if(column.displayInListNoProgram || column.displayInList){
- column.show = true;
- }
- column.showFilter = false;
});
- return columns;
+ return {columns: columns, filterTypes: filterTypes, filterText: filterText};
},
getData: function(rows, columns){
var data = [];
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-03-11 11:21:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-03-11 15:02:58 +0000
@@ -90,7 +90,7 @@
.vertical-center {
line-height: inherit;
vertical-align: middle;
-
+
}
.empty-event-container {
@@ -134,10 +134,6 @@
font-weight: bold;
}
-.new-event {
- cursor: pointer;
-}
-
.stage-completed {
background-color: #b9ffb9;
}
@@ -990,21 +986,21 @@
}
.map_context_menu{
- background-color:white;
- border:1px solid gray;
+ background-color:white;
+ border:1px solid gray;
z-index: 1000;
}
.map_context_menu_item{
- padding:3px 6px;
+ padding:3px 6px;
}
.map_context_menu_item:hover{
- background-color:#CCCCCC;
+ background-color:#CCCCCC;
}
.map_context_menu_separator{
- background-color:gray;
- height:1px;
- margin:0;
- padding:0;
+ background-color:gray;
+ height:1px;
+ margin:0;
+ padding:0;
}
.disabled-context-menu-item {
@@ -1012,6 +1008,7 @@
color: #dddddd;
cursor: none;
}
-.enable-context-menu-item {
- cursor:pointer;
+
+.mouse-pointer {
+ cursor: pointer;
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html 2015-02-04 12:53:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html 2015-03-11 15:02:58 +0000
@@ -16,13 +16,18 @@
<table class="table table-striped dhis2-table-hover table-bordered">
<thead>
<tr>
- <th ng-show="gridColumn.show" ng-repeat="gridColumn in gridColumns">
- {{gridColumn.name}}
+ <th ng-if="gridColumn.show" ng-repeat="gridColumn in gridColumns" class='mouse-pointer' ng-click="sortGrid(gridColumn)">
+ <!-- sort icon begins -->
+ <span ng-hide="gridColumn.showFilter" class="bold pointer" title="{{'sort'| translate}}">
+ <span ng-class="{true: 'red'} [sortColumn.id === gridColumn.id]"><i class="fa fa-sort"></i></span>
+ {{gridColumn.name}}
+ </span>
+ <!-- sort icon ends -->
</th>
</tr>
</thead>
<tbody id="list">
- <tr ng-repeat="trackedEntity in trackedEntityList.rows"
+ <tr ng-repeat="trackedEntity in trackedEntityList.rows | orderBy:d2Sort:reverse"
ng-click="showDashboard(trackedEntity)"
title="{{'go_to_dashboard'| translate}}">
<td ng-show="gridColumn.show"