From 0ee8a57c528cbe028242be811b8be1b57ae37b98 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:51:53 +0200 Subject: [PATCH] fix: [BETA-157] custom working list query (#1915) --- components/home/lists/lists-controller.js | 25 +++++++---------------- scripts/services.js | 4 ++-- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/components/home/lists/lists-controller.js b/components/home/lists/lists-controller.js index 84ab1e1b2..727d4bd61 100644 --- a/components/home/lists/lists-controller.js +++ b/components/home/lists/lists-controller.js @@ -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; @@ -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) diff --git a/scripts/services.js b/scripts/services.js index 12476c159..d2ee77697 100644 --- a/scripts/services.js +++ b/scripts/services.js @@ -2006,7 +2006,7 @@ var trackerCaptureServices = angular.module('trackerCaptureServices', ['ngResour query.url = query.url + q; } else{ - query.url = q; + query.url = q.substring(1); } } } @@ -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");