@trudb/tru-common-lib 0.2.329 → 0.2.330

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.
@@ -7414,7 +7414,7 @@ class TruDataChangeParser {
7414
7414
  if (this.entityFoundByQuery(change)) {
7415
7415
  var entityAlreadyInResults = this.getEntityFromResults(results, change);
7416
7416
  if (!entityAlreadyInResults.length && this.isLoaded()) {
7417
- this.addEntity(entity, true);
7417
+ this.addEntity(entity);
7418
7418
  }
7419
7419
  reloadResults = true;
7420
7420
  }
@@ -7445,13 +7445,13 @@ class TruDataChangeParser {
7445
7445
  newEntity[pkeyName] = change.tableRef;
7446
7446
  this.applyPropertyChanges(change, newEntity);
7447
7447
  if (this.isLoaded()) {
7448
- this.addEntity(newEntity, true);
7448
+ this.addEntity(newEntity);
7449
7449
  reloadResults = true;
7450
7450
  }
7451
7451
  }
7452
7452
  else if (entity === localEntity) {
7453
7453
  this.applyPropertyChanges(change, entity);
7454
- this.addEntity(entity, true);
7454
+ this.addEntity(entity);
7455
7455
  reloadResults = true;
7456
7456
  }
7457
7457
  }
@@ -7484,7 +7484,7 @@ class TruDataChangeParser {
7484
7484
  if (entity) {
7485
7485
  this.applyPropertyChanges(change, entity);
7486
7486
  if (this.entityFoundByQuery(change) && this.isLoaded()) {
7487
- this.addEntity(newEntity, true);
7487
+ this.addEntity(newEntity);
7488
7488
  reloadResults = true;
7489
7489
  }
7490
7490
  }
@@ -7501,7 +7501,7 @@ class TruDataChangeParser {
7501
7501
  newEntity[pkeyName2] = change.tableRef;
7502
7502
  this.applyPropertyChanges(change, newEntity);
7503
7503
  if (this.entityFoundByQuery(change) && this.isLoaded()) {
7504
- this.addEntity(newEntity, true);
7504
+ this.addEntity(newEntity);
7505
7505
  reloadResults = true;
7506
7506
  }
7507
7507
  }
@@ -7818,7 +7818,7 @@ class TruDataGrid {
7818
7818
  if (change.changeOperation === 'D') {
7819
7819
  this.api.forEachNode((rowNode) => {
7820
7820
  if (rowNode.data.$entity.Ref === change.tableRef) {
7821
- rowNodesToRemove.push(rowNode.data);
7821
+ rowNodesToRemove.push({ id: rowNode.data.$entity.Ref.toString() });
7822
7822
  }
7823
7823
  });
7824
7824
  }
@@ -7827,7 +7827,7 @@ class TruDataGrid {
7827
7827
  if (rowNode.data.$entity.Ref === change.tableRef) {
7828
7828
  let results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityType, this.latestSetupQuery, [rowNode.data.$entity.Ref]);
7829
7829
  if (!results)
7830
- rowNodesToRemove.push(rowNode.data);
7830
+ rowNodesToRemove.push({ id: rowNode.data.$entity.Ref.toString() });
7831
7831
  }
7832
7832
  });
7833
7833
  }
@@ -7835,7 +7835,6 @@ class TruDataGrid {
7835
7835
  if (rowNodesToRemove.length) {
7836
7836
  this.api.applyTransaction({ remove: rowNodesToRemove });
7837
7837
  }
7838
- this.api.refreshCells({ force: true });
7839
7838
  }));
7840
7839
  // Listen for entities added elsewhere in the app
7841
7840
  // Merge this logic with addEntity() logic below
@@ -7843,30 +7842,7 @@ class TruDataGrid {
7843
7842
  this.subs.push(this.dataContext.onEntityAdded().subscribe((changeArgs) => {
7844
7843
  if (!changeArgs.entity)
7845
7844
  return;
7846
- let results;
7847
- if (this.gridType === TruDataGridTypes.DetailManyToMany)
7848
- results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityManyToManyType, this.latestSetupQuery, [changeArgs.entity.Ref]);
7849
- else
7850
- results = this.dataContext.entityAccess().searchByRefArrayCacheOnly(this.config.resultConfig.entityType, this.latestSetupQuery, [changeArgs.entity.Ref]);
7851
- if (results) {
7852
- let entityAlreadyInGrid = null;
7853
- this.api?.forEachNodeAfterFilter((rowNode) => {
7854
- if (rowNode.data.$entity.Ref === changeArgs.entity.Ref)
7855
- entityAlreadyInGrid = changeArgs.entity;
7856
- });
7857
- if (!entityAlreadyInGrid) {
7858
- let enhancedEntity = this.enhanceRowDataForEntity(results[0]);
7859
- if (changeArgs.entity.Ref < 0) {
7860
- this.applyRelationships(results[0]);
7861
- this.rowData.push(enhancedEntity);
7862
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7863
- }
7864
- else {
7865
- this.rowData.unshift(enhancedEntity);
7866
- this.api.applyTransaction({ add: [enhancedEntity] });
7867
- }
7868
- }
7869
- }
7845
+ this.addEntity(changeArgs.entity);
7870
7846
  }));
7871
7847
  this.subs.push(fromEvent(document, 'keydown').subscribe((event) => {
7872
7848
  if (this.config.view.active && this.config.view.window.active) {
@@ -7987,48 +7963,29 @@ class TruDataGrid {
7987
7963
  }
7988
7964
  return false;
7989
7965
  };
7990
- //Can possibly merge with similar logic in onEntityAdded() observable above
7991
- addEntity = (newEntity, dataNotification = false) => {
7992
- let entityAlreadyInGrid = false;
7993
- this.api?.forEachNodeAfterFilter((rowNode) => {
7994
- if (rowNode.data.$entity.Ref === newEntity.Ref)
7995
- entityAlreadyInGrid = true;
7996
- });
7997
- if (this.entity && dataNotification || entityAlreadyInGrid)
7998
- return;
7999
- if (this.entity) {
8000
- newEntity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
8001
- }
8002
- if (this.gridType === TruDataGridTypes.DetailManyToMany) {
8003
- //let parentName = this.entity.constructor.name;
8004
- let unassociatedType = this.config.resultConfig.entityManyToManyType;
8005
- let ref = this.selectedUnassociatedChoice.value.$;
8006
- let childToAssociate = this.dataContext.entityAccess().searchByRefCacheOnly(unassociatedType, ref, true);
8007
- if (childToAssociate) {
8008
- let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
8009
- enhancedEntity.$entity[unassociatedType.name + 'Ref'] = childToAssociate[unassociatedType.name + 'Ref'];
8010
- enhancedEntity.$entity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
8011
- // remove item from the add dropdown control
8012
- let itemIndex = this.unassociatedChoices.findIndex((choice) => {
8013
- return choice[unassociatedType.name + 'Ref'] === childToAssociate[unassociatedType.name + 'Ref'];
8014
- });
8015
- this.unassociatedChoices.splice(itemIndex, 1);
8016
- // clear add selection
8017
- this.selectedUnassociatedChoice = undefined;
8018
- // add row to grid
8019
- this.unsavedEntities.push(enhancedEntity);
8020
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
8021
- }
8022
- }
8023
- else {
8024
- let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
8025
- if (dataNotification) {
8026
- this.rowData.unshift(enhancedEntity);
8027
- this.api.applyTransaction({ add: [enhancedEntity] });
8028
- }
8029
- else {
8030
- this.rowData.push(enhancedEntity);
8031
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
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 {
7986
+ this.rowData.unshift(enhancedEntity);
7987
+ this.api.applyTransaction({ add: [enhancedEntity] });
7988
+ }
8032
7989
  }
8033
7990
  }
8034
7991
  };