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/builders/timeline-cell-builder.ts

52 lines
1.6 KiB

import {WorkPackageCacheService} from "../../work-packages/work-package-cache.service";
import {WorkPackageTimelineCell} from "../../wp-table/timeline/wp-timeline-cell";
import {States} from "../../states.service";
import {WorkPackageResource} from "./../../api/api-v3/hal-resources/work-package-resource.service";
import {injectorBridge} from "../../angular/angular-injector-bridge.functions";
import {WorkPackageTable} from "../wp-fast-table";
export const timelineCellClassName = 'wp-timeline-cell';
export const timelineCollapsedClassName = '-collapsed';
export class TimelineCellBuilder {
public states:States;
public wpCacheService:WorkPackageCacheService;
constructor(private workPackageTable: WorkPackageTable) {
injectorBridge(this);
}
public get isVisible():boolean {
return this.states.table.timelineVisible.getCurrentValue() || false;
}
public build(workPackage:WorkPackageResource):HTMLElement {
const td = document.createElement('td');
td.classList.add(timelineCellClassName, '-max');
if (!this.isVisible) {
td.classList.add(timelineCollapsedClassName);
}
this.buildTimelineCell(td, workPackage);
return td;
}
public buildTimelineCell(cell:HTMLElement, workPackage:WorkPackageResource):void {
// required data for timeline cell
const timelineCell = new WorkPackageTimelineCell(
this.workPackageTable.timelineController,
this.wpCacheService,
this.states,
workPackage.id,
cell
);
// show timeline cell
timelineCell.activate();
}
}
TimelineCellBuilder.$inject = ['states', 'wpCacheService'];