33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
|
import { FormGroup } from '@angular/forms';
|
||
|
import { AutoCompleteFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data';
|
||
|
import { FieldDataEditorModel } from './field-data-editor-model';
|
||
|
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
|
||
|
|
||
|
export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel<AutoCompleteFieldDataEditorModel> {
|
||
|
|
||
|
public type: string;
|
||
|
public url: string;
|
||
|
public optionsRoot: string;
|
||
|
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();
|
||
|
|
||
|
buildForm(): FormGroup {
|
||
|
const formGroup = this.formBuilder.group({
|
||
|
label: [this.label],
|
||
|
type: [this.type],
|
||
|
url: [this.url],
|
||
|
optionsRoot: [this.optionsRoot]
|
||
|
});
|
||
|
formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm());
|
||
|
return formGroup;
|
||
|
}
|
||
|
|
||
|
fromModel(item: AutoCompleteFieldData): AutoCompleteFieldDataEditorModel {
|
||
|
this.type = item.type;
|
||
|
this.url = item.url;
|
||
|
this.label = item.label;
|
||
|
this.optionsRoot = item.optionsRoot;
|
||
|
this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions);
|
||
|
return this;
|
||
|
}
|
||
|
}
|