@onehat/data 1.21.5 → 1.21.7
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
package/src/Repository/Ajax.js
CHANGED
|
@@ -287,6 +287,17 @@ class AjaxRepository extends Repository {
|
|
|
287
287
|
return this._baseParams.hasOwnProperty(name);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Returns current value of base query param
|
|
292
|
+
* @param {string} name - Param name
|
|
293
|
+
*/
|
|
294
|
+
getBaseParam(name) {
|
|
295
|
+
if (!this.hasBaseParam(name)) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return this._baseParams[name];
|
|
299
|
+
}
|
|
300
|
+
|
|
290
301
|
/**
|
|
291
302
|
* Determines if query param exists
|
|
292
303
|
* @param {string} name - Param name
|
|
@@ -31,6 +31,32 @@ export default class Command extends EventEmitter {
|
|
|
31
31
|
this.setCheckReturnValues();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
useDefaultHandler() {
|
|
35
|
+
this.on('handleServerResponse', this.defaultHandler);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
defaultHandler(entity) {
|
|
39
|
+
|
|
40
|
+
const response = entity.prop.response.parsedValue;
|
|
41
|
+
|
|
42
|
+
if (!response || !response.status) {
|
|
43
|
+
entity.isError = true;
|
|
44
|
+
entity.errorMsg = 'No discernable response from server.';
|
|
45
|
+
entity.handled = true;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (response.status !== 'OK') {
|
|
50
|
+
entity.isError = true;
|
|
51
|
+
entity.errorMsg = 'Encountered server error(s): ' + response.message;
|
|
52
|
+
entity.handled = true;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Success!
|
|
57
|
+
entity.handled = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
34
60
|
/**
|
|
35
61
|
* Register a handler for this command.
|
|
36
62
|
* @param {function} handler - The event handler
|
|
@@ -214,11 +214,15 @@ class LocalFromRemoteRepository extends EventEmitter {
|
|
|
214
214
|
/**
|
|
215
215
|
* Registers multiple commands for when syncing in MODE_COMMAND_QUEUE mode.
|
|
216
216
|
*/
|
|
217
|
-
registerCommands(commands) {
|
|
217
|
+
registerCommands(commands, useDefaultHandler = true) {
|
|
218
218
|
const oThis = this;
|
|
219
219
|
_.each(commands, (name) => {
|
|
220
220
|
if (!oThis.isRegisteredCommand(name)) {
|
|
221
|
-
|
|
221
|
+
const command = new Command(name);
|
|
222
|
+
if (useDefaultHandler) {
|
|
223
|
+
command.useDefaultHandler();
|
|
224
|
+
}
|
|
225
|
+
oThis.commands[name] = command;
|
|
222
226
|
}
|
|
223
227
|
});
|
|
224
228
|
}
|