@onehat/data 1.18.1 → 1.18.3

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.18.1",
3
+ "version": "1.18.3",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -124,6 +124,7 @@ class AjaxRepository extends Repository {
124
124
  add: false,
125
125
  edit: false,
126
126
  delete: false,
127
+ deletePhantom: false,
127
128
  };
128
129
 
129
130
  }
@@ -537,6 +538,7 @@ class AjaxRepository extends Repository {
537
538
  add: false,
538
539
  edit: false,
539
540
  delete: false,
541
+ deletePhantom: false,
540
542
  };
541
543
  }
542
544
 
@@ -763,7 +765,11 @@ class AjaxRepository extends Repository {
763
765
  return;
764
766
  }
765
767
 
766
- this._operations.delete = true;
768
+ if (entity.isRemotePhantomMode && entity.isPhantom) {
769
+ this._operations.deletePhantom = true;
770
+ } else {
771
+ this._operations.delete = true;
772
+ }
767
773
  entity.isSaving = true;
768
774
 
769
775
  const
@@ -810,7 +816,7 @@ class AjaxRepository extends Repository {
810
816
  return;
811
817
  }
812
818
 
813
- this._operations.delete = true;
819
+ this._operations.delete = true; // NOTE: We don't use batchDelete for remotePhantom records
814
820
 
815
821
  const
816
822
  method = this.methods.delete,
@@ -966,7 +972,9 @@ class AjaxRepository extends Repository {
966
972
 
967
973
  // Do we need to reload?
968
974
  if (!this.eventsPaused) {
969
- if (this._operations.add || this._operations.delete) {
975
+ if (this.isRemotePhantomMode && (this._operations.add || this._operations.deletePhantom)) {
976
+ // Do nothing, as we don't want to immediately reload on add for a remote phantom mode record. It won't appear, and it will cause all kinds of trouble!
977
+ } else if (this._operations.add || this._operations.delete) {
970
978
  this.reload();
971
979
  } else {
972
980
  this.emit('changeData', this.entities);
@@ -1796,7 +1796,7 @@ export default class Repository extends EventEmitter {
1796
1796
  if (!entity) {
1797
1797
  return;
1798
1798
  }
1799
- if (entity.isPhantom) {
1799
+ if (entity.isPhantom && !entity.isRemotePhantomMode) {
1800
1800
  // Just auto-remove it. Don't bother saving to storage medium.
1801
1801
  this.removeEntity(entity);
1802
1802
  } else {