|
@@ -1,5 +1,5 @@
|
|
|
import { Component, Input, Output, EventEmitter, TemplateRef, Optional, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
|
|
-import { FormGroup, FormGroupName, AbstractControl, ControlContainer } from '@angular/forms';
|
|
|
+import { FormControl, FormGroup, FormGroupName, AbstractControl, ControlContainer } from '@angular/forms';
|
|
|
import { SuperForm } from 'angular-super-validator';
|
|
|
|
|
|
export interface DynarowContext {
|
|
@@ -122,8 +122,17 @@ export class DynaformComponent implements OnInit {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- getRowClass(inputType: string): string {
|
|
|
- return `row-${inputType.toLowerCase().replace('component', '')}`;
|
|
|
+ getRowClass(control: FormControl, inputType: string): string {
|
|
|
+ const errorClass = control && control.touched && control.invalid ? ' dyna-error' : '';
|
|
|
+ return `row-${inputType.toLowerCase().replace('component', '')}${errorClass}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ getValidationFailureMessage(control: FormControl, meta: StringMap) {
|
|
|
+ if (control.errors) {
|
|
|
+ const errKeys = Object.keys(control.errors);
|
|
|
+ console.log(errKeys);
|
|
|
+ return meta.valFailureMessages[errKeys[0]];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
getValidationErrors() {
|
|
@@ -134,7 +143,7 @@ export class DynaformComponent implements OnInit {
|
|
|
return 'No Errors';
|
|
|
}
|
|
|
|
|
|
- handle(fnId: string) {
|
|
|
+ handleCallback(fnId: string) {
|
|
|
this.call.emit(fnId);
|
|
|
}
|
|
|
|