@onehat/data 1.19.15 → 1.19.17
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
|
@@ -177,7 +177,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
if (this.isLoaded &&
|
|
180
|
+
if (this.isLoaded && !this.eventsPaused) {
|
|
181
181
|
if (this.isTree) {
|
|
182
182
|
return this.getRootNodes(1);
|
|
183
183
|
} else {
|
|
@@ -307,6 +307,52 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
getSingleEntityFromServer = async (id) => {
|
|
311
|
+
if (this.isDestroyed) {
|
|
312
|
+
this.throwError('this.getSingleEntityFromServer is no longer valid. Repository has been destroyed.');
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!this.api.get) {
|
|
316
|
+
this.throwError('No "get" api endpoint defined.');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const idPropertyName = this.getSchema().model.idProperty;
|
|
321
|
+
const params = {};
|
|
322
|
+
params['conditions[' + idPropertyName + ']'] = id;
|
|
323
|
+
|
|
324
|
+
const data = _.merge(params, this._baseParams);
|
|
325
|
+
return this._send(this.methods.get, this.api.get, data)
|
|
326
|
+
.then(result => {
|
|
327
|
+
if (this.debugMode) {
|
|
328
|
+
console.log('Response for getSingleEntityFromServer for ' + this.name, result);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (this.isDestroyed) {
|
|
332
|
+
// If this repository gets destroyed before it has a chance
|
|
333
|
+
// to process the Ajax request, just ignore the response.
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const {
|
|
338
|
+
root,
|
|
339
|
+
success,
|
|
340
|
+
total,
|
|
341
|
+
message
|
|
342
|
+
} = this._processServerResponse(result);
|
|
343
|
+
|
|
344
|
+
if (!root[0]) {
|
|
345
|
+
throw Error('Record does not exist!')
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return this.createStandaloneEntity(root[0]);
|
|
349
|
+
})
|
|
350
|
+
.finally(() => {
|
|
351
|
+
this.markLoading(false);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
310
356
|
/**
|
|
311
357
|
* Login to OneBuild API
|
|
312
358
|
* @param {object} creds - object with two properties:
|
|
@@ -1062,7 +1062,7 @@ export default class Repository extends EventEmitter {
|
|
|
1062
1062
|
* @param {boolean} isDelayedSave - Should the repository skip autosave when immediately adding the record?
|
|
1063
1063
|
* @return {object} entity - new Entity object
|
|
1064
1064
|
*/
|
|
1065
|
-
createStandaloneEntity =
|
|
1065
|
+
createStandaloneEntity = (data, isPersisted = false, isDelayedSave = false) => {
|
|
1066
1066
|
if (this.isDestroyed) {
|
|
1067
1067
|
this.throwError('this.createStandaloneEntity is no longer valid. Repository has been destroyed.');
|
|
1068
1068
|
return;
|