From c223d6f1082bdf83f9a3a2b1abbb6cc820f63737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 25 May 2016 09:37:03 +0200 Subject: [PATCH] Explicit setter for wpEditField.workPackage --- .../wp-edit-field/wp-edit-field.directive.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.ts b/frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.ts index b7ce8f726c..4e14bd2625 100644 --- a/frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.ts +++ b/frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.ts @@ -43,6 +43,7 @@ export class WorkPackageEditFieldController { public fieldLabel: string; public field: Field; public errorenous: boolean; + public workPackage: WorkPackageResource; protected _active: boolean = false; protected _forceFocus: boolean = false; @@ -63,10 +64,6 @@ export class WorkPackageEditFieldController { } - public get workPackage() { - return this.formCtrl.workPackage; - } - public get active() { return this._active; } @@ -104,10 +101,10 @@ export class WorkPackageEditFieldController { }); } - public initializeField(wp) { + public initializeField() { // Activate field when creating a work package // and the schema requires this field - if (wp.isNew && this.workPackage.requiredValueFor(this.fieldName)) { + if (this.workPackage.isNew && this.workPackage.requiredValueFor(this.fieldName)) { this.activate(); var activeField = this.formCtrl.firstActiveField; @@ -118,7 +115,7 @@ export class WorkPackageEditFieldController { // Mark the td field if it is inline-editable // We're resolving the non-form schema here since its loaded anyway for the table - wp.schema.$load().then(schema => { + this.workPackage.schema.$load().then(schema => { var fieldSchema = schema[this.fieldName]; this.editable = fieldSchema && fieldSchema.writable; @@ -230,11 +227,13 @@ function wpEditFieldLink(scope, formCtrl.registerField(scope.vm); formCtrl.onWorkPackageUpdated('wp-edit-field-' + scope.vm.fieldName, (wp) => { - scope.vm.initializeField(wp); + scope.vm.workPackage = wp; + scope.vm.initializeField(); }); - if (scope.vm.workPackage) { - scope.vm.initializeField(scope.vm.workPackage); + if (formCtrl.workPackage) { + scope.vm.workPackage = formCtrl.workPackage; + scope.vm.initializeField(); } element.addClass(scope.vm.fieldName);