Skip to content

Commit

Permalink
fix: [BETA-157] custom working list query (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Apr 24, 2024
1 parent 201c835 commit 0ee8a57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
25 changes: 7 additions & 18 deletions components/home/lists/lists-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ trackerCapture.controller('ListsController',function(
if($scope.customWorkingListValues.assignedUserMode){
customConfig.assignUrl += "&assignedUserMode="+$scope.customWorkingListValues.assignedUserMode;
}
if(!$scope.customWorkingListValues.assignedUserMode ||$scope.customWorkingListValues.assignedUserMode == "PROVIDED"
if((!$scope.customWorkingListValues.assignedUserMode || $scope.customWorkingListValues.assignedUserMode == "PROVIDED")
&& $scope.customWorkingListValues.assignedUsers){
if(customConfig.assignUrl) customConfig.assignUrl+="&";
customConfig.assignUrl += "assignedUser="+$scope.customWorkingListValues.assignedUsers;
Expand All @@ -242,33 +242,22 @@ trackerCapture.controller('ListsController',function(
customConfig.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.customWorkingListValues.attributes, $scope.customWorkingListValues.enrollment);

setCurrentTrackedEntityList($scope.trackedEntityListTypes.CUSTOM, customConfig, null);
$scope.fetchCustomWorkingList(customConfig);
$scope.fetchCustomWorkingList();
}

var getOrderUrl = function(urlToExtend){
if($scope.currentTrackedEntityList.sortColumn){
var sortColumn = $scope.currentTrackedEntityList.sortColumn;
if(urlToExtend){
return urlToExtend += "&order="+sortColumn.id+':'+sortColumn.direction;
}
return "order="+sortColumn.id+":"+sortColumn.direction;
}

}


$scope.fetchCustomWorkingList= function(){
if(!$scope.currentTrackedEntityList.type == $scope.trackedEntityListTypes.CUSTOM) return;
if($scope.currentTrackedEntityList.type !== $scope.trackedEntityListTypes.CUSTOM) return;
var customConfig = $scope.currentTrackedEntityList.config;
var sortColumn = $scope.currentTrackedEntityList.sortColumn;
$scope.currentTrackedEntityList.loading = true;
customConfig.queryAndSortUrl = customConfig.queryUrl;
if(sortColumn){
var order = '&order=' + sortColumn.id + ':' +sortColumn.direction;
customConfig.queryAndSortUrl = customConfig.queryAndSortUrl.concat(order);
if (customConfig.queryAndSortUrl) customConfig.queryAndSortUrl += "&";
customConfig.queryAndSortUrl += 'order=' + sortColumn.id + ':' +sortColumn.direction;
}
if(customConfig.assignUrl){
customConfig.queryAndSortUrl = customConfig.queryAndSortUrl.concat(customConfig.assignUrl);
if (customConfig.queryAndSortUrl) customConfig.queryAndSortUrl += "&";
customConfig.queryAndSortUrl += customConfig.assignUrl;
}

TEIService.search(customConfig.orgUnit.id,customConfig.ouMode.name, customConfig.queryAndSortUrl, customConfig.programUrl, customConfig.attributeUrl.url, $scope.pager, true)
Expand Down
4 changes: 2 additions & 2 deletions scripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ var trackerCaptureServices = angular.module('trackerCaptureServices', ['ngResour
query.url = query.url + q;
}
else{
query.url = q;
query.url = q.substring(1);
}
}
}
Expand Down Expand Up @@ -2852,7 +2852,7 @@ var trackerCaptureServices = angular.module('trackerCaptureServices', ['ngResour
searchParams.programUrl += "&followUp=true"
}
if(sortColumn){
searchParams.sortUrl = "&order="+sortColumn.id+':'+sortColumn.direction;
searchParams.sortUrl = "order="+sortColumn.id+':'+sortColumn.direction;
}
if(workingList.enrollmentCreatedPeriod){
var enrollmentStartDate = moment().add(workingList.enrollmentCreatedPeriod.periodFrom, 'days').format("YYYY-MM-DD");
Expand Down

0 comments on commit 0ee8a57

Please sign in to comment.