2019-01-18 18:03:45 +01:00
|
|
|
|
import { FormGroup } from "@angular/forms";
|
|
|
|
|
import { Rule } from "../../../../core/model/admin/dataset-profile/dataset-profile";
|
|
|
|
|
import { BaseFormModel } from "../../../../core/model/base-form-model";
|
|
|
|
|
|
|
|
|
|
export class RuleEditorModel extends BaseFormModel {
|
2018-10-05 17:00:54 +02:00
|
|
|
|
public target: string;
|
|
|
|
|
public value: string;
|
|
|
|
|
public ruleType: string;
|
|
|
|
|
public ruleStyle: string;
|
|
|
|
|
public valueType: string;
|
2018-02-02 11:57:24 +01:00
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
|
fromModel(item: Rule): RuleEditorModel {
|
2018-10-05 17:00:54 +02:00
|
|
|
|
this.target = item.target;
|
|
|
|
|
this.value = item.value;
|
|
|
|
|
this.ruleType = item.ruleType;
|
|
|
|
|
this.ruleStyle = item.ruleStyle;
|
|
|
|
|
this.valueType = item.valueType;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2018-02-02 11:57:24 +01:00
|
|
|
|
|
2019-04-16 12:49:09 +02:00
|
|
|
|
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
2018-10-05 17:00:54 +02:00
|
|
|
|
const formGroup = this.formBuilder.group({
|
2019-01-18 18:03:45 +01:00
|
|
|
|
// sourceField: [this.sourceField],
|
2019-04-16 12:49:09 +02:00
|
|
|
|
target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }],
|
|
|
|
|
ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }],
|
|
|
|
|
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }],
|
|
|
|
|
ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }],
|
|
|
|
|
valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }]
|
2018-10-05 17:00:54 +02:00
|
|
|
|
});
|
|
|
|
|
return formGroup;
|
|
|
|
|
}
|
|
|
|
|
}
|