From 18f6294914a7d987d0c86ab9e5fb1ccd836ffafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 13 Feb 2017 08:39:33 +0100 Subject: [PATCH] Properly close fields when submitting without changes --- .../wp-edit-form/work-package-edit-form.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/wp-edit-form/work-package-edit-form.ts b/frontend/app/components/wp-edit-form/work-package-edit-form.ts index 179558233c..26ade26c1c 100644 --- a/frontend/app/components/wp-edit-form/work-package-edit-form.ts +++ b/frontend/app/components/wp-edit-form/work-package-edit-form.ts @@ -98,6 +98,7 @@ export class WorkPackageEditForm { public submit() { if (!(this.workPackage.dirty || this.workPackage.isNew)) { + this.stopEditing(); return this.$q.when(this.workPackage); } @@ -117,8 +118,8 @@ export class WorkPackageEditForm { this.wpNotificationsService.showSave(this.workPackage, isInitial); this.editContext.onSaved(this.workPackage); - // Destroy this form - this.states.editing.get(this.workPackageId.toString()).clear('Editing completed'); + this.stopEditing(); + }) .catch((error) => { this.wpNotificationsService.handleErrorResponse(error, this.workPackage); @@ -130,6 +131,16 @@ export class WorkPackageEditForm { return deferred.promise; } + protected stopEditing() { + // Close all edit fields + _.each(this.activeFields, (handler:WorkPackageEditFieldHandler) => { + handler.deactivate(); + }); + + // Destroy this form + this.states.editing.get(this.workPackageId.toString()).clear('Editing completed'); + } + protected handleSubmissionErrors(error: any, deferred: any) { // Process single API errors this.handleErroneousAttributes(error);