@esfaenza/es-table 20.3.16 → 20.3.17
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.
|
@@ -6593,6 +6593,11 @@ class EsTable2Component {
|
|
|
6593
6593
|
// ===========================================================================
|
|
6594
6594
|
this.onChange = () => { };
|
|
6595
6595
|
this.onTouched = () => { };
|
|
6596
|
+
// ===========================================================================
|
|
6597
|
+
// ControlValueAccessor
|
|
6598
|
+
// ===========================================================================
|
|
6599
|
+
/** Timeout di debounce del writeValue in modalità EsTableHandledSearch */
|
|
6600
|
+
this.searchCallTimeout = null;
|
|
6596
6601
|
/** Ancora per la selezione a range stile Windows (Shift+click) */
|
|
6597
6602
|
this.selectionAnchor = null;
|
|
6598
6603
|
// ===========================================================================
|
|
@@ -6670,6 +6675,8 @@ class EsTable2Component {
|
|
|
6670
6675
|
this.headerRO?.disconnect();
|
|
6671
6676
|
if (this.noticeTimer)
|
|
6672
6677
|
clearTimeout(this.noticeTimer);
|
|
6678
|
+
if (this.searchCallTimeout)
|
|
6679
|
+
clearTimeout(this.searchCallTimeout);
|
|
6673
6680
|
}
|
|
6674
6681
|
/** Risoluzione input: valore esplicito || default di progetto || hard default */
|
|
6675
6682
|
io(v, d, hard) {
|
|
@@ -6680,10 +6687,17 @@ class EsTable2Component {
|
|
|
6680
6687
|
this.thDirectives?.changes.subscribe(() => { this.buildColumns(); this.refresh(); });
|
|
6681
6688
|
this.tdDirectives?.changes.subscribe(() => { this.buildColumns(); this.refresh(); });
|
|
6682
6689
|
}
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6690
|
+
writeValue(obj, throttle = true) {
|
|
6691
|
+
// Modalità EsTableHandledSearch: il writeValue viene debouncato (come l'originale),
|
|
6692
|
+
// così binding ravvicinati non generano ricerche a raffica.
|
|
6693
|
+
if (this.EsTableHandledSearch() && throttle) {
|
|
6694
|
+
if (this.searchCallTimeout)
|
|
6695
|
+
clearTimeout(this.searchCallTimeout);
|
|
6696
|
+
this.searchCallTimeout = setTimeout(() => this.writeValue(obj, false), this.SearchThrottle());
|
|
6697
|
+
return;
|
|
6698
|
+
}
|
|
6699
|
+
// È arrivato un nuovo modello → nessuna ricerca "in progress"
|
|
6700
|
+
this.researchInProgress.set(false);
|
|
6687
6701
|
this.view.set(obj ?? null);
|
|
6688
6702
|
this.detectMode(obj);
|
|
6689
6703
|
this.syncOrdersFromView();
|
|
@@ -6691,11 +6705,59 @@ class EsTable2Component {
|
|
|
6691
6705
|
if (obj)
|
|
6692
6706
|
this.firstBind.set(false);
|
|
6693
6707
|
this.cdr.markForCheck();
|
|
6708
|
+
// Auto-ricerca: la valorizzazione dell'ngModel chiede al consumer di cercare
|
|
6709
|
+
// (storicamente serviva ad applicare le preferenze colonne senza che il modello
|
|
6710
|
+
// in arrivo le sovrascrivesse). Il flag `selfsearch` evita loop; `firstsearch`
|
|
6711
|
+
// (true su `new AppSearch()`) salta l'auto-ricerca al primo bind.
|
|
6712
|
+
this.handleWriteValueAutoSearch();
|
|
6694
6713
|
}
|
|
6695
6714
|
registerOnChange(fn) { this.onChange = fn; }
|
|
6696
6715
|
registerOnTouched(fn) { this.onTouched = fn; }
|
|
6697
6716
|
setDisabledState() { }
|
|
6698
|
-
|
|
6717
|
+
/** Blocco auto-ricerca a fine writeValue (modalità EsTableHandledSearch) */
|
|
6718
|
+
handleWriteValueAutoSearch() {
|
|
6719
|
+
if (!this.EsTableHandledSearch() || !this.view())
|
|
6720
|
+
return;
|
|
6721
|
+
const v = this.view();
|
|
6722
|
+
if (!v.selfsearch && !v.firstsearch) {
|
|
6723
|
+
v.selfsearch = true;
|
|
6724
|
+
this.changed(true); // svuota gli items + propaga (mostra "vuoto" mentre cerca)
|
|
6725
|
+
this.onSearchRequest.emit(false);
|
|
6726
|
+
}
|
|
6727
|
+
else if (v.selfsearch) {
|
|
6728
|
+
v.selfsearch = false; // ricerca rientrata: azzero il guard
|
|
6729
|
+
this.changed();
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
/**
|
|
6733
|
+
* Richiesta di ricerca (paging/ordinamento). In modalità EsTableHandledSearch
|
|
6734
|
+
* imposta il guard `selfsearch` così il writeValue di rientro non ri-cerca.
|
|
6735
|
+
*/
|
|
6736
|
+
emitSearchRequest(arg) {
|
|
6737
|
+
this.researchInProgress.set(true);
|
|
6738
|
+
const v = this.view();
|
|
6739
|
+
if (v && !v.selfsearch && this.EsTableHandledSearch()) {
|
|
6740
|
+
v.selfsearch = true;
|
|
6741
|
+
this.changed(true);
|
|
6742
|
+
this.onSearchRequest.emit(false);
|
|
6743
|
+
}
|
|
6744
|
+
else {
|
|
6745
|
+
this.onSearchRequest.emit(arg);
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
changed(clearItems = false) {
|
|
6749
|
+
if (clearItems && this.viewMode()) {
|
|
6750
|
+
const isp = this.ItemSourceProperty();
|
|
6751
|
+
const v = this.view();
|
|
6752
|
+
if (v) {
|
|
6753
|
+
if (!isp)
|
|
6754
|
+
v.items = [];
|
|
6755
|
+
else
|
|
6756
|
+
v[isp] = [];
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
this.onChange(this.view());
|
|
6760
|
+
}
|
|
6699
6761
|
// ===========================================================================
|
|
6700
6762
|
// Mode & column model
|
|
6701
6763
|
// ===========================================================================
|
|
@@ -7098,7 +7160,7 @@ class EsTable2Component {
|
|
|
7098
7160
|
v.orders = list;
|
|
7099
7161
|
v.internalsearchrequest = true;
|
|
7100
7162
|
this.onOrderChanged.emit(new AppOrdering(col.id, next ?? undefined));
|
|
7101
|
-
this.
|
|
7163
|
+
this.emitSearchRequest(false);
|
|
7102
7164
|
}
|
|
7103
7165
|
else {
|
|
7104
7166
|
this.refresh();
|
|
@@ -7119,7 +7181,7 @@ class EsTable2Component {
|
|
|
7119
7181
|
const v = this.view();
|
|
7120
7182
|
v.page = p;
|
|
7121
7183
|
v.internalsearchrequest = true;
|
|
7122
|
-
this.
|
|
7184
|
+
this.emitSearchRequest(false);
|
|
7123
7185
|
}
|
|
7124
7186
|
else {
|
|
7125
7187
|
this.arrayPage.set(p);
|
|
@@ -7133,7 +7195,7 @@ class EsTable2Component {
|
|
|
7133
7195
|
v.itemsperpageoverride = n;
|
|
7134
7196
|
v.page = 1;
|
|
7135
7197
|
v.internalsearchrequest = true;
|
|
7136
|
-
this.
|
|
7198
|
+
this.emitSearchRequest(false);
|
|
7137
7199
|
}
|
|
7138
7200
|
else {
|
|
7139
7201
|
this.ArraymodeItemsPerPage.set(n);
|