[Save] Show blocking dialog

Show a blocking dialog while the save action is being performed.

Prevents users from pressing save a second time or performing
further actions while a save is in progress.

Fixes https://github.jpl.nasa.gov/MissionControl/vista/issues/362
This commit is contained in:
Pete Richards
2016-06-24 18:33:24 -07:00
parent 8bdf1e3072
commit 24e870a126
6 changed files with 107 additions and 14 deletions

View File

@@ -28,6 +28,7 @@ define(
var mockDomainObject,
mockEditorCapability,
actionContext,
dialogService,
mockActionCapability,
capabilities = {},
action;
@@ -36,6 +37,9 @@ define(
return {
then: function (callback) {
return mockPromise(callback(value));
},
catch: function (callback) {
return mockPromise(callback(value));
}
};
}
@@ -64,6 +68,10 @@ define(
actionContext = {
domainObject: mockDomainObject
};
dialogService = jasmine.createSpyObj(
"dialogService",
["showBlockingMessage", "dismiss"]
);
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.getCapability.andCallFake(function (capability) {
@@ -73,8 +81,7 @@ define(
mockEditorCapability.save.andReturn(mockPromise(true));
mockEditorCapability.isEditContextRoot.andReturn(true);
action = new SaveAction(actionContext);
action = new SaveAction(dialogService, actionContext);
});
it("only applies to domain object with an editor capability", function () {
@@ -104,6 +111,19 @@ define(
expect(mockActionCapability.perform).toHaveBeenCalledWith("navigate");
});
it("shows a dialog while saving", function () {
mockEditorCapability.save.andReturn(new Promise(function () {}));
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(dialogService.dismiss).not.toHaveBeenCalled();
});
it("hides a dialog when saving is complete", function () {
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(dialogService.dismiss).toHaveBeenCalled();
});
});
}
);