Restore hide other group filter in timelines

pull/913/head
Till Breuer 11 years ago
parent 85cbe57153
commit ccf07c0303
  1. 2
      app/assets/javascripts/angular/directives/timeline_directive.js
  2. 23
      app/assets/javascripts/angular/helpers/timeline-table-helper.js

@ -59,7 +59,7 @@ openprojectApp.directive('timeline', ['TimelineLoaderService', 'TimelineTableHel
if (tree.containsPlanningElements() || tree.containsProjects()) {
timeline.adjustForPlanningElements();
scope.rows = TimelineTableHelper.getTableRowsFromTimelineTree(tree);
scope.rows = TimelineTableHelper.getTableRowsFromTimelineTree(tree, timeline.options);
} else{
scope.rows = [];
}

@ -1,13 +1,25 @@
openprojectApp.factory('TimelineTableHelper', [function() {
var NodeFilter = function(options) {
this.options = options;
};
NodeFilter.prototype.excludeNode = function(node) {
return this.options && this.options.hide_other_group === 'yes' && node.level === 1 && node.payload.objectType === 'Project' && node.payload.getFirstLevelGrouping() === 0;
};
TimelineTableHelper = {
flattenTimelineTree: function(root, processNodeCallback){
flattenTimelineTree: function(root, filterCallback, processNodeCallback){
var nodes = [];
angular.forEach(root.childNodes, function(node){
if (!filterCallback(node)) {
// add relevant information to row
if (processNodeCallback) processNodeCallback(node, root);
// add subtree to nodes
nodes.push(node);
nodes = nodes.concat(TimelineTableHelper.flattenTimelineTree(node, processNodeCallback));
nodes = nodes.concat(TimelineTableHelper.flattenTimelineTree(node, filterCallback, processNodeCallback));
}
});
return nodes;
@ -32,10 +44,13 @@ openprojectApp.factory('TimelineTableHelper', [function() {
}
},
getTableRowsFromTimelineTree: function(tree) {
getTableRowsFromTimelineTree: function(tree, options) {
nodeFilter = new NodeFilter(options);
// add relevant information to tree root serving as first row
TimelineTableHelper.addRowDataToNode(tree);
rows = TimelineTableHelper.flattenTimelineTree(tree, TimelineTableHelper.addRowDataToNode);
rows = TimelineTableHelper.flattenTimelineTree(tree, function(node) { return nodeFilter.excludeNode(node); }, TimelineTableHelper.addRowDataToNode);
rows.unshift(tree);
return rows;

Loading…
Cancel
Save