@stemy/ngx-dynamic-form 13.1.17 → 13.1.19

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.
@@ -4,11 +4,11 @@ import { __decorate } from 'tslib';
4
4
  import * as i1 from '@ng-dynamic-forms/core';
5
5
  import { DynamicInputControlModel, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, serializable, DynamicFormArrayGroupModel as DynamicFormArrayGroupModel$1, DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormOption as DynamicFormOption$1, DynamicSelectModel as DynamicSelectModel$1, DynamicFormService as DynamicFormService$1, DynamicDatePickerModel, DynamicFormGroupModel, DynamicInputModel, DynamicFormValueControlModel, DynamicFileUploadModel, DynamicCheckboxModel, DynamicTextAreaModel, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormArrayComponent, DynamicFormControlComponent, DynamicFormGroupComponent, DYNAMIC_FORM_CONTROL_MAP_FN, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
6
6
  export { DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP, DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, DYNAMIC_FORM_CONTROL_TYPE_FILE_UPLOAD, DYNAMIC_FORM_CONTROL_TYPE_GROUP, DYNAMIC_FORM_CONTROL_TYPE_INPUT, DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP, DYNAMIC_FORM_CONTROL_TYPE_SELECT, DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA, DynamicCheckboxGroupModel, DynamicCheckboxModel, DynamicDatePickerModel, DynamicFileUploadModel, DynamicFormControlComponent, DynamicFormGroupModel, DynamicFormsCoreModule, DynamicInputModel, DynamicListDirective, DynamicRadioGroupModel, DynamicTemplateDirective, DynamicTextAreaModel } from '@ng-dynamic-forms/core';
7
- import { BehaviorSubject, of, isObservable, map, Subject, firstValueFrom, Subscription, debounceTime, groupBy, mergeMap } from 'rxjs';
7
+ import { BehaviorSubject, of, isObservable, map, Subject, firstValueFrom, Subscription, debounceTime as debounceTime$1, groupBy, mergeMap } from 'rxjs';
8
8
  import * as i0 from '@angular/core';
9
9
  import { Injector, Injectable, Inject, EventEmitter, Directive, Input, Output, HostBinding, HostListener, QueryList, Component, ChangeDetectionStrategy, ContentChildren, ViewChildren, ViewContainerRef, ViewChild, forwardRef, NgModule } from '@angular/core';
10
10
  import { FormGroup, FormArray, FormsModule, ReactiveFormsModule, NG_VALIDATORS } from '@angular/forms';
11
- import { first } from 'rxjs/operators';
11
+ import { debounceTime, first } from 'rxjs/operators';
12
12
  import { CommonModule } from '@angular/common';
13
13
 
14
14
  // --- Decorator functions ---
@@ -729,6 +729,7 @@ class DynamicFormService extends DynamicFormService$1 {
729
729
  const subSchemas = findRefs(property).map(ref => this.schemas[ref]);
730
730
  return Object.assign(this.getFormControlConfig(property, schema), {
731
731
  groupFactory: () => mergeFormModels(subSchemas.map(s => this.getFormModelForSchemaDef(s, customizeModels))),
732
+ initialCount: property.initialCount || 0,
732
733
  sortable: property.sortable || false,
733
734
  useTabs: property.useTabs || false,
734
735
  addItem: property.addItem !== false,
@@ -853,10 +854,14 @@ class DynamicFormService extends DynamicFormService$1 {
853
854
  }
854
855
  return new FormSelectSubject(async (selectModel, control) => {
855
856
  this.api.cache[property.endpoint] = this.api.cache[property.endpoint] || this.api.list(property.endpoint, this.api.makeListParams(1, -1)).then(result => {
856
- return result.items.map(i => {
857
+ const items = ObjectUtils.isArray(result)
858
+ ? result
859
+ : (ObjectUtils.isArray(result.items) ? result.items : []);
860
+ return items.map(i => {
861
+ const item = ObjectUtils.isObject(i) ? i : { id: i };
857
862
  return {
858
- ...i,
859
- value: i.id || i._id, label: i[property.labelField] || i.label || i.id || i._id
863
+ ...item,
864
+ value: item.id || item._id, label: item[property.labelField] || item.label || item.id || item._id
860
865
  };
861
866
  });
862
867
  });
@@ -1030,7 +1035,7 @@ class AsyncSubmitDirective {
1030
1035
  }
1031
1036
  this.callback = null;
1032
1037
  });
1033
- this.onSubmit = this.form.onSubmit.subscribe(() => this.callMethod());
1038
+ this.onSubmit = this.form.onSubmit.pipe(debounceTime(200)).subscribe(() => this.callMethod());
1034
1039
  }
1035
1040
  ngOnDestroy() {
1036
1041
  if (this.onStatusChange)
@@ -1129,10 +1134,10 @@ class DynamicBaseFormComponent extends DynamicFormComponent {
1129
1134
  if (this.group) {
1130
1135
  this.groupSubscription = ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(() => {
1131
1136
  this.onStatusChange.emit(this);
1132
- }), this.group.valueChanges.pipe(debounceTime(500)).subscribe(() => {
1137
+ }), this.group.valueChanges.pipe(debounceTime$1(500)).subscribe(() => {
1133
1138
  this.formService.notifyChanges(this.model, this.group);
1134
1139
  }), this.change.pipe(groupBy(ev => ev.model))
1135
- .pipe(mergeMap(t => t.pipe(debounceTime(500))))
1140
+ .pipe(mergeMap(t => t.pipe(debounceTime$1(500))))
1136
1141
  .subscribe(ev => {
1137
1142
  this.onValueChange.emit({ ...ev, form: this });
1138
1143
  }));
@@ -1475,15 +1480,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
1475
1480
  }] } });
1476
1481
 
1477
1482
  class DynamicBaseFormControlComponent extends DynamicFormControlComponent {
1478
- constructor(cdr, layoutService, validationService) {
1483
+ constructor(layoutService, validationService, form, injector, cdr) {
1479
1484
  super(layoutService, validationService);
1485
+ this.form = form;
1486
+ this.injector = injector;
1480
1487
  this.cdr = cdr;
1481
1488
  this.blur = new EventEmitter();
1482
1489
  this.change = new EventEmitter();
1483
1490
  this.focus = new EventEmitter();
1484
1491
  }
1485
1492
  ngAfterViewInit() {
1486
- this.subscription = this.control.valueChanges.pipe(debounceTime(500)).subscribe(value => {
1493
+ this.subscription = this.control.valueChanges.pipe(debounceTime$1(500)).subscribe(value => {
1487
1494
  this.onValueChanged(value);
1488
1495
  });
1489
1496
  }
@@ -1492,10 +1499,13 @@ class DynamicBaseFormControlComponent extends DynamicFormControlComponent {
1492
1499
  return;
1493
1500
  this.subscription.unsubscribe();
1494
1501
  }
1502
+ submit() {
1503
+ this.form.submit();
1504
+ }
1495
1505
  onValueChanged(value) {
1496
1506
  }
1497
1507
  }
1498
- 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 });
1508
+ DynamicBaseFormControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlComponent, deps: [{ token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }, { token: DynamicBaseFormComponent }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1499
1509
  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 });
1500
1510
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlComponent, decorators: [{
1501
1511
  type: Component,
@@ -1504,7 +1514,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
1504
1514
  template: "",
1505
1515
  changeDetection: ChangeDetectionStrategy.OnPush
1506
1516
  }]
1507
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }]; }, propDecorators: { formLayout: [{
1517
+ }], ctorParameters: function () { return [{ type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }, { type: DynamicBaseFormComponent }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { formLayout: [{
1508
1518
  type: Input
1509
1519
  }], group: [{
1510
1520
  type: Input