Remove explicit dependency on TL header

[ci skip]
pull/5456/head
Oliver Günther 8 years ago
parent f0fdeba279
commit ba6f347532
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 15
      frontend/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts
  2. 11
      frontend/app/components/wp-table/timeline/header/wp-timeline-header.directive.ts
  3. 16
      frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts
  4. 3
      frontend/app/components/wp-table/timeline/wp-timeline.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;
}
}

@ -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;

@ -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();

@ -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;

Loading…
Cancel
Save