@3kles/kles-material-dynamicforms 14.2.1 → 14.3.0
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/lib/dynamic-form.component.mjs +14 -2
- package/esm2020/lib/fields/select.search.component.mjs +3 -3
- package/esm2020/lib/interfaces/field.config.interface.mjs +1 -1
- package/fesm2015/3kles-kles-material-dynamicforms.mjs +15 -5
- package/fesm2015/3kles-kles-material-dynamicforms.mjs.map +1 -1
- package/fesm2020/3kles-kles-material-dynamicforms.mjs +15 -5
- package/fesm2020/3kles-kles-material-dynamicforms.mjs.map +1 -1
- package/lib/interfaces/field.config.interface.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ import * as i1 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i2 from '@angular/forms';
|
|
6
6
|
import { Validators, NG_VALUE_ACCESSOR, UntypedFormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
7
|
+
import { concat, of, Subject, Observable, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
8
|
+
import { take, catchError, map, takeUntil, startWith, switchMap } from 'rxjs/operators';
|
|
7
9
|
import * as i7$1 from '@angular/material/core';
|
|
8
10
|
import { MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatNativeDateModule, MatOption, ErrorStateMatcher } from '@angular/material/core';
|
|
9
11
|
import { MatSliderModule } from '@angular/material/slider';
|
|
@@ -61,8 +63,6 @@ import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
|
61
63
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
62
64
|
import * as i7 from '@ngx-translate/core';
|
|
63
65
|
import { TranslateModule } from '@ngx-translate/core';
|
|
64
|
-
import { Subject, Observable, of, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
65
|
-
import { takeUntil, startWith, switchMap, map, take } from 'rxjs/operators';
|
|
66
66
|
import * as i3 from '@angular/flex-layout/extended';
|
|
67
67
|
import { __decorate } from 'tslib';
|
|
68
68
|
import * as i3$1 from '@angular/flex-layout/flex';
|
|
@@ -305,7 +305,6 @@ class KlesDynamicFormComponent {
|
|
|
305
305
|
if (field.disabled) {
|
|
306
306
|
range.disable();
|
|
307
307
|
}
|
|
308
|
-
console.log(range);
|
|
309
308
|
return range;
|
|
310
309
|
}
|
|
311
310
|
else {
|
|
@@ -317,6 +316,17 @@ class KlesDynamicFormComponent {
|
|
|
317
316
|
if (field.disabled) {
|
|
318
317
|
control.disable();
|
|
319
318
|
}
|
|
319
|
+
if (field.asyncValue) {
|
|
320
|
+
concat(of({ value: null, pending: true }), field.asyncValue.pipe(take(1), catchError((err) => {
|
|
321
|
+
console.error(err);
|
|
322
|
+
return of(null);
|
|
323
|
+
}), map((value) => ({ value, pending: false })))).subscribe((response) => {
|
|
324
|
+
response.pending ? control.disable({ emitEvent: false }) : control.enable({ emitEvent: false });
|
|
325
|
+
control.setValue(response.value);
|
|
326
|
+
field.pending = response.pending;
|
|
327
|
+
field.value = response.value;
|
|
328
|
+
});
|
|
329
|
+
}
|
|
320
330
|
return control;
|
|
321
331
|
}
|
|
322
332
|
}
|
|
@@ -2359,8 +2369,8 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
|
|
|
2359
2369
|
})).subscribe(this.optionsFiltered$);
|
|
2360
2370
|
if (this.field.multiple) {
|
|
2361
2371
|
this.group.controls[this.field.name]
|
|
2362
|
-
.valueChanges.pipe(takeUntil(this._onDestroy), startWith(this.group.controls[this.field.name].value), switchMap(selected => {
|
|
2363
|
-
return this.optionsFiltered$.pipe(map((options) => options?.filter((option) => !option?.disabled)), map(options => {
|
|
2372
|
+
.valueChanges.pipe(takeUntil(this._onDestroy), startWith(this.group.controls[this.field.name].value), map((selected) => (this.field.property ? selected?.map(s => s[this.field.property]) : selected)), switchMap(selected => {
|
|
2373
|
+
return this.optionsFiltered$.pipe(map((options) => options?.filter((option) => !option?.disabled).map((option) => (this.field.property ? option[this.field.property] : option))), map(options => {
|
|
2364
2374
|
if (!selected) {
|
|
2365
2375
|
return false;
|
|
2366
2376
|
}
|