@onehat/data 1.22.30 → 1.22.32

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.22.30",
3
+ "version": "1.22.32",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -431,7 +431,7 @@ export default class MixedProperty extends EventEmitter {
431
431
  defaultValue: null,
432
432
  formatter: null,
433
433
  };
434
-
434
+
435
435
  // If types are configured, use the first type's default value
436
436
  if (defaults.types && Array.isArray(defaults.types) && defaults.types.length > 0) {
437
437
  const
@@ -450,7 +450,7 @@ export default class MixedProperty extends EventEmitter {
450
450
  }
451
451
  }
452
452
 
453
- return _.merge({}, mixedPropertyDefaults, defaults);
453
+ return _.merge({}, defaults);
454
454
  }
455
455
  }
456
456
 
@@ -1138,9 +1138,15 @@ export default class Repository extends EventEmitter {
1138
1138
  entity = Repository._createEntity(this.schema, data, this, isPersisted, isDelayedSave, this.isRemotePhantomMode);
1139
1139
  }
1140
1140
  this._relayEntityEvents(entity);
1141
- if (this.isTree && data.parentId) {
1142
- // Trees need new node to be added as first child of parent
1143
- const ix = this.getIxById(data.parentId) +1;
1141
+ if (this.isTree) {
1142
+ let ix = 1; // default to beginning
1143
+ if (data.previousSiblingId) {
1144
+ // new node to be added as next sibling of previousSiblingId
1145
+ ix = this.getIxById(data.previousSiblingId) +1;
1146
+ } else if (data.parentId) {
1147
+ // new node to be added as first child of parent
1148
+ ix = this.getIxById(data.parentId) +1;
1149
+ }
1144
1150
  this.entities = [
1145
1151
  ...this.entities.slice(0, ix),
1146
1152
  entity,
@@ -371,7 +371,7 @@ class TreeRepository extends OneBuildRepository {
371
371
  getRootNodes() {
372
372
  this.ensureTree();
373
373
  if (this.isDestroyed) {
374
- this.throwError('this.loadRootNodes is no longer valid. Repository has been destroyed.');
374
+ this.throwError('this.getRootNodes is no longer valid. Repository has been destroyed.');
375
375
  return;
376
376
  }
377
377