@trudb/tru-common-lib 0.2.233 → 0.2.235

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.
@@ -7793,10 +7793,12 @@ class TruDataGrid {
7793
7793
  this.api.refreshCells({ force: true });
7794
7794
  }
7795
7795
  }));
7796
+ // Listen for entities added elsewhere in the app
7797
+ // Merge this logic with addEntity() logic below
7798
+ // Three ways to add: Directly via toolbar, signalR, or listen for entity added event
7796
7799
  this.subs.push(this.dataContext.onEntityAdded().subscribe((changeArgs) => {
7797
7800
  if (!changeArgs.entity || this.isActive)
7798
7801
  return;
7799
- let rowNodesToAdd = [];
7800
7802
  let entity;
7801
7803
  if (this.gridType === TruDataGridTypes.DetailManyToMany)
7802
7804
  entity = this.dataContext.entityAccess().searchByRefCacheOnly(this.config.resultConfig.entityManyToManyType, changeArgs.entity.Ref, true);
@@ -7809,9 +7811,9 @@ class TruDataGrid {
7809
7811
  entityAlreadyInGrid = changeArgs.entity;
7810
7812
  });
7811
7813
  if (!entityAlreadyInGrid) {
7812
- rowNodesToAdd.push(this.enhanceRowDataForEntity(entity));
7813
- this.rowData.unshift(...rowNodesToAdd);
7814
- this.api.applyTransaction({ add: rowNodesToAdd, addIndex: 0 });
7814
+ let enhancedEntity = this.enhanceRowDataForEntity(entity);
7815
+ this.rowData.unshift(enhancedEntity);
7816
+ this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7815
7817
  }
7816
7818
  }
7817
7819
  }));
@@ -7929,7 +7931,12 @@ class TruDataGrid {
7929
7931
  return false;
7930
7932
  };
7931
7933
  addEntity = (newEntity, dataNotification = false) => {
7932
- if (this.entity && dataNotification)
7934
+ let entityAlreadyInGrid = false;
7935
+ this.api?.forEachNodeAfterFilter((rowNode) => {
7936
+ if (rowNode.data.$entity.Ref === newEntity.Ref)
7937
+ entityAlreadyInGrid = true;
7938
+ });
7939
+ if (this.entity && dataNotification || entityAlreadyInGrid)
7933
7940
  return;
7934
7941
  if (this.entity) {
7935
7942
  newEntity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];