@stemy/ngx-dynamic-form 13.1.14 → 13.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/ngx-dynamic-form/common-types.mjs +1 -1
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form-control.component.mjs +14 -1
- package/esm2020/ngx-dynamic-form/directives/async-submit.directive.mjs +5 -1
- package/esm2020/ngx-dynamic-form/utils/validation-errors.mjs +27 -0
- package/fesm2015/stemy-ngx-dynamic-form.mjs +41 -0
- package/fesm2015/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/fesm2020/stemy-ngx-dynamic-form.mjs +41 -0
- package/fesm2020/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +2 -1
- package/ngx-dynamic-form/components/base/dynamic-base-form-control.component.d.ts +7 -2
- package/ngx-dynamic-form/utils/validation-errors.d.ts +11 -0
- package/package.json +1 -1
|
@@ -963,6 +963,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
963
963
|
args: [Injector]
|
|
964
964
|
}] }]; } });
|
|
965
965
|
|
|
966
|
+
function getFormValidationErrors(controls) {
|
|
967
|
+
let errors = [];
|
|
968
|
+
Object.keys(controls).forEach(key => {
|
|
969
|
+
const control = controls[key];
|
|
970
|
+
if (control instanceof FormGroup) {
|
|
971
|
+
errors = errors.concat(getFormValidationErrors(control.controls));
|
|
972
|
+
}
|
|
973
|
+
if (control instanceof FormArray) {
|
|
974
|
+
control.controls.forEach((control) => {
|
|
975
|
+
errors = errors.concat(getFormValidationErrors(control.controls));
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
if (control.errors !== null) {
|
|
979
|
+
Object.keys(control.errors).forEach(keyError => {
|
|
980
|
+
errors.push({
|
|
981
|
+
control,
|
|
982
|
+
control_name: key,
|
|
983
|
+
error_name: keyError,
|
|
984
|
+
error_value: control.errors[keyError]
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
return errors;
|
|
990
|
+
}
|
|
991
|
+
|
|
966
992
|
class AsyncSubmitDirective {
|
|
967
993
|
constructor(toaster, cdr, elem, renderer) {
|
|
968
994
|
this.toaster = toaster;
|
|
@@ -1014,6 +1040,9 @@ class AsyncSubmitDirective {
|
|
|
1014
1040
|
}
|
|
1015
1041
|
click() {
|
|
1016
1042
|
this.callback = () => this.callMethod();
|
|
1043
|
+
if (this.form.status === "INVALID") {
|
|
1044
|
+
console.log(getFormValidationErrors(this.form.group.controls));
|
|
1045
|
+
}
|
|
1017
1046
|
if (this.form.status !== "VALID" && this.form.status !== "INVALID")
|
|
1018
1047
|
return;
|
|
1019
1048
|
this.callback();
|
|
@@ -1455,6 +1484,18 @@ class DynamicBaseFormControlComponent extends DynamicFormControlComponent {
|
|
|
1455
1484
|
this.change = new EventEmitter();
|
|
1456
1485
|
this.focus = new EventEmitter();
|
|
1457
1486
|
}
|
|
1487
|
+
ngAfterViewInit() {
|
|
1488
|
+
this.subscription = this.control.valueChanges.pipe(debounceTime(500)).subscribe(value => {
|
|
1489
|
+
this.onValueChanged(value);
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
ngOnDestroy() {
|
|
1493
|
+
if (!this.subscription)
|
|
1494
|
+
return;
|
|
1495
|
+
this.subscription.unsubscribe();
|
|
1496
|
+
}
|
|
1497
|
+
onValueChanged(value) {
|
|
1498
|
+
}
|
|
1458
1499
|
}
|
|
1459
1500
|
DynamicBaseFormControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1460
1501
|
DynamicBaseFormControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormControlComponent, selector: "dynamic-base-form-control", inputs: { formLayout: "formLayout", group: "group", layout: "layout", model: "model" }, outputs: { blur: "blur", change: "change", focus: "focus" }, usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|