@trudb/tru-common-lib 0.2.234 → 0.2.236

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,6 +7793,9 @@ 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;
@@ -7810,7 +7813,7 @@ class TruDataGrid {
7810
7813
  if (!entityAlreadyInGrid) {
7811
7814
  let enhancedEntity = this.enhanceRowDataForEntity(entity);
7812
7815
  this.rowData.unshift(enhancedEntity);
7813
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7816
+ this.api.applyTransaction({ add: [enhancedEntity] });
7814
7817
  }
7815
7818
  }
7816
7819
  }));
@@ -7928,7 +7931,12 @@ class TruDataGrid {
7928
7931
  return false;
7929
7932
  };
7930
7933
  addEntity = (newEntity, dataNotification = false) => {
7931
- 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)
7932
7940
  return;
7933
7941
  if (this.entity) {
7934
7942
  newEntity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
@@ -7957,7 +7965,10 @@ class TruDataGrid {
7957
7965
  else {
7958
7966
  let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7959
7967
  this.rowData.unshift(enhancedEntity);
7960
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7968
+ if (dataNotification)
7969
+ this.api.applyTransaction({ add: [enhancedEntity] });
7970
+ else
7971
+ this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7961
7972
  }
7962
7973
  };
7963
7974
  getMergeData = (config, entityToValidate) => {