From 9c867c0ca1a8d49a0c44775de1e8314381a1e9ef Mon Sep 17 00:00:00 2001 From: Roman Roelofsen Date: Fri, 27 Jan 2017 13:05:22 +0100 Subject: [PATCH] WIP Timeline: create start/due values with drag'n'drop --- .../work-package-cache.service.ts | 4 ---- .../timeline-milestone-cell-renderer.ts | 2 +- .../wp-timeline-cell-mouse-handler.ts | 21 +++++-------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/frontend/app/components/work-packages/work-package-cache.service.ts b/frontend/app/components/work-packages/work-package-cache.service.ts index b2e4771e08..22cb157055 100644 --- a/frontend/app/components/work-packages/work-package-cache.service.ts +++ b/frontend/app/components/work-packages/work-package-cache.service.ts @@ -83,15 +83,11 @@ export class WorkPackageCacheService { } saveIfChanged(workPackage) { - console.log("saveIfChanged"); if (!(workPackage.dirty || workPackage.isNew)) { - console.log(" - aborted"); return this.$q.when(workPackage); } - console.log(" - pass"); - const deferred = this.$q.defer(); workPackage.save() .then(() => { diff --git a/frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts b/frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts index 7bf9c2ace5..9fbd65fabd 100644 --- a/frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts +++ b/frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts @@ -30,7 +30,6 @@ export class TimelineMilestoneCellRenderer extends TimelineCellRenderer { const placeholder = document.createElement("div"); placeholder.className = "timeline-element milestone"; placeholder.style.pointerEvents = "none"; - placeholder.style.position = "absolute"; placeholder.style.height = "1em"; placeholder.style.width = "1em"; placeholder.style.left = (days * renderInfo.viewParams.pixelPerDay) + "px"; @@ -94,6 +93,7 @@ export class TimelineMilestoneCellRenderer extends TimelineCellRenderer { if (dateForCreate) { renderInfo.workPackage.date = dateForCreate; direction = "create"; + return direction; } // create date label 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 9fd32091cf..fdbd3a88cc 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 @@ -61,11 +61,6 @@ export function registerWorkPackageMouseHandler(this: void, workPackageMouseDownFn(ev); }; - jBody.on("mouseup", () => { - deactivate(false); - } - ); - function applyDateValues(dates:{[name:string]: Moment}) { const wp = renderInfo.workPackage; @@ -108,6 +103,7 @@ export function registerWorkPackageMouseHandler(this: void, jBody.on("mousemove", createMouseMoveFn(direction)); jBody.on("keyup", keyPressFn); + jBody.on("mouseup", () => deactivate(false)); } function handleMouseMoveOnEmptyCell(ev: MouseEvent) { @@ -142,6 +138,7 @@ export function registerWorkPackageMouseHandler(this: void, if (mouseDownType === "create") { deactivate(false); + ev.preventDefault(); return; } @@ -162,25 +159,17 @@ export function registerWorkPackageMouseHandler(this: void, deactivate(false); }; - jBody.on("keyup", (ev) => { - const kev: KeyboardEvent = ev as any; - if (kev.keyCode === keyCodeESC) { - deactivate(true); - } - }); - + jBody.on("keyup", keyPressFn); }; } function deactivate(cancelled: boolean) { workPackageTimeline.disableViewParamsCalculation = false; - // if (startX == null) { - // return; - // } - cell.onmousemove = handleMouseMoveOnEmptyCell; + cell.onmouseup = null; bar.style.pointerEvents = "auto"; + jBody.off("mouseup"); jBody.off("mousemove"); jBody.off("keyup"); jQuery(".hascontextmenu").css("cursor", "context-menu");