change name toFormGroupAlt

This commit is contained in:
annampak 2017-09-21 13:32:58 +03:00
parent 77b44527b5
commit 5c5bf3bfd0
3 changed files with 7 additions and 13 deletions

View File

@ -54,6 +54,10 @@ export class DataModel {
return this.fIndex.get(key); return this.fIndex.get(key);
} }
public getFieldSourceByKey(key){
return this.fIndSources.get(key);
}

View File

@ -26,7 +26,7 @@ export class DynamicFormComponent implements OnInit {
constructor(private qcs: FieldControlService, private serverService: ServerService, private fieldVisibility: FieldVisibility, private dataModelService: dataModelBuilder) { 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 = new DataModel();
this.dataModel = this.dataModelService.getDataModel(data); 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); //this.form = this.qcs.toFormGroup(this.fields);
console.log("SUMMARY: ======>"); console.log("SUMMARY: ======>");

View File

@ -7,19 +7,9 @@ import { GroupBase } from '../form/dynamic-form-group/group-base';
@Injectable() @Injectable()
export class FieldControlService { export class FieldControlService {
constructor(){ } constructor(){ }
toFormGroup(fields: FieldBase<any>[]){
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<any>[], groups: GroupBase<any>[]){ toFormGroup(fields: FieldBase<any>[], groups: GroupBase<any>[]){
let form: any = {}; let form: any = {};