New eslint rules auto fix (#3058)
* no-implicit-coercion and no-unneeded-ternary * End every line with a semicolon * Spacing and formatting * Enabled semi-spacing * Applies npm run lint:fix to code after master merge * Fix merge issues * Switched operator-linebreak to 'before' Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ define([
|
||||
) {
|
||||
|
||||
return {
|
||||
name:"platform/persistence/aggregator",
|
||||
name: "platform/persistence/aggregator",
|
||||
definition: {
|
||||
"extensions": {
|
||||
"components": [
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
@@ -75,11 +74,13 @@ define(
|
||||
Object.keys(METHOD_DEFAULTS).forEach(function (method) {
|
||||
PersistenceAggregator.prototype[method] = function (space) {
|
||||
var delegateArgs = Array.prototype.slice.apply(arguments, []);
|
||||
|
||||
return this.providerMapPromise.then(function (map) {
|
||||
var provider = map[space];
|
||||
return provider ?
|
||||
provider[method].apply(provider, delegateArgs) :
|
||||
METHOD_DEFAULTS[method];
|
||||
|
||||
return provider
|
||||
? provider[method].apply(provider, delegateArgs)
|
||||
: METHOD_DEFAULTS[method];
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -63,6 +63,7 @@ define(
|
||||
mockProvider[m].and.returnValue(fakePromise(true));
|
||||
});
|
||||
mockProvider.listSpaces.and.returnValue(fakePromise([space]));
|
||||
|
||||
return mockProvider;
|
||||
});
|
||||
mockCallback = jasmine.createSpy();
|
||||
@@ -74,6 +75,7 @@ define(
|
||||
result.push(v);
|
||||
});
|
||||
});
|
||||
|
||||
return fakePromise(result);
|
||||
});
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ define([
|
||||
) {
|
||||
|
||||
return {
|
||||
name:"platform/persistence/couch",
|
||||
name: "platform/persistence/couch",
|
||||
definition: {
|
||||
"name": "Couch Persistence",
|
||||
"description": "Adapter to read and write objects using a CouchDB instance.",
|
||||
|
||||
@@ -76,7 +76,6 @@ define(
|
||||
this.path = path;
|
||||
this.interval = interval;
|
||||
|
||||
|
||||
// Callback if the HTTP request to Couch fails
|
||||
function handleError() {
|
||||
self.state = DISCONNECTED;
|
||||
|
||||
@@ -68,6 +68,7 @@ define(
|
||||
CouchPersistenceProvider.prototype.checkResponse = function (response) {
|
||||
if (response && response.ok) {
|
||||
this.revs[response.id] = response.rev;
|
||||
|
||||
return response.ok;
|
||||
} else {
|
||||
return false;
|
||||
@@ -78,6 +79,7 @@ define(
|
||||
CouchPersistenceProvider.prototype.getModel = function (response) {
|
||||
if (response && response.model) {
|
||||
this.revs[response[ID]] = response[REV];
|
||||
|
||||
return response.model;
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -107,7 +109,6 @@ define(
|
||||
return this.request(subpath, "PUT", value);
|
||||
};
|
||||
|
||||
|
||||
CouchPersistenceProvider.prototype.listSpaces = function () {
|
||||
return this.$q.when(this.spaces);
|
||||
};
|
||||
@@ -121,19 +122,20 @@ define(
|
||||
.then(this.checkResponse.bind(this));
|
||||
};
|
||||
|
||||
|
||||
CouchPersistenceProvider.prototype.readObject = function (space, key) {
|
||||
return this.get(key).then(this.getModel.bind(this));
|
||||
};
|
||||
|
||||
CouchPersistenceProvider.prototype.updateObject = function (space, key, value) {
|
||||
var rev = this.revs[key];
|
||||
|
||||
return this.put(key, new CouchDocument(key, value, rev))
|
||||
.then(this.checkResponse.bind(this));
|
||||
};
|
||||
|
||||
CouchPersistenceProvider.prototype.deleteObject = function (space, key, value) {
|
||||
var rev = this.revs[key];
|
||||
|
||||
return this.put(key, new CouchDocument(key, value, rev, true))
|
||||
.then(this.checkResponse.bind(this));
|
||||
};
|
||||
|
||||
@@ -124,7 +124,6 @@ define(
|
||||
expect(indicator.getGlyphClass()).toEqual("err");
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -85,7 +85,11 @@ define(
|
||||
it("allows object creation", function () {
|
||||
var model = { someKey: "some value" };
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "xyz", "ok": true }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "xyz",
|
||||
"ok": true
|
||||
}
|
||||
}));
|
||||
provider.createObject("testSpace", "abc", model).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -105,7 +109,11 @@ define(
|
||||
it("allows object models to be read back", function () {
|
||||
var model = { someKey: "some value" };
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "xyz", "model": model }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "xyz",
|
||||
"model": model
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc").then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -121,13 +129,21 @@ define(
|
||||
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "xyz", "model": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "xyz",
|
||||
"model": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "uvw", "ok": true }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "uvw",
|
||||
"ok": true
|
||||
}
|
||||
}));
|
||||
provider.updateObject("testSpace", "abc", model).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -147,13 +163,21 @@ define(
|
||||
it("allows object deletion", function () {
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "xyz", "model": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "xyz",
|
||||
"model": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "uvw", "ok": true }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "uvw",
|
||||
"ok": true
|
||||
}
|
||||
}));
|
||||
provider.deleteObject("testSpace", "abc", {}).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -173,7 +197,11 @@ define(
|
||||
it("reports failure to create objects", function () {
|
||||
var model = { someKey: "some value" };
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_rev": "xyz", "ok": false }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_rev": "xyz",
|
||||
"ok": false
|
||||
}
|
||||
}));
|
||||
provider.createObject("testSpace", "abc", model).then(capture);
|
||||
expect(capture).toHaveBeenCalledWith(false);
|
||||
|
||||
@@ -31,7 +31,7 @@ define([
|
||||
) {
|
||||
|
||||
return {
|
||||
name:"platform/persistence/elastic",
|
||||
name: "platform/persistence/elastic",
|
||||
definition: {
|
||||
"name": "ElasticSearch Persistence",
|
||||
"description": "Adapter to read and write objects using an ElasticSearch instance.",
|
||||
|
||||
@@ -86,12 +86,15 @@ define(
|
||||
ElasticIndicator.prototype.getCssClass = function () {
|
||||
return "c-indicator--clickable icon-suitcase";
|
||||
};
|
||||
|
||||
ElasticIndicator.prototype.getGlyphClass = function () {
|
||||
return this.state.glyphClass;
|
||||
};
|
||||
|
||||
ElasticIndicator.prototype.getText = function () {
|
||||
return this.state.text;
|
||||
};
|
||||
|
||||
ElasticIndicator.prototype.getDescription = function () {
|
||||
return this.state.description;
|
||||
};
|
||||
|
||||
@@ -77,26 +77,30 @@ define(
|
||||
ElasticPersistenceProvider.prototype.get = function (subpath) {
|
||||
return this.request(subpath, "GET");
|
||||
};
|
||||
|
||||
ElasticPersistenceProvider.prototype.put = function (subpath, value, params) {
|
||||
return this.request(subpath, "PUT", value, params);
|
||||
};
|
||||
|
||||
ElasticPersistenceProvider.prototype.del = function (subpath) {
|
||||
return this.request(subpath, "DELETE");
|
||||
};
|
||||
|
||||
|
||||
// Handle an update error
|
||||
ElasticPersistenceProvider.prototype.handleError = function (response, key) {
|
||||
var error = new Error("Persistence error."),
|
||||
$q = this.$q;
|
||||
if ((response || {}).status === CONFLICT) {
|
||||
error.key = "revision";
|
||||
|
||||
// Load the updated model, then reject the promise
|
||||
return this.get(key).then(function (res) {
|
||||
error.model = res[SRC];
|
||||
|
||||
return $q.reject(error);
|
||||
});
|
||||
}
|
||||
|
||||
// Reject the promise
|
||||
return this.$q.reject(error);
|
||||
};
|
||||
@@ -106,6 +110,7 @@ define(
|
||||
if (response && response[SRC]) {
|
||||
this.revs[response[SEQ_NO]] = response[SEQ_NO];
|
||||
this.revs[response[PRIMARY_TERM]] = response[PRIMARY_TERM];
|
||||
|
||||
return response[SRC];
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -119,6 +124,7 @@ define(
|
||||
if (response && !response.error) {
|
||||
this.revs[SEQ_NO] = response[SEQ_NO];
|
||||
this.revs[PRIMARY_TERM] = response[PRIMARY_TERM];
|
||||
|
||||
return response;
|
||||
} else {
|
||||
return this.handleError(response, key);
|
||||
@@ -135,7 +141,6 @@ define(
|
||||
return this.$q.when([]);
|
||||
};
|
||||
|
||||
|
||||
ElasticPersistenceProvider.prototype.createObject = function (space, key, value) {
|
||||
return this.put(key, value).then(this.checkResponse.bind(this));
|
||||
};
|
||||
@@ -149,6 +154,7 @@ define(
|
||||
function checkUpdate(response) {
|
||||
return self.checkResponse(response, key);
|
||||
}
|
||||
|
||||
return this.put(key, value)
|
||||
.then(checkUpdate);
|
||||
};
|
||||
|
||||
@@ -82,7 +82,6 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clean excess whitespace from a search term and return the cleaned
|
||||
* version.
|
||||
|
||||
@@ -104,7 +104,6 @@ define(
|
||||
expect(indicator.getGlyphClass()).toEqual("err");
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/ElasticPersistenceProvider"],
|
||||
function (ElasticPersistenceProvider) {
|
||||
@@ -85,7 +84,11 @@ define(
|
||||
it("allows object creation", function () {
|
||||
var model = { someKey: "some value" };
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_seq_no": 1, "_primary_term": 1 }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_seq_no": 1,
|
||||
"_primary_term": 1
|
||||
}
|
||||
}));
|
||||
provider.createObject("testSpace", "abc", model).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -100,7 +103,12 @@ define(
|
||||
it("allows object models to be read back", function () {
|
||||
var model = { someKey: "some value" };
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_seq_no": 1, "_primary_term": 1, "_source": model }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_seq_no": 1,
|
||||
"_primary_term": 1,
|
||||
"_source": model
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc").then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -117,13 +125,20 @@ define(
|
||||
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_seq_no": 1, "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_seq_no": 1,
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.updateObject("testSpace", "abc", model).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -138,13 +153,19 @@ define(
|
||||
it("allows object deletion", function () {
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.deleteObject("testSpace", "abc", {}).then(capture);
|
||||
expect(mockHttp).toHaveBeenCalledWith({
|
||||
@@ -173,13 +194,20 @@ define(
|
||||
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_seq_no": 1, "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_seq_no": 1,
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "status": 409, "error": "Revision error..." }
|
||||
data: {
|
||||
"status": 409,
|
||||
"error": "Revision error..."
|
||||
}
|
||||
}));
|
||||
provider.updateObject("testSpace", "abc", model).then(
|
||||
capture,
|
||||
@@ -196,13 +224,20 @@ define(
|
||||
|
||||
// First do a read to populate rev tags...
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "_id": "abc", "_seq_no": 1, "_source": {} }
|
||||
data: {
|
||||
"_id": "abc",
|
||||
"_seq_no": 1,
|
||||
"_source": {}
|
||||
}
|
||||
}));
|
||||
provider.readObject("testSpace", "abc");
|
||||
|
||||
// Now perform an update
|
||||
mockHttp.and.returnValue(mockPromise({
|
||||
data: { "status": 410, "error": "Revision error..." }
|
||||
data: {
|
||||
"status": 410,
|
||||
"error": "Revision error..."
|
||||
}
|
||||
}));
|
||||
provider.updateObject("testSpace", "abc", model).then(
|
||||
capture,
|
||||
@@ -213,7 +248,6 @@ define(
|
||||
expect(mockErrorCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@ define([
|
||||
) {
|
||||
|
||||
return {
|
||||
name:"platform/persistence/local",
|
||||
name: "platform/persistence/local",
|
||||
definition: {
|
||||
"extensions": {
|
||||
"components": [
|
||||
|
||||
@@ -43,12 +43,15 @@ define(
|
||||
LocalStorageIndicator.prototype.getCssClass = function () {
|
||||
return "c-indicator--clickable icon-suitcase s-status-caution";
|
||||
};
|
||||
|
||||
LocalStorageIndicator.prototype.getGlyphClass = function () {
|
||||
return 'caution';
|
||||
};
|
||||
|
||||
LocalStorageIndicator.prototype.getText = function () {
|
||||
return "Off-line storage";
|
||||
};
|
||||
|
||||
LocalStorageIndicator.prototype.getDescription = function () {
|
||||
return LOCAL_STORAGE_WARNING;
|
||||
};
|
||||
|
||||
@@ -55,8 +55,8 @@ define(
|
||||
* @private
|
||||
*/
|
||||
LocalStoragePersistenceProvider.prototype.getValue = function (key) {
|
||||
return this.localStorage[key] ?
|
||||
JSON.parse(this.localStorage[key]) : {};
|
||||
return this.localStorage[key]
|
||||
? JSON.parse(this.localStorage[key]) : {};
|
||||
};
|
||||
|
||||
LocalStoragePersistenceProvider.prototype.listSpaces = function () {
|
||||
@@ -71,11 +71,13 @@ define(
|
||||
var spaceObj = this.getValue(space);
|
||||
spaceObj[key] = value;
|
||||
this.setValue(space, spaceObj);
|
||||
|
||||
return this.$q.when(true);
|
||||
};
|
||||
|
||||
LocalStoragePersistenceProvider.prototype.readObject = function (space, key) {
|
||||
var spaceObj = this.getValue(space);
|
||||
|
||||
return this.$q.when(spaceObj[key]);
|
||||
};
|
||||
|
||||
@@ -83,6 +85,7 @@ define(
|
||||
var spaceObj = this.getValue(space);
|
||||
delete spaceObj[key];
|
||||
this.setValue(space, spaceObj);
|
||||
|
||||
return this.$q.when(true);
|
||||
};
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ define(
|
||||
expect(description.length).not.toEqual(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/LocalStoragePersistenceProvider"],
|
||||
function (LocalStoragePersistenceProvider) {
|
||||
|
||||
@@ -33,7 +33,7 @@ define([
|
||||
) {
|
||||
|
||||
return {
|
||||
name:"platform/persistence/queue",
|
||||
name: "platform/persistence/queue",
|
||||
definition: {
|
||||
"extensions": {
|
||||
"components": [
|
||||
|
||||
@@ -34,7 +34,10 @@ define(
|
||||
key: "cancel"
|
||||
}
|
||||
],
|
||||
OK_OPTIONS = [{ name: "OK", key: "ok" }];
|
||||
OK_OPTIONS = [{
|
||||
name: "OK",
|
||||
key: "ok"
|
||||
}];
|
||||
|
||||
/**
|
||||
* Populates a `dialogModel` to pass to `dialogService.getUserChoise`
|
||||
@@ -49,8 +52,8 @@ define(
|
||||
// Place this failure into an appropriate group
|
||||
function categorizeFailure(failure) {
|
||||
// Check if the error is due to object revision
|
||||
var isRevisionError = ((failure || {}).error || {}).key ===
|
||||
PersistenceFailureConstants.REVISION_ERROR_KEY;
|
||||
var isRevisionError = ((failure || {}).error || {}).key
|
||||
=== PersistenceFailureConstants.REVISION_ERROR_KEY;
|
||||
// Push the failure into the appropriate group
|
||||
(isRevisionError ? revisionErrors : otherErrors).push(failure);
|
||||
}
|
||||
@@ -65,8 +68,8 @@ define(
|
||||
revised: revisionErrors,
|
||||
unrecoverable: otherErrors
|
||||
},
|
||||
options: revisionErrors.length > 0 ?
|
||||
OVERWRITE_CANCEL_OPTIONS : OK_OPTIONS
|
||||
options: revisionErrors.length > 0
|
||||
? OVERWRITE_CANCEL_OPTIONS : OK_OPTIONS
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ define(
|
||||
function discard(failure) {
|
||||
var persistence =
|
||||
failure.domainObject.getCapability('persistence');
|
||||
|
||||
return persistence.refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ define(
|
||||
PersistenceFailureHandler
|
||||
) {
|
||||
|
||||
|
||||
/**
|
||||
* The PersistenceQueue is used by the QueuingPersistenceCapability
|
||||
* to aggregate calls for object persistence. These are then issued
|
||||
|
||||
@@ -87,6 +87,7 @@ define(
|
||||
requeue: requeue,
|
||||
error: error
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,9 +98,9 @@ define(
|
||||
|
||||
// Handle any failures from the full operation
|
||||
function handleFailure(value) {
|
||||
return failures.length > 0 ?
|
||||
failureHandler.handle(failures) :
|
||||
value;
|
||||
return failures.length > 0
|
||||
? failureHandler.handle(failures)
|
||||
: value;
|
||||
}
|
||||
|
||||
// Try to persist everything, then handle any failures
|
||||
|
||||
@@ -66,8 +66,8 @@ define(
|
||||
|
||||
// Check if the queue's size has stopped increasing)
|
||||
function quiescent() {
|
||||
return Object.keys(self.persistences).length ===
|
||||
self.lastObservedSize;
|
||||
return Object.keys(self.persistences).length
|
||||
=== self.lastObservedSize;
|
||||
}
|
||||
|
||||
// Persist all queued objects
|
||||
@@ -82,6 +82,7 @@ define(
|
||||
function clearFlushPromise(value) {
|
||||
self.flushPromise = undefined;
|
||||
flushingDefer.resolve(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -109,6 +110,7 @@ define(
|
||||
} else {
|
||||
self.scheduleFlush();
|
||||
}
|
||||
|
||||
// Update lastObservedSize to detect quiescence
|
||||
self.lastObservedSize = Object.keys(self.persistences).length;
|
||||
}
|
||||
@@ -120,14 +122,13 @@ define(
|
||||
} else {
|
||||
// Otherwise, schedule a flush on a timeout (to give
|
||||
// a window for other updates to get aggregated)
|
||||
self.pendingTimeout = self.pendingTimeout ||
|
||||
$timeout(maybeFlush, self.delay, false);
|
||||
self.pendingTimeout = self.pendingTimeout
|
||||
|| $timeout(maybeFlush, self.delay, false);
|
||||
}
|
||||
|
||||
return self.activeDefer.promise;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Queue persistence of a domain object.
|
||||
* @param {DomainObject} domainObject the domain object
|
||||
@@ -139,6 +140,7 @@ define(
|
||||
var id = domainObject.getId();
|
||||
this.persistences[id] = persistence;
|
||||
this.objects[id] = domainObject;
|
||||
|
||||
return this.scheduleFlush();
|
||||
};
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ define(
|
||||
capabilities.persistence = function (domainObject) {
|
||||
// Get/instantiate the original
|
||||
var original =
|
||||
(typeof originalPersistence === 'function') ?
|
||||
originalPersistence(domainObject) :
|
||||
originalPersistence;
|
||||
(typeof originalPersistence === 'function')
|
||||
? originalPersistence(domainObject)
|
||||
: originalPersistence;
|
||||
|
||||
// Provide a decorated version
|
||||
return new QueuingPersistenceCapability(
|
||||
@@ -72,6 +72,7 @@ define(
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceFailureConstants"],
|
||||
function (PersistenceFailureConstants) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceFailureController"],
|
||||
function (PersistenceFailureController) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceFailureDialog", "../src/PersistenceFailureConstants"],
|
||||
function (PersistenceFailureDialog, Constants) {
|
||||
@@ -31,11 +30,26 @@ define(
|
||||
|
||||
beforeEach(function () {
|
||||
testFailures = [
|
||||
{ error: { key: Constants.REVISION_ERROR_KEY }, someKey: "abc" },
|
||||
{ error: { key: "..." }, someKey: "def" },
|
||||
{ error: { key: Constants.REVISION_ERROR_KEY }, someKey: "ghi" },
|
||||
{ error: { key: Constants.REVISION_ERROR_KEY }, someKey: "jkl" },
|
||||
{ error: { key: "..." }, someKey: "mno" }
|
||||
{
|
||||
error: { key: Constants.REVISION_ERROR_KEY },
|
||||
someKey: "abc"
|
||||
},
|
||||
{
|
||||
error: { key: "..." },
|
||||
someKey: "def"
|
||||
},
|
||||
{
|
||||
error: { key: Constants.REVISION_ERROR_KEY },
|
||||
someKey: "ghi"
|
||||
},
|
||||
{
|
||||
error: { key: Constants.REVISION_ERROR_KEY },
|
||||
someKey: "jkl"
|
||||
},
|
||||
{
|
||||
error: { key: "..." },
|
||||
someKey: "mno"
|
||||
}
|
||||
];
|
||||
dialog = new PersistenceFailureDialog(testFailures);
|
||||
});
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceFailureHandler", "../src/PersistenceFailureConstants"],
|
||||
function (PersistenceFailureHandler, Constants) {
|
||||
@@ -48,10 +47,14 @@ define(
|
||||
mockFailure.domainObject.getCapability.and.callFake(function (c) {
|
||||
return (c === 'persistence') && mockPersistence;
|
||||
});
|
||||
mockFailure.domainObject.getModel.and.returnValue({ id: id, modified: index });
|
||||
mockFailure.domainObject.getModel.and.returnValue({
|
||||
id: id,
|
||||
modified: index
|
||||
});
|
||||
mockFailure.persistence = mockPersistence;
|
||||
mockFailure.id = id;
|
||||
mockFailure.error = { key: Constants.REVISION_ERROR_KEY };
|
||||
|
||||
return mockFailure;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceQueueHandler"],
|
||||
function (PersistenceQueueHandler) {
|
||||
@@ -50,6 +49,7 @@ define(
|
||||
['persist', 'refresh']
|
||||
);
|
||||
mockPersistence.persist.and.returnValue(asPromise(true));
|
||||
|
||||
return mockPersistence;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ define(
|
||||
['getId']
|
||||
);
|
||||
mockDomainObject.getId.and.returnValue(id);
|
||||
|
||||
return mockDomainObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceQueueImpl"],
|
||||
function (PersistenceQueueImpl) {
|
||||
@@ -41,6 +40,7 @@ define(
|
||||
['getId']
|
||||
);
|
||||
mockDomainObject.getId.and.returnValue(id);
|
||||
|
||||
return mockDomainObject;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ define(
|
||||
'persistence-' + id,
|
||||
['persist']
|
||||
);
|
||||
|
||||
return mockPersistence;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/PersistenceQueue"],
|
||||
function (PersistenceQueue) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/QueuingPersistenceCapabilityDecorator"],
|
||||
function (QueuingPersistenceCapabilityDecorator) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
define(
|
||||
["../src/QueuingPersistenceCapability"],
|
||||
function (QueuingPersistenceCapability) {
|
||||
|
||||
Reference in New Issue
Block a user