Timeline: start/due dates can't be moved after/before each other

pull/5162/head
Roman Roelofsen 8 years ago
parent b3453bb010
commit b87fd9b1c0
  1. 11
      frontend/app/components/wp-table/timeline/cell-renderer/timeline-cell-renderer.ts
  2. 6
      frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts

@ -42,7 +42,7 @@ export class TimelineCellRenderer {
* Handle movement by <delta> days of the work package to either (or both) edge(s)
* depending on which initial date was set.
*/
public onDaysMoved(wp:WorkPackageResourceInterface, delta:number) {
public onDaysMoved(wp: WorkPackageResourceInterface, delta: number): CellDateMovement {
const initialStartDate = wp.$pristine['startDate'];
const initialDueDate = wp.$pristine['dueDate'];
let dates:CellDateMovement = {};
@ -55,6 +55,15 @@ export class TimelineCellRenderer {
dates.dueDate = moment(initialDueDate).add(delta, "days");
}
// only start or due are changed
if (_.keys(dates).length === 1) {
if (dates.startDate != undefined && dates.startDate.isAfter(moment(wp.dueDate))) {
dates.startDate = moment(wp.dueDate);
} else if (dates.dueDate != undefined && dates.dueDate.isBefore(moment(wp.startDate))) {
dates.dueDate = moment(wp.startDate);
}
}
return dates;
}

@ -27,12 +27,12 @@
// ++
import {timelineElementCssClass, RenderInfo} from "./wp-timeline";
import {WorkPackageCacheService} from "../../work-packages/work-package-cache.service";
import {WorkPackageTimelineTableController} from "./wp-timeline-container.directive";
import {TimelineCellRenderer} from "./cell-renderer/timeline-cell-renderer";
import IScope = angular.IScope;
import Observable = Rx.Observable;
import IDisposable = Rx.IDisposable;
import Moment = moment.Moment;
import {WorkPackageTimelineTableController} from "./wp-timeline-container.directive";
import {TimelineCellRenderer} from './cell-renderer/timeline-cell-renderer';
const classNameBar = "bar";
const classNameLeftHandle = "leftHandle";
@ -76,7 +76,7 @@ export function registerWorkPackageMouseHandler(this: void,
dateStates = renderer.onDaysMoved(renderInfo.workPackage, days);
applyDateValues(dateStates);
applyDateValues(dateStates);
}
function keyPressFn(ev: JQueryEventObject) {

Loading…
Cancel
Save