OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/app/assets/javascripts/angular/helpers/timeline-table-helper.js

47 lines
1.3 KiB

openprojectApp.factory('TimelineTableHelper', [function() {
TimelineTableHelper = {
flattenTimelineTree: function(root, processNodeCallback){
var nodes = [];
angular.forEach(root.childNodes, function(node){
if (processNodeCallback) processNodeCallback(node, root);
nodes.push(node);
nodes = nodes.concat(TimelineTableHelper.flattenTimelineTree(node, processNodeCallback));
});
return nodes;
},
addRowDataToNode: function(node, parent) {
// ancestors
if (parent) {
node.ancestors = [parent];
if(parent.ancestors) node.ancestors = parent.ancestors.concat(node.ancestors);
}
// first level group
isNested = node.level >= 2;
if (node.payload.objectType === 'Project' && !isNested) {
node.firstLevelGroup = node.payload.getFirstLevelGrouping();
node.firstLevelGroupingName = node.payload.getFirstLevelGroupingName();
} else {
// inherit group from parent
node.firstLevelGroup = parent.firstLevelGroup;
}
},
getTableRowsFromTimelineTree: function(tree) {
TimelineTableHelper.addRowDataToNode(tree);
rows = TimelineTableHelper.flattenTimelineTree(tree, TimelineTableHelper.addRowDataToNode);
rows.unshift(tree);
return rows;
}
};
return TimelineTableHelper;
}]);