@onehat/data 1.22.31 → 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.31",
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",
@@ -38,21 +38,12 @@ export default class MixedProperty extends EventEmitter {
38
38
 
39
39
  super(config, entity);
40
40
 
41
- // Apply config to this instance (similar to how Property does it)
42
- _.merge(this, config);
43
- this._originalConfig = config;
44
- this._entity = entity;
45
-
46
41
  this.registerEvents([
47
42
  'change',
48
43
  'changeValidity',
49
44
  'destroy',
50
45
  ]);
51
46
 
52
- this.rawValue = null;
53
- this.parsedValue = null;
54
- this.isDestroyed = false;
55
-
56
47
  this.types = config.types;
57
48
  this.currentType = this.types[0].type || this.types[0];
58
49
  this.internalProperties = new Map();
@@ -440,7 +431,7 @@ export default class MixedProperty extends EventEmitter {
440
431
  defaultValue: null,
441
432
  formatter: null,
442
433
  };
443
-
434
+
444
435
  // If types are configured, use the first type's default value
445
436
  if (defaults.types && Array.isArray(defaults.types) && defaults.types.length > 0) {
446
437
  const
@@ -459,7 +450,7 @@ export default class MixedProperty extends EventEmitter {
459
450
  }
460
451
  }
461
452
 
462
- return _.merge({}, mixedPropertyDefaults, defaults);
453
+ return _.merge({}, defaults);
463
454
  }
464
455
  }
465
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