@trudb/tru-common-lib 0.2.331 → 0.2.333

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.
@@ -7964,7 +7964,12 @@ class TruDataGrid {
7964
7964
  return false;
7965
7965
  };
7966
7966
  addEntity = (newEntity) => {
7967
- if (newEntity.Ref < 0) {
7967
+ let entityAlreadyInGrid = null;
7968
+ this.api?.forEachNodeAfterFilter((rowNode) => {
7969
+ if (rowNode.data.$entity.Ref === newEntity.Ref)
7970
+ entityAlreadyInGrid = newEntity;
7971
+ });
7972
+ if (newEntity.Ref < 0 && !entityAlreadyInGrid) {
7968
7973
  let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7969
7974
  this.applyRelationships(newEntity);
7970
7975
  this.rowData.push(enhancedEntity);
@@ -7977,11 +7982,6 @@ class TruDataGrid {
7977
7982
  else
7978
7983
  results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityType, this.latestSetupQuery, [newEntity.Ref]);
7979
7984
  if (results) {
7980
- let entityAlreadyInGrid = null;
7981
- this.api?.forEachNodeAfterFilter((rowNode) => {
7982
- if (rowNode.data.$entity.Ref === newEntity.Ref)
7983
- entityAlreadyInGrid = newEntity;
7984
- });
7985
7985
  if (!entityAlreadyInGrid) {
7986
7986
  let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7987
7987
  this.rowData.unshift(enhancedEntity);
@@ -8235,7 +8235,7 @@ class TruDataGrid {
8235
8235
  return true;
8236
8236
  };
8237
8237
  onAdd = () => {
8238
- this.addEntity(this.dataContext.entityAccess().add(this.config.resultConfig.entityType));
8238
+ this.dataContext.entityAccess().add(this.config.resultConfig.entityType);
8239
8239
  };
8240
8240
  onDelete = () => {
8241
8241
  let selectedRows = this.api.getSelectedRows();