@trudb/tru-common-lib 0.2.330 → 0.2.331

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,25 +7964,26 @@ class TruDataGrid {
7964
7964
  return false;
7965
7965
  };
7966
7966
  addEntity = (newEntity) => {
7967
- let results;
7968
- if (this.gridType === TruDataGridTypes.DetailManyToMany)
7969
- results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityManyToManyType, this.latestSetupQuery, [newEntity.Ref]);
7970
- else
7971
- results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityType, this.latestSetupQuery, [newEntity.Ref]);
7972
- if (results) {
7973
- let entityAlreadyInGrid = null;
7974
- this.api?.forEachNodeAfterFilter((rowNode) => {
7975
- if (rowNode.data.$entity.Ref === newEntity.Ref)
7976
- entityAlreadyInGrid = newEntity;
7977
- });
7978
- if (!entityAlreadyInGrid) {
7979
- let enhancedEntity = this.enhanceRowDataForEntity(results[0]);
7980
- if (newEntity.Ref < 0) {
7981
- this.applyRelationships(results[0]);
7982
- this.rowData.push(enhancedEntity);
7983
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7984
- }
7985
- else {
7967
+ if (newEntity.Ref < 0) {
7968
+ let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7969
+ this.applyRelationships(newEntity);
7970
+ this.rowData.push(enhancedEntity);
7971
+ this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7972
+ }
7973
+ else {
7974
+ let results;
7975
+ if (this.gridType === TruDataGridTypes.DetailManyToMany)
7976
+ results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityManyToManyType, this.latestSetupQuery, [newEntity.Ref]);
7977
+ else
7978
+ results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityType, this.latestSetupQuery, [newEntity.Ref]);
7979
+ if (results) {
7980
+ let entityAlreadyInGrid = null;
7981
+ this.api?.forEachNodeAfterFilter((rowNode) => {
7982
+ if (rowNode.data.$entity.Ref === newEntity.Ref)
7983
+ entityAlreadyInGrid = newEntity;
7984
+ });
7985
+ if (!entityAlreadyInGrid) {
7986
+ let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7986
7987
  this.rowData.unshift(enhancedEntity);
7987
7988
  this.api.applyTransaction({ add: [enhancedEntity] });
7988
7989
  }