WIP Timeline: create start/due values with drag'n'drop

pull/5181/head
Roman Roelofsen 8 years ago
parent 41780ae1e2
commit 9c867c0ca1
  1. 4
      frontend/app/components/work-packages/work-package-cache.service.ts
  2. 2
      frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts
  3. 21
      frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts

@ -83,15 +83,11 @@ export class WorkPackageCacheService {
} }
saveIfChanged(workPackage) { saveIfChanged(workPackage) {
console.log("saveIfChanged");
if (!(workPackage.dirty || workPackage.isNew)) { if (!(workPackage.dirty || workPackage.isNew)) {
console.log(" - aborted");
return this.$q.when(workPackage); return this.$q.when(workPackage);
} }
console.log(" - pass");
const deferred = this.$q.defer(); const deferred = this.$q.defer();
workPackage.save() workPackage.save()
.then(() => { .then(() => {

@ -30,7 +30,6 @@ export class TimelineMilestoneCellRenderer extends TimelineCellRenderer {
const placeholder = document.createElement("div"); const placeholder = document.createElement("div");
placeholder.className = "timeline-element milestone"; placeholder.className = "timeline-element milestone";
placeholder.style.pointerEvents = "none"; placeholder.style.pointerEvents = "none";
placeholder.style.position = "absolute";
placeholder.style.height = "1em"; placeholder.style.height = "1em";
placeholder.style.width = "1em"; placeholder.style.width = "1em";
placeholder.style.left = (days * renderInfo.viewParams.pixelPerDay) + "px"; placeholder.style.left = (days * renderInfo.viewParams.pixelPerDay) + "px";
@ -94,6 +93,7 @@ export class TimelineMilestoneCellRenderer extends TimelineCellRenderer {
if (dateForCreate) { if (dateForCreate) {
renderInfo.workPackage.date = dateForCreate; renderInfo.workPackage.date = dateForCreate;
direction = "create"; direction = "create";
return direction;
} }
// create date label // create date label

@ -61,11 +61,6 @@ export function registerWorkPackageMouseHandler(this: void,
workPackageMouseDownFn(ev); workPackageMouseDownFn(ev);
}; };
jBody.on("mouseup", () => {
deactivate(false);
}
);
function applyDateValues(dates:{[name:string]: Moment}) { function applyDateValues(dates:{[name:string]: Moment}) {
const wp = renderInfo.workPackage; const wp = renderInfo.workPackage;
@ -108,6 +103,7 @@ export function registerWorkPackageMouseHandler(this: void,
jBody.on("mousemove", createMouseMoveFn(direction)); jBody.on("mousemove", createMouseMoveFn(direction));
jBody.on("keyup", keyPressFn); jBody.on("keyup", keyPressFn);
jBody.on("mouseup", () => deactivate(false));
} }
function handleMouseMoveOnEmptyCell(ev: MouseEvent) { function handleMouseMoveOnEmptyCell(ev: MouseEvent) {
@ -142,6 +138,7 @@ export function registerWorkPackageMouseHandler(this: void,
if (mouseDownType === "create") { if (mouseDownType === "create") {
deactivate(false); deactivate(false);
ev.preventDefault();
return; return;
} }
@ -162,25 +159,17 @@ export function registerWorkPackageMouseHandler(this: void,
deactivate(false); deactivate(false);
}; };
jBody.on("keyup", (ev) => { jBody.on("keyup", keyPressFn);
const kev: KeyboardEvent = ev as any;
if (kev.keyCode === keyCodeESC) {
deactivate(true);
}
});
}; };
} }
function deactivate(cancelled: boolean) { function deactivate(cancelled: boolean) {
workPackageTimeline.disableViewParamsCalculation = false; workPackageTimeline.disableViewParamsCalculation = false;
// if (startX == null) {
// return;
// }
cell.onmousemove = handleMouseMoveOnEmptyCell; cell.onmousemove = handleMouseMoveOnEmptyCell;
cell.onmouseup = null;
bar.style.pointerEvents = "auto"; bar.style.pointerEvents = "auto";
jBody.off("mouseup");
jBody.off("mousemove"); jBody.off("mousemove");
jBody.off("keyup"); jBody.off("keyup");
jQuery(".hascontextmenu").css("cursor", "context-menu"); jQuery(".hascontextmenu").css("cursor", "context-menu");

Loading…
Cancel
Save