diff --git a/dmp-frontend/src/app/entities/DataModel.ts b/dmp-frontend/src/app/entities/DataModel.ts index 257465c89..dd4da1c93 100644 --- a/dmp-frontend/src/app/entities/DataModel.ts +++ b/dmp-frontend/src/app/entities/DataModel.ts @@ -54,6 +54,10 @@ export class DataModel { return this.fIndex.get(key); } + public getFieldSourceByKey(key){ + return this.fIndSources.get(key); + } + diff --git a/dmp-frontend/src/app/form/dynamic-form.component.ts b/dmp-frontend/src/app/form/dynamic-form.component.ts index b81377c20..0fd4d7068 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form.component.ts @@ -26,7 +26,7 @@ export class DynamicFormComponent implements OnInit { constructor(private qcs: FieldControlService, private serverService: ServerService, private fieldVisibility: FieldVisibility, private dataModelService: dataModelBuilder) { - this.form = this.qcs.toFormGroup(new Array()); + this.form = this.qcs.toFormGroup(new Array(), new Array()); } @@ -63,7 +63,7 @@ export class DynamicFormComponent implements OnInit { this.dataModel = new DataModel(); this.dataModel = this.dataModelService.getDataModel(data); - this.form = this.qcs.toFormGroupAlt(this.dataModel.fields, this.dataModel.groups); + this.form = this.qcs.toFormGroup(this.dataModel.fields, this.dataModel.groups); //this.form = this.qcs.toFormGroup(this.fields); console.log("SUMMARY: ======>"); diff --git a/dmp-frontend/src/app/services/field-control.service.ts b/dmp-frontend/src/app/services/field-control.service.ts index c3e37aa1c..6b641c193 100644 --- a/dmp-frontend/src/app/services/field-control.service.ts +++ b/dmp-frontend/src/app/services/field-control.service.ts @@ -7,19 +7,9 @@ import { GroupBase } from '../form/dynamic-form-group/group-base'; @Injectable() export class FieldControlService { constructor(){ } - - toFormGroup(fields: FieldBase[]){ - let group: any ={}; - fields.forEach(field => { - group[field.key] = field.required ? new FormControl(field.value || '', Validators.required) - : new FormControl(field.value || '') - }); - - return new FormGroup(group); - } - toFormGroupAlt(fields: FieldBase[], groups: GroupBase[]){ + toFormGroup(fields: FieldBase[], groups: GroupBase[]){ let form: any = {};