diff --git a/frontend/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts index a33f3d52b2..b286ae9f62 100644 --- a/frontend/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -42,7 +42,6 @@ import {scopeDestroyed$} from "../../../../helpers/angular-rx-utils"; import {WorkPackageTableTimelineVisible} from "../../../wp-fast-table/wp-table-timeline-visible"; import {debugLog} from "../../../../helpers/debug_output"; import {openprojectModule} from "../../../../angular-modules"; -import {WorkPackageTimelineHeaderController} from "../header/wp-timeline-header.directive"; import {TypeResource} from "../../../api/api-v3/hal-resources/type-resource.service"; import {WorkPackageTimelineCell} from "../wp-timeline-cell"; @@ -60,8 +59,6 @@ export class WorkPackageTimelineTableController { public disableViewParamsCalculation = false; - public header:WorkPackageTimelineHeaderController; - public cells:{[id: string]:WorkPackageTimelineCell} = {}; private renderers:{ [name:string]: (vp:TimelineViewParameters) => void } = {}; @@ -125,6 +122,10 @@ export class WorkPackageTimelineTableController { this.refreshView(); } + getAbsoluteLeftCoordinates():number { + return this.$element.offset().left; + } + get viewParameters(): TimelineViewParameters { return this._viewParameters; } @@ -148,7 +149,6 @@ export class WorkPackageTimelineTableController { setTimeout(() => { this.calculateViewParams(this._viewParameters); this.updateAllWorkPackagesSubject.next(true); - this.header.refreshView(this._viewParameters); _.each(this.renderers, (cb, key) => { debugLog(`Refreshing timeline member ${key}`); @@ -266,9 +266,9 @@ export class WorkPackageTimelineTableController { newParams.dateDisplayStart.subtract(3, "days"); // right spacing - const headerWidth = this.header.getHeaderWidth(); + const width = this.$element.width(); const pixelPerDay = currentParams.pixelPerDay; - const visibleDays = Math.ceil((headerWidth / pixelPerDay) * 1.5); + const visibleDays = Math.ceil((width / pixelPerDay) * 1.5); newParams.dateDisplayEnd.add(visibleDays, "days"); // Check if view params changed: @@ -285,9 +285,6 @@ export class WorkPackageTimelineTableController { this._viewParameters.dateDisplayEnd = newParams.dateDisplayEnd; } - - this._viewParameters.timelineHeader = this.header; - return changed; } } diff --git a/frontend/app/components/wp-table/timeline/header/wp-timeline-header.directive.ts b/frontend/app/components/wp-table/timeline/header/wp-timeline-header.directive.ts index 90066b5d77..607978fa6e 100644 --- a/frontend/app/components/wp-table/timeline/header/wp-timeline-header.directive.ts +++ b/frontend/app/components/wp-table/timeline/header/wp-timeline-header.directive.ts @@ -51,7 +51,7 @@ export class WorkPackageTimelineHeaderController { } $onInit() { - this.wpTimeline.header = this; + this.wpTimeline.onRefreshRequested('header', (vp:TimelineViewParameters) => this.refreshView(vp)); } refreshView(vp:TimelineViewParameters) { @@ -59,15 +59,6 @@ export class WorkPackageTimelineHeaderController { this.renderLabels(vp); } - getHeaderWidth():number { - // Consider the left margin of the header due to the border. - return this.$element.width(); - } - - getAbsoluteLeftCoordinates():number { - return this.$element.offset().left; - } - private renderLabels(vp:TimelineViewParameters) { if (this.activeZoomLevel === vp.settings.zoomLevel) { return; diff --git a/frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts b/frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts index 7bc993181e..f5053bfcf5 100644 --- a/frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts +++ b/frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts @@ -40,15 +40,6 @@ const classNameBar = "bar"; export const classNameLeftHandle = "leftHandle"; export const classNameRightHandle = "rightHandle"; - -function getCursorOffsetInDaysFromLeft(renderInfo: RenderInfo, ev: MouseEvent) { - const header = renderInfo.viewParams.timelineHeader; - const headerLeft = header.getAbsoluteLeftCoordinates(); - const cursorOffsetLeftInPx = ev.clientX - headerLeft; - const cursorOffsetLeftInDays = Math.floor(cursorOffsetLeftInPx / renderInfo.viewParams.pixelPerDay); - return cursorOffsetLeftInDays; -} - export function registerWorkPackageMouseHandler(this: void, getRenderInfo: () => RenderInfo, workPackageTimeline: WorkPackageTimelineTableController, @@ -86,6 +77,13 @@ export function registerWorkPackageMouseHandler(this: void, wpCacheService.updateWorkPackage(wp); } + function getCursorOffsetInDaysFromLeft(renderInfo: RenderInfo, ev: MouseEvent) { + const leftOffset = workPackageTimeline.getAbsoluteLeftCoordinates(); + const cursorOffsetLeftInPx = ev.clientX - leftOffset; + const cursorOffsetLeftInDays = Math.floor(cursorOffsetLeftInPx / renderInfo.viewParams.pixelPerDay); + return cursorOffsetLeftInDays; + } + function workPackageMouseDownFn(ev: MouseEvent) { ev.preventDefault(); diff --git a/frontend/app/components/wp-table/timeline/wp-timeline.ts b/frontend/app/components/wp-table/timeline/wp-timeline.ts index 55d081e580..9e829e4007 100644 --- a/frontend/app/components/wp-table/timeline/wp-timeline.ts +++ b/frontend/app/components/wp-table/timeline/wp-timeline.ts @@ -30,7 +30,6 @@ import { WorkPackageResourceInterface, WorkPackageResource } from "../../api/api-v3/hal-resources/work-package-resource.service"; -import {WorkPackageTimelineHeaderController} from "./header/wp-timeline-header.directive"; import Moment = moment.Moment; export const timelineElementCssClass = "timeline-element"; @@ -68,8 +67,6 @@ export class TimelineViewParameters { settings: TimelineViewParametersSettings = new TimelineViewParametersSettings(); - timelineHeader: WorkPackageTimelineHeaderController; - activeSelectionMode: null|((wp: WorkPackageResource) => any) = null; selectionModeStart: null|string = null;