@rxap/forms 13.0.4 → 13.0.6
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/fesm2020/rxap-forms.mjs
CHANGED
|
@@ -1235,6 +1235,12 @@ class FormDirective extends FormGroupDirective {
|
|
|
1235
1235
|
return this._formDefinition;
|
|
1236
1236
|
}
|
|
1237
1237
|
ngOnChanges(changes) {
|
|
1238
|
+
// depending on the usage the member from is set after another member
|
|
1239
|
+
// triggers the ngOnChanges hook. to prevent an "angular" exception
|
|
1240
|
+
// the ngOnChanges is skipped if the member form is not set
|
|
1241
|
+
if (!this.form) {
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1238
1244
|
super.ngOnChanges(changes);
|
|
1239
1245
|
const formChange = changes.form;
|
|
1240
1246
|
if (formChange && !formChange.firstChange) {
|
|
@@ -1242,10 +1248,14 @@ class FormDirective extends FormGroupDirective {
|
|
|
1242
1248
|
}
|
|
1243
1249
|
}
|
|
1244
1250
|
ngOnInit() {
|
|
1245
|
-
if (!this.
|
|
1251
|
+
if (!this._formDefinition) {
|
|
1246
1252
|
// TODO : replace with rxap error
|
|
1247
1253
|
throw new Error('The form definition instance is not defined');
|
|
1248
1254
|
}
|
|
1255
|
+
if (!this.form) {
|
|
1256
|
+
// TODO : replace with rxap error
|
|
1257
|
+
throw new Error('The form instance is not defined');
|
|
1258
|
+
}
|
|
1249
1259
|
this.loadInitialState(this.form);
|
|
1250
1260
|
function HasNgOnInitMethod(obj) {
|
|
1251
1261
|
return obj && typeof obj.ngOnInit === 'function';
|
|
@@ -1257,8 +1267,14 @@ class FormDirective extends FormGroupDirective {
|
|
|
1257
1267
|
const debounce = typeof this._formDefinition.rxapMetadata.autoSubmit === 'number'
|
|
1258
1268
|
? this._formDefinition.rxapMetadata.autoSubmit
|
|
1259
1269
|
: 5000;
|
|
1260
|
-
this._autoSubmitSubscription = this
|
|
1261
|
-
.
|
|
1270
|
+
this._autoSubmitSubscription = this
|
|
1271
|
+
.form
|
|
1272
|
+
.valueChanges
|
|
1273
|
+
.pipe(debounceTime(debounce), filter(() => this.form.valid), tap((value) => {
|
|
1274
|
+
if (isDevMode()) {
|
|
1275
|
+
console.debug(`Auto submit form '${this._formDefinition.rxapMetadata.id}'`, value);
|
|
1276
|
+
}
|
|
1277
|
+
}), tap(() => this.submit()))
|
|
1262
1278
|
.subscribe();
|
|
1263
1279
|
}
|
|
1264
1280
|
}
|