@onehat/data 1.16.0 → 1.16.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -306,7 +306,7 @@ class AjaxRepository extends Repository {
306
306
  if (clearBase) {
307
307
  this._baseParams = {};
308
308
  }
309
- if (reload && this.isLoaded) {
309
+ if (reload && this.isLoaded && !this.eventsPaused) {
310
310
  return this.reload();
311
311
  }
312
312
  }
@@ -321,7 +321,7 @@ class AjaxRepository extends Repository {
321
321
  this.setBaseParam(this.paramSort, sorter.name);
322
322
  this.setBaseParam(this.paramDirection, sorter.direction);
323
323
 
324
- if (this.isLoaded) {
324
+ if (this.isLoaded && !this.eventsPaused) {
325
325
  return this.reload();
326
326
  }
327
327
  }
@@ -335,7 +335,7 @@ class AjaxRepository extends Repository {
335
335
  this.setParam(name, value);
336
336
  });
337
337
 
338
- if (this.isLoaded) {
338
+ if (this.isLoaded && !this.eventsPaused) {
339
339
  return this.reload();
340
340
  }
341
341
  }
@@ -348,7 +348,7 @@ class AjaxRepository extends Repository {
348
348
  this.setBaseParam(this.paramPageNum, this.page);
349
349
  this.setBaseParam(this.paramPageSize, this.pageSize);
350
350
 
351
- if (this.isLoaded) {
351
+ if (this.isLoaded && !this.eventsPaused) {
352
352
  return this.reload();
353
353
  }
354
354
  }
@@ -927,10 +927,12 @@ class AjaxRepository extends Repository {
927
927
  this.emit('save', batchOperationResults);
928
928
 
929
929
  // Do we need to reload?
930
- if (this._operations.add || this._operations.delete) {
931
- this.reload();
932
- } else {
933
- this.emit('changeData', this.entities);
930
+ if (!this.eventsPaused) {
931
+ if (this._operations.add || this._operations.delete) {
932
+ this.reload();
933
+ } else {
934
+ this.emit('changeData', this.entities);
935
+ }
934
936
  }
935
937
  }));
936
938
  }
@@ -171,7 +171,7 @@ class OneBuildRepository extends AjaxRepository {
171
171
  }
172
172
  });
173
173
 
174
- if (this.isLoaded && this.isAutoLoad) {
174
+ if (this.isLoaded && this.isAutoLoad && !this.eventsPaused) {
175
175
  return this.reload();
176
176
  }
177
177
  }
@@ -191,12 +191,14 @@ class OneBuildRepository extends AjaxRepository {
191
191
  this.setBaseParam('order', sorterStrings.join(','));
192
192
  }
193
193
 
194
- if (this.isLoaded && this.isAutoLoad) {
195
- return this.reload().then(() => {
194
+ if (!this.eventsPaused) {
195
+ if (this.isLoaded && this.isAutoLoad) {
196
+ return this.reload().then(() => {
197
+ this.emit('changeSorters');
198
+ });
199
+ } else {
196
200
  this.emit('changeSorters');
197
- });
198
- } else {
199
- this.emit('changeSorters');
201
+ }
200
202
  }
201
203
  }
202
204
 
@@ -988,7 +988,7 @@ export default class Repository extends EventEmitter {
988
988
  let entity = data;
989
989
  if (!(data instanceof Entity)) {
990
990
  // Create the new entity
991
- entity = Repository._createEntity(this.schema, data, this, isPersisted, originalIsMapped, isDelayedSave);
991
+ entity = Repository._createEntity(this.schema, data, this, isPersisted, originalIsMapped, isDelayedSave, this.isRemotePhantomMode);
992
992
  }
993
993
  this._relayEntityEvents(entity);
994
994
  this.entities.push(entity);
@@ -1026,7 +1026,7 @@ export default class Repository extends EventEmitter {
1026
1026
  return;
1027
1027
  }
1028
1028
 
1029
- const entity = Repository._createEntity(this.schema, data, this, isPersisted, originalIsMapped, isDelayedSave);
1029
+ const entity = Repository._createEntity(this.schema, data, this, isPersisted, originalIsMapped, isDelayedSave, this.isRemotePhantomMode);
1030
1030
 
1031
1031
  if (entity.isPhantom) {
1032
1032
  entity.createTempId();
@@ -1075,8 +1075,8 @@ export default class Repository extends EventEmitter {
1075
1075
  * @return {object} entity - new Entity object
1076
1076
  * @private
1077
1077
  */
1078
- static _createEntity = (schema, rawData, repository = null, isPersisted = false, originalIsMapped = false, isDelayedSave = false) => {
1079
- const entity = new Entity(schema, rawData, repository, originalIsMapped, isDelayedSave, this.isRemotePhantomMode);
1078
+ static _createEntity = (schema, rawData, repository = null, isPersisted = false, originalIsMapped = false, isDelayedSave = false, isRemotePhantomMode = false) => {
1079
+ const entity = new Entity(schema, rawData, repository, originalIsMapped, isDelayedSave, isRemotePhantomMode);
1080
1080
  entity.initialize();
1081
1081
  entity.isPersisted = isPersisted;
1082
1082
  return entity;