Reset newly set date when the work package is erroneous

pull/5162/head
Oliver Günther 8 years ago
parent 0bdc600e2d
commit c5694e282d
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 7
      frontend/app/components/work-packages/work-package-cache.service.ts
  2. 2
      frontend/app/components/wp-table/timeline/cell-renderer/timeline-cell-renderer.ts
  3. 2
      frontend/app/components/wp-table/timeline/cell-renderer/timeline-milestone-cell-renderer.ts
  4. 22
      frontend/app/components/wp-table/timeline/wp-timeline-cell-mouse-handler.ts

@ -86,14 +86,19 @@ export class WorkPackageCacheService {
return this.$q.when(workPackage); return this.$q.when(workPackage);
} }
return workPackage.save() const deferred = this.$q.defer();
workPackage.save()
.then(() => { .then(() => {
this.wpNotificationsService.showSave(workPackage); this.wpNotificationsService.showSave(workPackage);
this.$rootScope.$emit('workPackagesRefreshInBackground'); this.$rootScope.$emit('workPackagesRefreshInBackground');
deferred.resolve(workPackage);
}) })
.catch((error) => { .catch((error) => {
this.wpNotificationsService.handleErrorResponse(error, workPackage); this.wpNotificationsService.handleErrorResponse(error, workPackage);
deferred.reject(error);
}); });
return deferred.promise;
} }
loadWorkPackage(workPackageId: number, forceUpdate = false): State<WorkPackageResource> { loadWorkPackage(workPackageId: number, forceUpdate = false): State<WorkPackageResource> {

@ -33,7 +33,7 @@ export class TimelineCellRenderer {
/** /**
* Restore the original date, if any was set. * Restore the original date, if any was set.
*/ */
public onCancel(wp:WorkPackageResourceInterface, dates:CellDateMovement) { public onCancel(wp:WorkPackageResourceInterface) {
wp.restoreFromPristine('startDate'); wp.restoreFromPristine('startDate');
wp.restoreFromPristine('dueDate'); wp.restoreFromPristine('dueDate');
} }

@ -28,7 +28,7 @@ export class TimelineMilestoneCellRenderer extends TimelineCellRenderer {
/** /**
* Restore the original date, if any was set. * Restore the original date, if any was set.
*/ */
public onCancel(wp: WorkPackageResourceInterface, dates:CellMilestoneMovement) { public onCancel(wp: WorkPackageResourceInterface) {
wp.restoreFromPristine('date'); wp.restoreFromPristine('date');
} }

@ -106,13 +106,6 @@ export function registerWorkPackageMouseHandler(this: void,
return; return;
} }
if (cancelled) {
renderer.onCancel(renderInfo.workPackage, dateStates);
} else {
// Persist the changes
wpCacheService.saveIfChanged(renderInfo.workPackage);
}
jBody.off("mousemove", mouseMoveFn); jBody.off("mousemove", mouseMoveFn);
jBody.off("keyup", keyPressFn); jBody.off("keyup", keyPressFn);
jQuery(".hascontextmenu").css("cursor", "context-menu"); jQuery(".hascontextmenu").css("cursor", "context-menu");
@ -123,9 +116,20 @@ export function registerWorkPackageMouseHandler(this: void,
startX = null; startX = null;
dateStates = {}; dateStates = {};
workPackageTimeline.refreshView(); if (cancelled) {
renderer.onCancel(renderInfo.workPackage);
return workPackageTimeline.refreshView();
}
// Persist the changes
wpCacheService.saveIfChanged(renderInfo.workPackage)
.catch(() => {
// Reset the changes on error
renderer.onCancel(renderInfo.workPackage);
})
.finally(() => {
workPackageTimeline.refreshView();
});
} }
} }

Loading…
Cancel
Save