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/frontend/app/components/wp-fast-table/helpers/wp-table-hierarchy-helpers.ts

38 lines
1.2 KiB

import {WorkPackageResourceInterface} from '../../api/api-v3/hal-resources/work-package-resource.service';
import {WorkPackageTable} from '../wp-fast-table';
/**
* Returns the collapsed group class for the given ancestor id
*/
export function collapsedGroupClass(ancestorId:string):string {
return `__collapsed-group-${ancestorId}`;
}
export function hierarchyGroupClass(ancestorId:string):string {
return `__hierarchy-group-${ancestorId}`;
}
export function hierarchyRootClass(ancestorId:string):string {
return `__hierarchy-root-${ancestorId}`;
}
export function ancestorClassIdentifier(ancestorId:string) {
return `wp-ancestor-row-${ancestorId}`;
}
/**
* Returns whether any of the children of this work package
* are visible in the table results.
*/
export function hasChildrenInTable(workPackage:WorkPackageResourceInterface, table:WorkPackageTable) {
if (workPackage.isLeaf) {
return false; // Work Package has no children at all
}
// Return if this work package is in the ancestor chain of any of the work packages
return !!_.find(table.rows, (wpId:string) => {
const row = table.rowIndex[wpId].object;
return row.ancestorIds.indexOf(workPackage.id.toString()) >= 0;
});
}