@trudb/tru-common-lib 0.2.360 → 0.2.362

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.
@@ -7743,7 +7743,7 @@ class TruDataGrid {
7743
7743
  setNoRowsTemplate = () => {
7744
7744
  //this.noRowsTemplate = `<span style="font-size:14px;font-weight:bold;">No data found.</span>`;
7745
7745
  };
7746
- applyRelationships = async (newEntity) => {
7746
+ applyRelationshipsAndUpdateGrid = (newEntity) => {
7747
7747
  if (this.entity) {
7748
7748
  newEntity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
7749
7749
  }
@@ -7751,13 +7751,12 @@ class TruDataGrid {
7751
7751
  //let parentName = this.entity.constructor.name;
7752
7752
  let unassociatedType = this.config.resultConfig.entityManyToManyType;
7753
7753
  let ref = this.selectedUnassociatedChoice.value.$;
7754
- await this.dataContext.entityAccess().searchByRefServerOnly(unassociatedType, ref).subscribe((childToAssociate) => {
7754
+ this.dataContext.entityAccess().searchByRefServerOnly(unassociatedType, ref).subscribe((childToAssociate) => {
7755
7755
  if (!childToAssociate)
7756
7756
  childToAssociate = this.appEnvironment.globalDataContext?.entityAccess().searchByRefCacheOnly(unassociatedType, ref, true);
7757
7757
  if (childToAssociate) {
7758
- let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7759
- enhancedEntity.$entity[this.config.resultConfig.entityManyToManyTypeNameWithPrefix + 'Ref'] = childToAssociate[unassociatedType.name + 'Ref'];
7760
- enhancedEntity.$entity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
7758
+ newEntity.$entity[this.config.resultConfig.entityManyToManyTypeNameWithPrefix + 'Ref'] = childToAssociate[unassociatedType.name + 'Ref'];
7759
+ newEntity.$entity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
7761
7760
  // remove item from the add dropdown control
7762
7761
  let itemIndex = this.unassociatedChoices.findIndex((choice) => {
7763
7762
  return choice.value.$ === childToAssociate[unassociatedType.name + 'Ref'];
@@ -7766,10 +7765,18 @@ class TruDataGrid {
7766
7765
  // clear add selection
7767
7766
  this.selectedUnassociatedChoice = undefined;
7768
7767
  // add row to grid
7769
- this.unsavedEntities.push(enhancedEntity);
7768
+ this.unsavedEntities.push(newEntity);
7769
+ this.rowData.push(newEntity);
7770
+ this.api.applyTransaction({ add: [newEntity], addIndex: 0 });
7771
+ this.api.refreshCells({ force: true });
7770
7772
  }
7771
7773
  });
7772
7774
  }
7775
+ else {
7776
+ this.rowData.push(newEntity);
7777
+ this.api.applyTransaction({ add: [newEntity], addIndex: 0 });
7778
+ this.api.refreshCells({ force: true });
7779
+ }
7773
7780
  };
7774
7781
  subscribeTo = () => {
7775
7782
  this.subs.push(this.appEnvironment.onSaveComplete$.pipe(skip(1)).subscribe(event => {
@@ -7986,10 +7993,7 @@ class TruDataGrid {
7986
7993
  });
7987
7994
  if (newEntity.Ref < 0 && !entityAlreadyInGrid) {
7988
7995
  let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
7989
- this.applyRelationships(newEntity);
7990
- this.rowData.push(enhancedEntity);
7991
- this.api.applyTransaction({ add: [enhancedEntity], addIndex: 0 });
7992
- this.api.refreshCells({ force: true });
7996
+ this.applyRelationshipsAndUpdateGrid(enhancedEntity);
7993
7997
  }
7994
7998
  else {
7995
7999
  let results;