diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/gridcontroller.js b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/gridcontroller.js index 7f2833ef4ac53770a75e6080b52f1fd1ce20f961..461b7892185fb56d3dedcbf26ee927539a7a1cb5 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/gridcontroller.js +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/gridcontroller.js @@ -78,7 +78,7 @@ $scope.columns = [ { field: 'mom_object_group_id', displayName: 'Group', enableCellEdit: false, - cellTemplate:'<a target="_blank" href="https://lofar.astron.nl/mom3/user/project/setUpMom2ObjectDetails.do?view=generalinfo&mom2ObjectId={{row.entity.mom_object_group_mom2object_id}}">{{row.entity.mom_object_group_name}} {{row.entity.mom_object_group_id}}</a>', + cellTemplate:'<a target="_blank" href="https://lofar.astron.nl/mom3/user/project/setUpMom2ObjectDetails.do?view=generalinfo&mom2ObjectId={{row.entity.mom_object_group_mom2object_id}}">{{row.entity.mom_object_group_id}} {{row.entity.mom_object_group_name}}</a>', width: '13%', filter: { condition: uiGridConstants.filter.EXACT, @@ -255,6 +255,11 @@ $scope.columns = [ $scope.$evalAsync(jumpToSelectedTaskRows); }, true); + $scope.$watch('dataService.filteredTaskChangeCntr', function() { + $scope.$evalAsync(fillProjectsColumFilterSelectOptions) + $scope.$evalAsync(fillGroupsColumFilterSelectOptions); + }); + $scope.$watch('dataService.initialLoadComplete', function() { $scope.$evalAsync(function() { taskstatustypenames = $scope.dataService.taskstatustypes.map(function(x) { return x.name; }); @@ -271,10 +276,10 @@ $scope.columns = [ function fillProjectsColumFilterSelectOptions() { var projectNames = []; var momProjectsDict = $scope.dataService.momProjectsDict; - var tasks = $scope.dataService.tasks; + var tasks = $scope.dataService.filteredTasks; //get unique projectIds from tasks var task_project_ids = tasks.map(function(t) { return t.project_mom_id; }); - task_project_ids = task_project_ids.filter(function(value, index, arr) { return arr.indexOf(value) == index;}) + task_project_ids = task_project_ids.filter(function(value, index) { return task_project_ids.indexOf(value) == index;}) for(var project_id of task_project_ids) { if(momProjectsDict.hasOwnProperty(project_id)) { @@ -289,13 +294,22 @@ $scope.columns = [ }; function fillGroupsColumFilterSelectOptions() { - var tasks = $scope.dataService.tasks; + var tasks = $scope.dataService.filteredTasks; //get unique groupNames from tasks - var groupNamesAndIds = tasks.map(function(t) { return { name: t.mom_object_group_name, id: t.mom_object_group_id }; }); - groupNamesAndIds = groupNamesAndIds.filter(function(value, index, arr) { return arr.indexOf(value) == index;}) - groupNamesAndIds.sort(); + var groupId2Name = {}; + var groupIds = []; + + for(var task of tasks) { + if(task.mom_object_group_id) { + if(!groupId2Name.hasOwnProperty(task.mom_object_group_id)) { + groupId2Name[task.mom_object_group_id] = task.mom_object_group_name; + groupIds.push(task.mom_object_group_id); + } + } + } - var groupSelectOptions = groupNamesAndIds.map(function(obj) { return { value: obj.id, label: obj.name + ' ' + obj.id }; }); + var groupSelectOptions = groupIds.map(function(gid) { return { value: gid, label: gid + ' ' + groupId2Name[gid]}; }); + groupSelectOptions.sort(function(a,b) { return a.value - b.value; }); fillColumFilterSelectOptions(groupSelectOptions, $scope.columns[7]); };