2021-04-06 08:57:17 +02:00
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { FieldDataOption } from '../../../../../core/model/dataset-profile-definition/field-data/field-data';
|
|
|
|
import { FieldDataEditorModel } from './field-data-editor-model';
|
|
|
|
|
|
|
|
export class FieldDataOptionEditorModel extends FieldDataEditorModel<FieldDataOptionEditorModel> {
|
|
|
|
public label: string;
|
|
|
|
public value: string;
|
2019-09-10 17:30:46 +02:00
|
|
|
public source: string;
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2019-04-16 12:49:09 +02:00
|
|
|
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
2019-01-18 18:03:45 +01:00
|
|
|
return new FormBuilder().group({
|
2021-04-06 08:57:17 +02:00
|
|
|
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.label')) },[Validators.required]],
|
|
|
|
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) },[Validators.required]],
|
2019-09-10 17:30:46 +02:00
|
|
|
source: [{ value: this.source, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.source')) }]
|
2019-01-18 18:03:45 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fromModel(item: FieldDataOption): FieldDataOptionEditorModel {
|
2020-09-18 17:53:05 +02:00
|
|
|
if (item) {
|
|
|
|
this.label = item.label;
|
|
|
|
this.value = item.value;
|
|
|
|
this.source = item.source;
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|