Skip to content
Snippets Groups Projects
Commit cacce2ff authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #9607: fill project and group filters with entries from filtered tasks

parent 7ecdf80d
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,7 @@ $scope.columns = [ ...@@ -78,7 +78,7 @@ $scope.columns = [
{ field: 'mom_object_group_id', { field: 'mom_object_group_id',
displayName: 'Group', displayName: 'Group',
enableCellEdit: false, 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%', width: '13%',
filter: { filter: {
condition: uiGridConstants.filter.EXACT, condition: uiGridConstants.filter.EXACT,
...@@ -255,6 +255,11 @@ $scope.columns = [ ...@@ -255,6 +255,11 @@ $scope.columns = [
$scope.$evalAsync(jumpToSelectedTaskRows); $scope.$evalAsync(jumpToSelectedTaskRows);
}, true); }, true);
$scope.$watch('dataService.filteredTaskChangeCntr', function() {
$scope.$evalAsync(fillProjectsColumFilterSelectOptions)
$scope.$evalAsync(fillGroupsColumFilterSelectOptions);
});
$scope.$watch('dataService.initialLoadComplete', function() { $scope.$watch('dataService.initialLoadComplete', function() {
$scope.$evalAsync(function() { $scope.$evalAsync(function() {
taskstatustypenames = $scope.dataService.taskstatustypes.map(function(x) { return x.name; }); taskstatustypenames = $scope.dataService.taskstatustypes.map(function(x) { return x.name; });
...@@ -271,10 +276,10 @@ $scope.columns = [ ...@@ -271,10 +276,10 @@ $scope.columns = [
function fillProjectsColumFilterSelectOptions() { function fillProjectsColumFilterSelectOptions() {
var projectNames = []; var projectNames = [];
var momProjectsDict = $scope.dataService.momProjectsDict; var momProjectsDict = $scope.dataService.momProjectsDict;
var tasks = $scope.dataService.tasks; var tasks = $scope.dataService.filteredTasks;
//get unique projectIds from tasks //get unique projectIds from tasks
var task_project_ids = tasks.map(function(t) { return t.project_mom_id; }); 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) { for(var project_id of task_project_ids) {
if(momProjectsDict.hasOwnProperty(project_id)) { if(momProjectsDict.hasOwnProperty(project_id)) {
...@@ -289,13 +294,22 @@ $scope.columns = [ ...@@ -289,13 +294,22 @@ $scope.columns = [
}; };
function fillGroupsColumFilterSelectOptions() { function fillGroupsColumFilterSelectOptions() {
var tasks = $scope.dataService.tasks; var tasks = $scope.dataService.filteredTasks;
//get unique groupNames from tasks //get unique groupNames from tasks
var groupNamesAndIds = tasks.map(function(t) { return { name: t.mom_object_group_name, id: t.mom_object_group_id }; }); var groupId2Name = {};
groupNamesAndIds = groupNamesAndIds.filter(function(value, index, arr) { return arr.indexOf(value) == index;}) var groupIds = [];
groupNamesAndIds.sort();
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]); fillColumFilterSelectOptions(groupSelectOptions, $scope.columns[7]);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment