@esfaenza/forms-and-validations 11.2.161 → 11.2.162
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/bundles/esfaenza-forms-and-validations.umd.js +23 -3
- package/bundles/esfaenza-forms-and-validations.umd.js.map +1 -1
- package/esfaenza-forms-and-validations.metadata.json +1 -1
- package/esm2015/lib/forms/form-autocomplete/form-autocomplete.component.js +23 -4
- package/fesm2015/esfaenza-forms-and-validations.js +22 -3
- package/fesm2015/esfaenza-forms-and-validations.js.map +1 -1
- package/lib/forms/form-autocomplete/form-autocomplete.component.d.ts +4 -0
- package/package.json +1 -1
|
@@ -3857,6 +3857,9 @@
|
|
|
3857
3857
|
_this.ignoreNextWriteValue = false;
|
|
3858
3858
|
/** Sorgente Bindata Filtrata in base al contenuto della casella di testo */
|
|
3859
3859
|
_this.FilteredBoundSource = [];
|
|
3860
|
+
_this.timer = null;
|
|
3861
|
+
_this.maxCallsPerSecond = 4;
|
|
3862
|
+
_this.callsDoneThisThreeSeconds = 0;
|
|
3860
3863
|
//******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
|
|
3861
3864
|
//TODO: spostarla in un metodo di utilità (esfaenza/extensions)
|
|
3862
3865
|
/** @ignore */
|
|
@@ -3869,7 +3872,7 @@
|
|
|
3869
3872
|
if (!value)
|
|
3870
3873
|
return;
|
|
3871
3874
|
if (this.SearchFunction) {
|
|
3872
|
-
this.
|
|
3875
|
+
this.doSearchProtected(value, true, this.SearchFunctionContext, function (t) {
|
|
3873
3876
|
_this.Source = t;
|
|
3874
3877
|
_this.tryBindSourceDisplay();
|
|
3875
3878
|
setTimeout(function () { _this.finalizeValue(value); });
|
|
@@ -3906,7 +3909,7 @@
|
|
|
3906
3909
|
var tmpModel = this.Model;
|
|
3907
3910
|
if (!tmpModel || !this.SearchFunction)
|
|
3908
3911
|
return;
|
|
3909
|
-
this.
|
|
3912
|
+
this.doSearchProtected(tmpModel, true, this.SearchFunctionContext, function (t) {
|
|
3910
3913
|
if (t && t.length > 0) {
|
|
3911
3914
|
_this.Source = t;
|
|
3912
3915
|
_this.tryBindSourceDisplay();
|
|
@@ -3944,7 +3947,7 @@
|
|
|
3944
3947
|
throw "Impossibile filtrare gli elementi senza una funzione di ricerca che restituisca una lista di { id: string, description: string }";
|
|
3945
3948
|
if (this.SearchFunction) {
|
|
3946
3949
|
this.throttla("filtersource", function () {
|
|
3947
|
-
_this.
|
|
3950
|
+
_this.doSearchProtected(event, false, _this.SearchFunctionContext, function (t) {
|
|
3948
3951
|
_this.Source = t;
|
|
3949
3952
|
_this.tryBindSourceDisplay();
|
|
3950
3953
|
// In questo caso è già filtrata dalla SearchFunction
|
|
@@ -3963,6 +3966,23 @@
|
|
|
3963
3966
|
}, 100);
|
|
3964
3967
|
}
|
|
3965
3968
|
};
|
|
3969
|
+
// Permetto al massimo 4 chiamate ogni 3 secondi, se nell'arco di 3 secondi ci sono più di 4 chiamate, ignoro le eccedenti
|
|
3970
|
+
FormAutocompleteComponent.prototype.doSearchProtected = function (search, byid, context, onRes) {
|
|
3971
|
+
var _this = this;
|
|
3972
|
+
if (!this.timer) {
|
|
3973
|
+
this.timer = setTimeout(function () {
|
|
3974
|
+
_this.callsDoneThisThreeSeconds = 0;
|
|
3975
|
+
clearTimeout(_this.timer);
|
|
3976
|
+
_this.timer = null;
|
|
3977
|
+
}, 3000);
|
|
3978
|
+
}
|
|
3979
|
+
if (this.callsDoneThisThreeSeconds >= this.maxCallsPerSecond)
|
|
3980
|
+
return;
|
|
3981
|
+
this.callsDoneThisThreeSeconds++;
|
|
3982
|
+
this.SearchFunction(search, byid, context).subscribe(function (t) {
|
|
3983
|
+
onRes(t);
|
|
3984
|
+
});
|
|
3985
|
+
};
|
|
3966
3986
|
/** @ignore */
|
|
3967
3987
|
FormAutocompleteComponent.prototype.removeFilteredSourceOnDescriptionSelection = function () {
|
|
3968
3988
|
var _this = this;
|