@onehat/data 1.10.4 → 1.10.5
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.
|
@@ -112,6 +112,25 @@ describe('Entity', function() {
|
|
|
112
112
|
expect(_.isEqual(entity.getSubmitValues(), clone.getSubmitValues())).to.be.true;
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
it.skip('duplicate', function() {
|
|
116
|
+
const entity = this.entity;
|
|
117
|
+
|
|
118
|
+
const duplicate = entity.duplicate();
|
|
119
|
+
|
|
120
|
+
expect(entity === duplicate).to.be.false;
|
|
121
|
+
expect(_.isEqual(entity.id, duplicate.id)).to.be.true;
|
|
122
|
+
expect(_.isEqual(entity.displayValue, duplicate.displayValue)).to.be.true;
|
|
123
|
+
expect(_.isEqual(entity.isDirty, duplicate.isDirty)).to.be.true;
|
|
124
|
+
expect(_.isEqual(entity.isPersisted, duplicate.isPersisted)).to.be.true;
|
|
125
|
+
expect(_.isEqual(entity.isDeleted, duplicate.isDeleted)).to.be.true;
|
|
126
|
+
expect(_.isEqual(entity._originalData, duplicate._originalData)).to.be.true;
|
|
127
|
+
expect(_.isEqual(entity.getOriginalData(), duplicate.getOriginalData())).to.be.true;
|
|
128
|
+
expect(_.isEqual(entity.getRawValues(), duplicate.getRawValues())).to.be.true;
|
|
129
|
+
expect(_.isEqual(entity.getParsedValues(), duplicate.getParsedValues())).to.be.true;
|
|
130
|
+
expect(_.isEqual(entity.getDisplayValues(), duplicate.getDisplayValues())).to.be.true;
|
|
131
|
+
expect(_.isEqual(entity.getSubmitValues(), duplicate.getSubmitValues())).to.be.true;
|
|
132
|
+
});
|
|
133
|
+
|
|
115
134
|
it('_createProperties', function() {
|
|
116
135
|
const entity = this.entity;
|
|
117
136
|
expect(_.size(entity.properties)).to.be.eq(3);
|
package/package.json
CHANGED
package/src/Entity.js
CHANGED
|
@@ -322,7 +322,7 @@ class Entity extends EventEmitter {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
|
-
*
|
|
325
|
+
* Creates an exact copy of this Entity in its current state.
|
|
326
326
|
* @return {object} Entity - The clone
|
|
327
327
|
* @memberOf Entity
|
|
328
328
|
*/
|
|
@@ -338,6 +338,28 @@ class Entity extends EventEmitter {
|
|
|
338
338
|
return clone;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Duplicates this Entity and inserts the copy into the Repository.
|
|
343
|
+
* @return {object} Entity - The clone
|
|
344
|
+
* @memberOf Entity
|
|
345
|
+
*/
|
|
346
|
+
duplicate = () => {
|
|
347
|
+
let duplicate;
|
|
348
|
+
if (this.repository) {
|
|
349
|
+
duplicate = this.repository.add(this.rawData, false);
|
|
350
|
+
}
|
|
351
|
+
// const duplicate = new Entity(this.schema, this._originalData, this.repository);
|
|
352
|
+
// duplicate.initialize();
|
|
353
|
+
// if (this.isDirty) {
|
|
354
|
+
// duplicate.setValues( this.getRawValues() );
|
|
355
|
+
// }
|
|
356
|
+
// duplicate.isPersisted = false;
|
|
357
|
+
// duplicate.id = newId;
|
|
358
|
+
// duplicate.isDeleted = false;
|
|
359
|
+
|
|
360
|
+
return duplicate;
|
|
361
|
+
}
|
|
362
|
+
|
|
341
363
|
/**
|
|
342
364
|
* Resets the Entity to a state as if it had just been created,
|
|
343
365
|
* Gets data to restore from _originalData.
|
|
@@ -184,7 +184,11 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
if (this.isLoaded && this.autoLoad) {
|
|
187
|
-
return this.reload()
|
|
187
|
+
return this.reload().then(() => {
|
|
188
|
+
this.emit('changeSorters');
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
this.emit('changeSorters');
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
|
|
@@ -528,10 +528,10 @@ export default class Repository extends EventEmitter {
|
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
this.sorters = sorters;
|
|
531
|
-
this.emit('changeSorters');
|
|
532
531
|
if (this._onChangeSorters) {
|
|
533
532
|
return this._onChangeSorters();
|
|
534
533
|
}
|
|
534
|
+
this.emit('changeSorters');
|
|
535
535
|
}
|
|
536
536
|
return isChanged;
|
|
537
537
|
}
|