@fluxhub/fluxhub-lib 22.0.32 → 22.0.33

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.
@@ -10694,19 +10694,52 @@ class FHGridComponent {
10694
10694
  this.command.emit(o);
10695
10695
  }
10696
10696
  b_ensure = false;
10697
+ // Le chiavi _POS/_POS2/_LAST_ROW non si cancellano dopo il ripristino: anche un
10698
+ // secondo aggiornamento della pagina deve tornare sull'ultima riga cliccata.
10697
10699
  ensure_visible() {
10698
- if (this.b_ensure)
10700
+ if (this.b_ensure || this.b_row_restored)
10699
10701
  return;
10700
10702
  this.b_ensure = true;
10701
10703
  try {
10702
- if (localStorage.getItem(this.grid_customer_preference_key + '_POS') != null) {
10703
- if (this.gridApi)
10704
- this.gridApi.ensureIndexVisible(parseInt(localStorage.getItem(this.grid_customer_preference_key + '_POS') || '0'));
10705
- localStorage.removeItem(this.grid_customer_preference_key + '_POS');
10706
- }
10704
+ const pos = localStorage.getItem(this.grid_customer_preference_key + '_POS');
10705
+ if (pos != null && this.gridApi)
10706
+ this.gridApi.ensureIndexVisible(parseInt(pos) || 0, 'middle');
10707
10707
  }
10708
10708
  catch (e) { }
10709
10709
  }
10710
+ b_row_restored = false;
10711
+ /**
10712
+ * Riposiziona la grid sull'ultima riga cliccata (una volta per istanza). Chiamata a ogni
10713
+ * blocco caricato dal server: se la riga sta in un blocco successivo la trova quando
10714
+ * ensure_visible() lo fa caricare. Cerca per id (gridOptions.getRowId) e, per le righe
10715
+ * senza chiave (id generato a caso), confronta i dati con _LAST_ROW.
10716
+ */
10717
+ restore_last_row() {
10718
+ if (this.b_row_restored || !this.gridApi)
10719
+ return;
10720
+ const id = localStorage.getItem(this.grid_customer_preference_key + '_POS2');
10721
+ const raw = localStorage.getItem(this.grid_customer_preference_key + '_LAST_ROW');
10722
+ if (id == null && (raw == null || raw === 'undefined'))
10723
+ return;
10724
+ let node = id != null ? this.gridApi.getRowNode(id) : null;
10725
+ if (node == null && raw != null)
10726
+ this.gridApi.forEachNode((n) => {
10727
+ if (node == null && n.data != null && JSON.stringify(n.data) === raw)
10728
+ node = n;
10729
+ });
10730
+ if (node == null || node.rowIndex == null)
10731
+ return;
10732
+ this.b_row_restored = true;
10733
+ this.sRow = node.data;
10734
+ if (this.selection_mode?.enableClickSelection)
10735
+ node.setSelected(true, true);
10736
+ this.gridApi.ensureNodeVisible(node, 'middle');
10737
+ // focus sulla prima colonna con dati, non su quella delle checkbox (si vedrebbe appena)
10738
+ const cols = this.gridApi.getAllDisplayedColumns();
10739
+ const col = cols.find((c) => c.getColDef()?.field) || cols[0];
10740
+ if (col)
10741
+ this.gridApi.setFocusedCell(node.rowIndex, col);
10742
+ }
10710
10743
  gf = null;
10711
10744
  toggle_mantieni = null;
10712
10745
  ck_flag() {
@@ -11036,21 +11069,7 @@ class FHGridComponent {
11036
11069
  this.fill_end.emit();
11037
11070
  this.check_width();
11038
11071
  localStorage.setItem(this.grid_customer_preference_key + '_POS1', JSON.stringify(p));
11039
- if (localStorage.getItem(this.grid_customer_preference_key + '_POS2') != null)
11040
- if (this.gridOptions != null)
11041
- if (this.gridApi != null)
11042
- this.gridApi.forEachNode((node) => {
11043
- if (this.getRowId(node) ===
11044
- localStorage.getItem(this.grid_customer_preference_key + '_POS2')) {
11045
- node.setSelected(true);
11046
- localStorage.removeItem(this.grid_customer_preference_key + '_POS2');
11047
- if (localStorage.getItem(this.grid_customer_preference_key + '_LAST_ROW') != null)
11048
- this.sRow = this.read_last_row();
11049
- else
11050
- this.sRow = null;
11051
- localStorage.removeItem(this.grid_customer_preference_key + '_LAST_ROW');
11052
- }
11053
- });
11072
+ this.restore_last_row();
11054
11073
  let b_mantieni_ck = false;
11055
11074
  if (this.toggle_mantieni != null)
11056
11075
  b_mantieni_ck = this.toggle_mantieni.checked;
@@ -11279,19 +11298,6 @@ class FHGridComponent {
11279
11298
  }
11280
11299
  };
11281
11300
  }
11282
- getRowId(item) {
11283
- if (item == null)
11284
- return this.uti_s.newGuid();
11285
- if (item.data == null)
11286
- return this.uti_s.newGuid();
11287
- if (item.data.id != null)
11288
- return String(item.data.id);
11289
- if (item.data.uiid != null)
11290
- return item.data.uiid;
11291
- if (item.data.codice != null)
11292
- return item.data.codice;
11293
- return this.uti_s.newGuid();
11294
- }
11295
11301
  agGrid;
11296
11302
  b_init = false;
11297
11303
  b_init1 = false;
@@ -12160,18 +12166,17 @@ class FHGridComponent {
12160
12166
  return;
12161
12167
  if (this.isTotalsRow($event))
12162
12168
  return;
12163
- var selectedInGrid;
12164
- if (this.gridApi)
12165
- selectedInGrid = this.gridApi.getSelectedNodes();
12166
- if (selectedInGrid != null)
12167
- if (selectedInGrid[0] != null) {
12168
- localStorage.setItem(this.grid_customer_preference_key + '_POS', String(selectedInGrid[0].rowIndex));
12169
- if (this.gridApi)
12170
- localStorage.setItem(this.grid_customer_preference_key + '_POS_BAR', JSON.stringify(this.gridApi.getVerticalPixelRange()));
12171
- localStorage.setItem(this.grid_customer_preference_key + '_POS2', this.getRowId(selectedInGrid[0]));
12172
- // this.m_appService.getState().grid_obj=new Object();
12173
- // this.m_appService.getState().grid_obj[this.grid_customer_preference_key+'_NODE']=this.gridApi.getSelectedRows[0];
12174
- }
12169
+ // Posizione da ripristinare al ricaricamento: la riga CLICCATA, non la selezione
12170
+ // (con rowSelection multiRow il click non seleziona e getSelectedNodes() e' vuoto
12171
+ // o contiene le righe spuntate). Id = quello di gridOptions.getRowId (node.id).
12172
+ const node = $event.node;
12173
+ if (node != null && node.data != null && node.rowIndex != null) {
12174
+ localStorage.setItem(this.grid_customer_preference_key + '_POS', String(node.rowIndex));
12175
+ if (this.gridApi)
12176
+ localStorage.setItem(this.grid_customer_preference_key + '_POS_BAR', JSON.stringify(this.gridApi.getVerticalPixelRange()));
12177
+ if (node.id != null)
12178
+ localStorage.setItem(this.grid_customer_preference_key + '_POS2', String(node.id));
12179
+ }
12175
12180
  this.sRow = $event.data;
12176
12181
  // riga senza dati (gruppo, riga di caricamento): niente LAST_ROW, altrimenti si salva la stringa 'undefined'
12177
12182
  if (this.sRow != null)