dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36947
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18899: tracker-capture: sorting TEI list in relationship
------------------------------------------------------------
revno: 18899
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-04-14 14:20:55 +0200
message:
tracker-capture: sorting TEI list in relationship
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.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/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-04-09 13:20:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-04-14 12:20:55 +0000
@@ -171,6 +171,7 @@
.controller('AddRelationshipController',
function($scope,
$rootScope,
+ DateUtils,
CurrentSelection,
OperatorFactory,
AttributesFactory,
@@ -264,6 +265,7 @@
$scope.queryUrl = null;
$scope.programUrl = null;
$scope.attributeUrl = {url: null, hasValue: false};
+ $scope.sortColumn = {};
}
//listen for selections
@@ -272,6 +274,29 @@
$scope.teiForRelationship = relationshipInfo.tei;
});
+ //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.search = function(mode){
resetFields();
@@ -338,7 +363,12 @@
//process tei grid
$scope.trackedEntityList = TEIGridService.format(data,false, $scope.optionSets);
$scope.showTrackedEntityDiv = true;
- $scope.teiFetched = true;
+ $scope.teiFetched = true;
+
+ if(!$scope.sortColumn.id){
+ $scope.sortGrid({id: 'created', name: $translate('registration_date'), valueType: 'date', displayInListNoProgram: false, showFilter: false, show: false});
+ }
+
});
};