@esfaenza/forms-and-validations 15.2.55 → 15.2.57

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.
@@ -3791,18 +3791,22 @@ class FormAutocompleteComponent extends BaseFormControl {
3791
3791
  onFailure?.();
3792
3792
  return;
3793
3793
  }
3794
- this.doSearchProtected(tmpModel, true, this.SearchFunctionContext, (t) => {
3795
- if (t && t.length > 0) {
3796
- this.Source = t;
3797
- this.tryBindSourceDisplay();
3798
- if (!this.Multi)
3799
- setTimeout(() => { this.finalizeValue(tmpModel); });
3794
+ this.log("filtersource enqueue");
3795
+ this.throttla("filtersource", () => {
3796
+ this.log("filtersource fire");
3797
+ this.doSearchProtected(tmpModel, true, this.SearchFunctionContext, (t) => {
3798
+ if (t && t.length > 0) {
3799
+ this.Source = t;
3800
+ this.tryBindSourceDisplay();
3801
+ if (!this.Multi)
3802
+ setTimeout(() => { this.finalizeValue(tmpModel); });
3803
+ else
3804
+ this.cdr.markForCheck();
3805
+ }
3800
3806
  else
3801
- this.cdr.markForCheck();
3802
- }
3803
- else
3804
- onFailure?.();
3805
- });
3807
+ onFailure?.();
3808
+ });
3809
+ }, 400);
3806
3810
  }
3807
3811
  /**
3808
3812
  * Evento di filtro della sorgente dati in base all'input utente
@@ -3831,6 +3835,7 @@ class FormAutocompleteComponent extends BaseFormControl {
3831
3835
  return;
3832
3836
  }
3833
3837
  if (!event || event.length < this.MinChars) {
3838
+ this.log("search event ignored: " + event);
3834
3839
  this.FilteredBoundSource = [];
3835
3840
  this.cdr.markForCheck();
3836
3841
  return;
@@ -3838,8 +3843,11 @@ class FormAutocompleteComponent extends BaseFormControl {
3838
3843
  if (!this.SearchFunction && (!this.Source || this.Source.length == 0))
3839
3844
  throw "Impossibile filtrare gli elementi senza una funzione di ricerca che restituisca una lista di { id: string, description: string }";
3840
3845
  if (this.SearchFunction) {
3846
+ this.log("filtersource enqueue");
3841
3847
  this.throttla("filtersource", () => {
3848
+ this.log("filtersource fire");
3842
3849
  this.doSearchProtected(event, false, this.SearchFunctionContext, (t) => {
3850
+ this.log("filtersource received API response");
3843
3851
  this.Source = t;
3844
3852
  this.tryBindSourceDisplay();
3845
3853
  // In questo caso è già filtrata dalla SearchFunction
@@ -3851,6 +3859,7 @@ class FormAutocompleteComponent extends BaseFormControl {
3851
3859
  }
3852
3860
  else {
3853
3861
  this.throttla("filtersource", () => {
3862
+ this.log("filtersource fire");
3854
3863
  // In questo caso devo filtrare io in memoria
3855
3864
  this.FilteredBoundSource = this.BoundSource.filter(t => (this.CaseSensitive && t.description.includes(event)) || (!this.CaseSensitive && t.description.toLowerCase().includes(event.toLowerCase())));
3856
3865
  this.removeFilteredSourceOnDescriptionSelection();
@@ -3867,9 +3876,12 @@ class FormAutocompleteComponent extends BaseFormControl {
3867
3876
  this.timer = null;
3868
3877
  }, 3000);
3869
3878
  }
3870
- if (this.callsDoneThisThreeSeconds >= this.maxCallsPerSecond)
3879
+ if (this.callsDoneThisThreeSeconds >= this.maxCallsPerSecond) {
3880
+ this.log("Ignoring excessive calls");
3871
3881
  return;
3882
+ }
3872
3883
  this.callsDoneThisThreeSeconds++;
3884
+ this.log("Search function being called...");
3873
3885
  this.SearchFunction(search, byid, context).subscribe(t => {
3874
3886
  onRes(t);
3875
3887
  });