import { FormGroup } from '@angular/forms';
import { Multiplicity } from '../../../../core/model/admin/dataset-profile/dataset-profile';
import { BaseFormModel } from '../../../../core/model/base-form-model';

export class MultiplicityEditorModel extends BaseFormModel {
	public min: number;
	public max: number;

	fromModel(item: Multiplicity): MultiplicityEditorModel {
		this.min = item.min;
		this.max = item.max;
		return this;
	}

	buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
		const formGroup = this.formBuilder.group({
			min: [{ value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min')) }],
			max: [{ value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max')) }]
		});
		return formGroup;
	}
}
