From 03edd26e173f3e8b3afb89fc3bd3862bfd752d2e Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 1 Dec 2015 16:45:08 -0800 Subject: [PATCH 1/2] [Edit] Return promise from editable persistence https://github.com/nasa/openmctweb/issues/305 --- .../edit/src/capabilities/EditablePersistenceCapability.js | 2 +- platform/commonUI/edit/src/objects/EditableDomainObjectCache.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/edit/src/capabilities/EditablePersistenceCapability.js b/platform/commonUI/edit/src/capabilities/EditablePersistenceCapability.js index 42b08c72b1..92d29f66ad 100644 --- a/platform/commonUI/edit/src/capabilities/EditablePersistenceCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditablePersistenceCapability.js @@ -50,7 +50,7 @@ define( // Simply trigger refresh of in-view objects; do not // write anything to database. persistence.persist = function () { - cache.markDirty(editableObject); + return cache.markDirty(editableObject); }; // Delegate refresh to the original object; this avoids refreshing diff --git a/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js b/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js index 88a154d79b..01854cfda5 100644 --- a/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js +++ b/platform/commonUI/edit/src/objects/EditableDomainObjectCache.js @@ -111,6 +111,7 @@ define( */ EditableDomainObjectCache.prototype.markDirty = function (domainObject) { this.dirtyObjects[domainObject.getId()] = domainObject; + return this.$q.when(true); }; /** From d5f054e3287e8f15d9da31d8378df797a2990bf1 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 4 Dec 2015 11:20:19 -0800 Subject: [PATCH 2/2] [Edit] Test return type ...from the edit-mode-wrapped persistence capability. --- .../test/capabilities/EditablePersistenceCapabilitySpec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js index f442bf106b..7fa0ac0dd7 100644 --- a/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditablePersistenceCapabilitySpec.js @@ -31,6 +31,7 @@ define( mockEditableObject, mockDomainObject, mockCache, + mockPromise, capability; beforeEach(function () { @@ -50,7 +51,9 @@ define( "cache", [ "markDirty" ] ); + mockPromise = jasmine.createSpyObj("promise", ["then"]); + mockCache.markDirty.andReturn(mockPromise); mockDomainObject.getCapability.andReturn(mockPersistence); capability = new EditablePersistenceCapability( @@ -84,6 +87,10 @@ define( expect(mockPersistence.refresh).toHaveBeenCalled(); }); + it("returns a promise from persist", function () { + expect(capability.persist().then).toEqual(jasmine.any(Function)); + }); + }); } ); \ No newline at end of file