@esfaenza/es-table 20.3.11 → 20.3.14

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.
@@ -1263,8 +1263,15 @@ class ColumnMetadataHandler {
1263
1263
  let newHeaders = [];
1264
1264
  // Se devo finalizzare aggancio tutte le variabili di bind
1265
1265
  if (finalize) {
1266
+ // Mappa ID -> header costruita una sola volta (evita il .filter() lineare per ogni OrderDirective)
1267
+ let headersById = new Map();
1268
+ for (let h = 0; h < this.est.TMPRowTHs.length; h++) {
1269
+ let header = this.est.TMPRowTHs[h];
1270
+ if (!headersById.has(header.ID))
1271
+ headersById.set(header.ID, header);
1272
+ }
1266
1273
  this.est.OrderDirectives.forEach(o => {
1267
- let heaedrItem = this.est.TMPRowTHs.filter(t => t.ID == o)[0];
1274
+ let heaedrItem = headersById.get(o);
1268
1275
  if (heaedrItem)
1269
1276
  newHeaders.push(heaedrItem);
1270
1277
  });
@@ -1273,8 +1280,16 @@ class ColumnMetadataHandler {
1273
1280
  for (let i = 0; i < this.est.RowContexts.length; i++) {
1274
1281
  let context = this.est.TMPRowTDs[this.est.RowContexts[i]];
1275
1282
  let newContext = [];
1283
+ // Mappa ID -> signal costruita una sola volta per riga: il getter del signal viene invocato
1284
+ // una volta per cella invece di una volta per ogni (colonna × OrderDirective)
1285
+ let contextById = new Map();
1286
+ for (let c = 0; c < context.length; c++) {
1287
+ let id = context[c]().ID;
1288
+ if (!contextById.has(id))
1289
+ contextById.set(id, context[c]);
1290
+ }
1276
1291
  this.est.OrderDirectives.forEach(o => {
1277
- let contextItem = context.filter(t => t().ID == o)[0];
1292
+ let contextItem = contextById.get(o);
1278
1293
  // potrebbe esser undefined nel caso ci fossero colonne sotto thIf
1279
1294
  if (contextItem)
1280
1295
  newContext.push(contextItem);
@@ -1669,7 +1684,6 @@ class HierarchyModeHandler {
1669
1684
  this.orderItemsInPlace(objs);
1670
1685
  }
1671
1686
  orderItemsInPlace(items) {
1672
- debugger;
1673
1687
  let ownKey = this.est.OwnKey();
1674
1688
  let parentKey = this.est.ParentKey();
1675
1689
  const childrenMap = new Map();
@@ -3529,9 +3543,15 @@ class Logger {
3529
3543
  constructor(debugMode) {
3530
3544
  this.debugMode = debugMode;
3531
3545
  }
3546
+ /**
3547
+ * Emette un log a console solo se la modalità debug è attiva.
3548
+ *
3549
+ * Il testo può essere passato come funzione (**lazy**): in tal caso viene valutato solo quando il debug è attivo,
3550
+ * evitando di costruire stringhe costose (es. interpolazioni per-cella) quando i log sono disabilitati.
3551
+ */
3532
3552
  log(text) {
3533
3553
  if (this.debugMode)
3534
- console.log("[@esfaenza/es-table @ " + (new Date()).toISOString() + "] " + text);
3554
+ console.log("[@esfaenza/es-table @ " + (new Date()).toISOString() + "] " + (typeof text === 'function' ? text() : text));
3535
3555
  }
3536
3556
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: Logger, deps: [{ token: EST_DEBUG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3537
3557
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: Logger, providedIn: "root" }); }
@@ -3861,7 +3881,7 @@ class EstRendererPipe {
3861
3881
  this.logger.log(`Renderer retrieved in a non performant way`);
3862
3882
  EsTd = params.src.find((item) => item.tdForProperty === propName);
3863
3883
  }
3864
- this.logger.log(`Renderer ${EsTd ? 'found' : 'NOT found'} for '${propName}${params.name ? '/' + params.name : ''}'${!EsTd ? '. Using fallback renderer' : ''}`);
3884
+ this.logger.log(() => `Renderer ${EsTd ? 'found' : 'NOT found'} for '${propName}${params.name ? '/' + params.name : ''}'${!EsTd ? '. Using fallback renderer' : ''}`);
3865
3885
  var ret = EsTd ? EsTd.Template : params.fallback;
3866
3886
  return ret;
3867
3887
  }
@@ -3898,7 +3918,7 @@ class EstEditorPipe {
3898
3918
  this.logger.log(`Editor retrieved in a non performant way`);
3899
3919
  Editor = params.src.find((item) => item.editorForProperty === propName);
3900
3920
  }
3901
- this.logger.log(`Editor ${Editor ? 'found' : 'NOT found'} for '${propName}${params.name ? '/' + params.name : ''}'${!Editor ? '. Using fallback editor' : ''}`);
3921
+ this.logger.log(() => `Editor ${Editor ? 'found' : 'NOT found'} for '${propName}${params.name ? '/' + params.name : ''}'${!Editor ? '. Using fallback editor' : ''}`);
3902
3922
  var ret = Editor ? Editor.Template : params.fallback;
3903
3923
  return ret;
3904
3924
  }
@@ -4957,69 +4977,77 @@ class EsTableComponent {
4957
4977
  let contextFixeds = {};
4958
4978
  for (let i = 0; i < tds.length; i++) {
4959
4979
  let td = tds[i];
4980
+ // Valori costanti per colonna: calcolati una sola volta invece che per ogni riga
4981
+ let key = td.td;
4982
+ let th = this.thsCache[td.td];
4983
+ if (!!th)
4984
+ th._referenced = true;
4985
+ // Skippare senza th (casistica tabella dinamica)
4986
+ if (!(th && th.thIf && (td.tdIf || th.thGroup)))
4987
+ continue;
4988
+ let thCasted = th;
4989
+ let colDef = columnsCache[td.td];
4990
+ let isFixed = th.thFixed || th.thGroup || th.thPinned;
4991
+ let multiProp = td._multi ? td.td.split('_')[0] : null;
4992
+ let multiIndex = td._multi ? td.td.split('_')[1] : null;
4993
+ let alignment = (td.tdAlignment || th.thAlignment || defaultAlignment).toLowerCase();
4994
+ let format = td.tdFormat || th.thFormat;
4995
+ let template = thCasted.thGroup && !this.ShowItemGroupsColumns ? null : td.Template;
4996
+ let groupClass = thCasted.thGroupClass || '';
4960
4997
  for (let i = 0; i < bs.length; i++) {
4961
4998
  let item = bs[i];
4962
4999
  let ctx = item._hash;
4963
- let key = td.td;
4964
- let th = this.thsCache[td.td];
4965
- if (!!th)
4966
- th._referenced = true;
4967
- // Skippare senza th (casistica tabella dinamica)
4968
- if (th && th.thIf && (td.tdIf || th.thGroup)) {
4969
- let thCasted = th;
4970
- let isFixed = th.thFixed || th.thGroup || th.thPinned;
4971
- let itemToAdd = item._item ?
4972
- {
4973
- LeftBorder: thCasted._lbord,
4974
- RightBorder: thCasted._rbord,
4975
- ID: key,
4976
- Pinned: columnsCache[td.td].pinned,
4977
- PinnedWidth: thCasted.thPinnedWidth,
4978
- GroupHeader: false,
4979
- GroupAggregation: false,
4980
- Visible: columnsCache[td.td].visible,
4981
- Wraps: false,
4982
- Class: td.tdClass,
4983
- IconClass: td.tdIconClass,
4984
- ConditionField: td.tdConditionField,
4985
- ConditionValue: td.tdConditionValue,
4986
- Title: td.tdTitle,
4987
- Content: td.tdContent,
4988
- Template: thCasted.thGroup && !this.ShowItemGroupsColumns ? null : td.Template,
4989
- Multi: td._multi,
4990
- MultiProp: td._multi ? td.td.split('_')[0] : null,
4991
- MultiIndex: td._multi ? td.td.split('_')[1] : null,
4992
- Alignment: (td.tdAlignment || th.thAlignment || defaultAlignment).toLowerCase(),
4993
- Format: td.tdFormat || th.thFormat,
4994
- PropertyName: th.thProperty,
4995
- PropertyType: th.thType,
4996
- PropertySource: th.thSource,
4997
- EditorOptions: th.thEditorOptions,
4998
- PropAccessor: td.tdPropertyAccessor,
4999
- RoutePath: thCasted.thRoutePath,
5000
- RouteParameterProperties: thCasted.thRouteParameterProperties
5001
- } :
5002
- {
5003
- LeftBorder: thCasted._lbord,
5004
- RightBorder: thCasted._rbord,
5005
- ID: key,
5006
- Pinned: columnsCache[td.td].pinned,
5007
- PinnedWidth: thCasted.thPinnedWidth,
5008
- GroupHeader: thCasted.thGroup,
5009
- GroupAggregation: !!thCasted.thAggregation,
5010
- Visible: columnsCache[td.td].visible,
5011
- Wraps: false,
5012
- Class: thCasted.thGroupClass || '',
5013
- Content: this.rowGrouping_H.getGroupCellDisplay(item, key, th)
5014
- };
5015
- if (this.TMPRowTDs[ctx]) {
5016
- this.TMPRowTDs[ctx].push(signal(itemToAdd));
5017
- }
5018
- else {
5019
- this.RowContexts.push(ctx);
5020
- this.TMPRowTDs[ctx] = [signal(itemToAdd)];
5021
- contextFixeds[ctx] = isFixed ? 1 : 0;
5022
- }
5000
+ let itemToAdd = item._item ?
5001
+ {
5002
+ LeftBorder: thCasted._lbord,
5003
+ RightBorder: thCasted._rbord,
5004
+ ID: key,
5005
+ Pinned: colDef.pinned,
5006
+ PinnedWidth: thCasted.thPinnedWidth,
5007
+ GroupHeader: false,
5008
+ GroupAggregation: false,
5009
+ Visible: colDef.visible,
5010
+ Wraps: false,
5011
+ Class: td.tdClass,
5012
+ IconClass: td.tdIconClass,
5013
+ ConditionField: td.tdConditionField,
5014
+ ConditionValue: td.tdConditionValue,
5015
+ Title: td.tdTitle,
5016
+ Content: td.tdContent,
5017
+ Template: template,
5018
+ Multi: td._multi,
5019
+ MultiProp: multiProp,
5020
+ MultiIndex: multiIndex,
5021
+ Alignment: alignment,
5022
+ Format: format,
5023
+ PropertyName: th.thProperty,
5024
+ PropertyType: th.thType,
5025
+ PropertySource: th.thSource,
5026
+ EditorOptions: th.thEditorOptions,
5027
+ PropAccessor: td.tdPropertyAccessor,
5028
+ RoutePath: thCasted.thRoutePath,
5029
+ RouteParameterProperties: thCasted.thRouteParameterProperties
5030
+ } :
5031
+ {
5032
+ LeftBorder: thCasted._lbord,
5033
+ RightBorder: thCasted._rbord,
5034
+ ID: key,
5035
+ Pinned: colDef.pinned,
5036
+ PinnedWidth: thCasted.thPinnedWidth,
5037
+ GroupHeader: thCasted.thGroup,
5038
+ GroupAggregation: !!thCasted.thAggregation,
5039
+ Visible: colDef.visible,
5040
+ Wraps: false,
5041
+ Class: groupClass,
5042
+ Content: this.rowGrouping_H.getGroupCellDisplay(item, key, th)
5043
+ };
5044
+ if (this.TMPRowTDs[ctx]) {
5045
+ this.TMPRowTDs[ctx].push(signal(itemToAdd));
5046
+ }
5047
+ else {
5048
+ this.RowContexts.push(ctx);
5049
+ this.TMPRowTDs[ctx] = [signal(itemToAdd)];
5050
+ contextFixeds[ctx] = isFixed ? 1 : 0;
5023
5051
  }
5024
5052
  }
5025
5053
  }
@@ -5196,7 +5224,6 @@ class EsTableComponent {
5196
5224
  * @returns {boolean} **true** se l'operaizone è andata a buon fine, **false** altrimenti
5197
5225
  */
5198
5226
  handleClick(event, item) {
5199
- debugger;
5200
5227
  this.selection_H.clearSelectionStatusExcluding(undefined);
5201
5228
  let selecteditems = [];
5202
5229
  if (event.shiftKey && this.ShiftClick() && !this.SingleSelection()) {
@@ -5636,7 +5663,6 @@ class EsTableComponent {
5636
5663
  //* Piango ancora
5637
5664
  // Gestione Embedding
5638
5665
  showDialog(dlg, elementRef) {
5639
- debugger;
5640
5666
  dlg.show();
5641
5667
  this.retries = 0;
5642
5668
  if (this.emb.Embedded)