2019-01-18 18:03:45 +01:00
|
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
|
import { FormGroup } from '@angular/forms';
|
2019-12-11 15:51:03 +01:00
|
|
|
|
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
|
|
|
|
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
|
|
|
|
import { AutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model';
|
|
|
|
|
import { WordListFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model';
|
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-dataset-profile-editor-combo-box-field-component',
|
|
|
|
|
styleUrls: ['./dataset-profile-editor-combo-box-field.component.scss'],
|
|
|
|
|
templateUrl: './dataset-profile-editor-combo-box-field.component.html'
|
|
|
|
|
})
|
|
|
|
|
export class DatasetProfileEditorComboBoxFieldComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@Input() form: FormGroup;
|
|
|
|
|
options = DatasetProfileComboBoxType;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public enumUtils: EnumUtils
|
|
|
|
|
) { super(); }
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-02-17 17:39:07 +01:00
|
|
|
|
// this.setupListeners();
|
2019-01-28 16:47:12 +01:00
|
|
|
|
}
|
2019-01-28 14:05:19 +01:00
|
|
|
|
|
2019-01-28 16:47:12 +01:00
|
|
|
|
setupListeners() {
|
2019-01-18 18:03:45 +01:00
|
|
|
|
this.form.get('data').get('type').valueChanges
|
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
|
.subscribe(x => {
|
2019-01-28 16:47:12 +01:00
|
|
|
|
if (this.form.get('data')) { this.form.removeControl('data'); }
|
|
|
|
|
if (x === DatasetProfileComboBoxType.Autocomplete) {
|
|
|
|
|
this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm());
|
|
|
|
|
} else if (x === DatasetProfileComboBoxType.WordList) {
|
|
|
|
|
this.form.addControl('data', new WordListFieldDataEditorModel().buildForm());
|
2019-01-28 14:05:19 +01:00
|
|
|
|
}
|
2019-01-28 16:47:12 +01:00
|
|
|
|
this.setupListeners();
|
|
|
|
|
});
|
2019-01-18 18:03:45 +01:00
|
|
|
|
}
|
|
|
|
|
}
|