All files / lib/dynamic-form-field dynamic-form-field-base.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 13/13
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                                  67x 67x     6x 6x 6x   906x 65x   22x   1x 113x   5x 1x 91x     4x      
import { DynamicFormElementBase } from '../dynamic-form-element/dynamic-form-element-base';
import { DynamicFormValidationErrors } from '../dynamic-form-validation/dynamic-form-validation-errors';
import { DynamicFormValidationService } from '../dynamic-form-validation/dynamic-form-validation.service';
import { DynamicFormField } from './dynamic-form-field';
import { DynamicFormFieldControl } from './dynamic-form-field-control';
import { DynamicFormFieldDefinition } from './dynamic-form-field-definition';
import { DynamicFormFieldTemplate } from './dynamic-form-field-template';
 
export abstract class DynamicFormFieldBase<
  Value = any, Model extends Value = Value,
  Control extends DynamicFormFieldControl<Value> = DynamicFormFieldControl<Value>,
  Template extends DynamicFormFieldTemplate = DynamicFormFieldTemplate,
  Definition extends DynamicFormFieldDefinition<Value, Template> = DynamicFormFieldDefinition<Value, Template>,
  Field extends DynamicFormField<Value, Model, Control, Template, Definition> =
    DynamicFormField<Value, Model, Control, Template, Definition>
> extends DynamicFormElementBase<Template, Definition, Field> {
 
  constructor(protected validationService: DynamicFormValidationService) {
    super();
  }
 
  get key(): string { return this.element.key; }
  get index(): number { return this.element.index; }
  get path(): string { return this.element.path; }
 
  get field(): Field { return this.element; }
  set field(field: Field) { this.element = field; }
 
  get control(): Control { return this.field.control; }
 
  get disabled(): boolean { return this.field.disabled; }
  get readonly(): boolean { return this.field.readonly; }
 
  get errors(): DynamicFormValidationErrors { return this.field.errors; }
  get hasErrors(): boolean { return this.field.hasErrors; }
  get showErrors(): boolean { return this.field.showErrors; }
 
  get errorMessage(): string {
    return this.validationService.getErrorMessage(this.errors);
  }
}