|
|
@ -32,11 +32,13 @@ import {opWorkPackagesModule} from '../../../angular-modules'; |
|
|
|
import {WorkPackageEditingService} from '../../wp-edit-form/work-package-editing-service'; |
|
|
|
import {WorkPackageEditingService} from '../../wp-edit-form/work-package-editing-service'; |
|
|
|
import {WorkPackageEditForm} from '../../wp-edit-form/work-package-edit-form'; |
|
|
|
import {WorkPackageEditForm} from '../../wp-edit-form/work-package-edit-form'; |
|
|
|
import {SingleViewEditContext} from '../../wp-edit-form/single-view-edit-context'; |
|
|
|
import {SingleViewEditContext} from '../../wp-edit-form/single-view-edit-context'; |
|
|
|
|
|
|
|
import {input} from 'reactivestates'; |
|
|
|
|
|
|
|
|
|
|
|
export class WorkPackageEditFieldGroupController { |
|
|
|
export class WorkPackageEditFieldGroupController { |
|
|
|
public workPackageId:string; |
|
|
|
public workPackageId:string; |
|
|
|
public inEditMode:boolean; |
|
|
|
public inEditMode:boolean; |
|
|
|
public fields:{ [attribute:string]:WorkPackageEditFieldController } = {}; |
|
|
|
public fields:{ [attribute:string]:WorkPackageEditFieldController } = {}; |
|
|
|
|
|
|
|
private registeredFields = input<string[]>(); |
|
|
|
|
|
|
|
|
|
|
|
constructor(protected $scope:ng.IScope, |
|
|
|
constructor(protected $scope:ng.IScope, |
|
|
|
protected states:States, |
|
|
|
protected states:States, |
|
|
@ -75,6 +77,7 @@ export class WorkPackageEditFieldGroupController { |
|
|
|
|
|
|
|
|
|
|
|
public register(field:WorkPackageEditFieldController) { |
|
|
|
public register(field:WorkPackageEditFieldController) { |
|
|
|
this.fields[field.fieldName] = field; |
|
|
|
this.fields[field.fieldName] = field; |
|
|
|
|
|
|
|
this.registeredFields.putValue(_.keys(this.fields)); |
|
|
|
const form = this.editingForm; |
|
|
|
const form = this.editingForm; |
|
|
|
|
|
|
|
|
|
|
|
if (form && form.editMode) { |
|
|
|
if (form && form.editMode) { |
|
|
@ -82,6 +85,15 @@ export class WorkPackageEditFieldGroupController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public waitForField(name:string):Promise<WorkPackageEditFieldController> { |
|
|
|
|
|
|
|
return this.registeredFields |
|
|
|
|
|
|
|
.values$() |
|
|
|
|
|
|
|
.filter(keys => keys.indexOf(name) >= 0) |
|
|
|
|
|
|
|
.take(1) |
|
|
|
|
|
|
|
.map(() => this.fields[name]) |
|
|
|
|
|
|
|
.toPromise(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public start() { |
|
|
|
public start() { |
|
|
|
const form = this.wpEditing.startEditing(this.workPackageId, this.editContext, true); |
|
|
|
const form = this.wpEditing.startEditing(this.workPackageId, this.editContext, true); |
|
|
|
_.each(this.fields, ctrl => form.activate(ctrl.fieldName)); |
|
|
|
_.each(this.fields, ctrl => form.activate(ctrl.fieldName)); |
|
|
|