@trudb/tru-common-lib 0.0.913 → 0.0.915

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.
@@ -1623,8 +1623,9 @@ class TruDetailViewBase {
1623
1623
  nextIndex = 0;
1624
1624
  return nextIndex;
1625
1625
  };
1626
- onAddEntity = () => {
1627
- let newEntity = this.dataContext.entityAccess().add(this.entityType);
1626
+ onAddEntity = (newEntity) => {
1627
+ if (!newEntity)
1628
+ newEntity = this.dataContext.entityAccess().add(this.entityType);
1628
1629
  this.entities.splice(this.navigationIndex + 1, 0, newEntity);
1629
1630
  this.navigateTo(this.navigationIndex + 1);
1630
1631
  };
@@ -2818,6 +2819,7 @@ class TruDataChangeParser {
2818
2819
  dataContext;
2819
2820
  entity;
2820
2821
  tableName;
2822
+ addEntity;
2821
2823
  getLatestResults;
2822
2824
  getLatestQuery;
2823
2825
  contextFilters;
@@ -2834,12 +2836,13 @@ class TruDataChangeParser {
2834
2836
  dataChanged(change) {
2835
2837
  this.dataChanged$.next(change);
2836
2838
  }
2837
- constructor(connection, appEnviroment, dataContext, globalDataContext, entity, tableName, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, modelTypeLookup, modelPropertyLookup) {
2839
+ constructor(connection, appEnviroment, dataContext, globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, modelTypeLookup, modelPropertyLookup) {
2838
2840
  this.appEnvionment = appEnviroment;
2839
2841
  this.dataContext = dataContext;
2840
2842
  this.globalDataContext = globalDataContext;
2841
2843
  this.entity = entity;
2842
2844
  this.tableName = tableName;
2845
+ this.addEntity = addEntity;
2843
2846
  this.getLatestResults = getLatestResults;
2844
2847
  this.getLatestQuery = getLatestQuery;
2845
2848
  this.contextFilters = contextFilters;
@@ -2971,7 +2974,7 @@ class TruDataChangeParser {
2971
2974
  if (this.entityFoundByQuery(change)) {
2972
2975
  var entityAlreadyInResults = this.getEntityFromResults(results, change);
2973
2976
  if (!entityAlreadyInResults.length && this.isLoaded()) {
2974
- results.push(entity);
2977
+ this.addEntity(entity);
2975
2978
  }
2976
2979
  reloadResults = true;
2977
2980
  }
@@ -3002,20 +3005,17 @@ class TruDataChangeParser {
3002
3005
  newEntity[pkeyName] = change.tableRef;
3003
3006
  this.applyPropertyChanges(change, newEntity);
3004
3007
  if (this.isLoaded()) {
3005
- var results = this.getLatestResults();
3006
- results.push(newEntity);
3008
+ this.addEntity(newEntity);
3007
3009
  reloadResults = true;
3008
3010
  }
3009
3011
  }
3010
3012
  else if (entity === localEntity) {
3011
3013
  this.applyPropertyChanges(change, entity);
3012
- var results = this.getLatestResults();
3013
- results.push(entity);
3014
+ this.addEntity(entity);
3014
3015
  reloadResults = true;
3015
3016
  }
3016
3017
  }
3017
3018
  else if (!this.entityFoundByQuery(change) && entityAlreadyInResults.length) {
3018
- var results = this.getLatestResults();
3019
3019
  var entityToDelete = this.getEntityFromResults(results, change);
3020
3020
  if (entityToDelete.length) {
3021
3021
  results.splice(results.indexOf(entityAlreadyInResults[0]), 1);
@@ -3043,9 +3043,8 @@ class TruDataChangeParser {
3043
3043
  await this.getEntityFromServer(change).subscribe((entity) => {
3044
3044
  if (entity) {
3045
3045
  this.applyPropertyChanges(change, entity);
3046
- var results = this.getLatestResults();
3047
3046
  if (this.entityFoundByQuery(change) && this.isLoaded()) {
3048
- results.push(entity);
3047
+ this.addEntity(newEntity);
3049
3048
  reloadResults = true;
3050
3049
  }
3051
3050
  }
@@ -3062,8 +3061,7 @@ class TruDataChangeParser {
3062
3061
  newEntity[pkeyName2] = change.tableRef;
3063
3062
  this.applyPropertyChanges(change, newEntity);
3064
3063
  if (this.entityFoundByQuery(change) && this.isLoaded()) {
3065
- var results = this.getLatestResults();
3066
- results.push(newEntity);
3064
+ this.addEntity(newEntity);
3067
3065
  reloadResults = true;
3068
3066
  }
3069
3067
  }
@@ -3161,8 +3159,8 @@ class TruConnectionHub {
3161
3159
  console.log(`SignalR connection error: ${error}`);
3162
3160
  }
3163
3161
  };
3164
- subscribe = (dataContext, entity, tableName, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded) => {
3165
- return new TruDataChangeParser(this.connection, this.appEnvironment, dataContext, this.appEnvironment.globalDataContext, entity, tableName, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, this.modelTypeLookup, this.modelPropertyLookup).onDataChanged();
3162
+ subscribe = (dataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded) => {
3163
+ return new TruDataChangeParser(this.connection, this.appEnvironment, dataContext, this.appEnvironment.globalDataContext, entity, tableName, addEntity, getLatestResults, getLatestQuery, contextFilters, expandPaths, isLoaded, this.modelTypeLookup, this.modelPropertyLookup).onDataChanged();
3166
3164
  };
3167
3165
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.2", ngImport: i0, type: TruConnectionHub, deps: [{ token: TruDataContext }, { token: TruAppEnvironment }, { token: TruModelTypeLookup }, { token: TruModelPropertyLookup }], target: i0.ɵɵFactoryTarget.Injectable });
3168
3166
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.2", ngImport: i0, type: TruConnectionHub, providedIn: 'root' });
@@ -3549,7 +3547,7 @@ class TruDataGrid {
3549
3547
  // //this.addEntity(changeArgs.entity)
3550
3548
  //}
3551
3549
  }));
3552
- this.subs.push(this.connectionHub.subscribe(this.dataContext, this.config.resultConfig.entityType, this.config.resultConfig.entityType.name, () => { return this.loadedEntities; }, () => { return this.latestSetupQuery; }, this.config.resultConfig.expands, [], () => { return true; }).subscribe((dataChange) => {
3550
+ this.subs.push(this.connectionHub.subscribe(this.dataContext, this.config.resultConfig.entityType, this.config.resultConfig.entityType.name, this.addEntity, () => { return this.loadedEntities; }, () => { return this.latestSetupQuery; }, this.config.resultConfig.expands, [], () => { return true; }).subscribe((dataChange) => {
3553
3551
  this.api.refreshCells({ force: true });
3554
3552
  }));
3555
3553
  };