[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

@@ -21,8 +21,8 @@
*****************************************************************************/
define(
[],
function () {
['./SaveInProgressDialog'],
function (SaveInProgressDialog) {
/**
* The "Save" action; the action triggered by clicking Save from
@@ -33,9 +33,11 @@ define(
* @memberof platform/commonUI/edit
*/
function SaveAction(
dialogService,
context
) {
this.domainObject = (context || {}).domainObject;
this.dialogService = dialogService;
}
/**
@@ -46,7 +48,8 @@ define(
* @memberof platform/commonUI/edit.SaveAction#
*/
SaveAction.prototype.perform = function () {
var domainObject = this.domainObject;
var domainObject = this.domainObject,
dialog = new SaveInProgressDialog(this.dialogService);
function resolveWith(object) {
return function () {
@@ -72,8 +75,17 @@ define(
return object;
}
//return doSave().then(returnToBrowse);
return doSave().then(returnToBrowse);
function hideBlockingDialog(object) {
dialog.hide();
return object;
}
dialog.show();
return doSave()
.then(hideBlockingDialog)
.then(returnToBrowse)
.catch(hideBlockingDialog);
};
/**

View File

@@ -21,9 +21,14 @@
*****************************************************************************/
define(
['../creation/CreateWizard'],
function (CreateWizard) {
define([
'../creation/CreateWizard',
'./SaveInProgressDialog'
],
function (
CreateWizard,
SaveInProgressDialog
) {
/**
* The "Save" action; the action triggered by clicking Save from
@@ -105,7 +110,8 @@ define(
SaveAsAction.prototype.save = function () {
var self = this,
domainObject = this.domainObject,
copyService = this.copyService;
copyService = this.copyService,
dialog = new SaveInProgressDialog(this.dialogService);
function doWizardSave(parent) {
var wizard = self.createWizard(parent);
@@ -116,6 +122,16 @@ define(
).then(wizard.populateObjectFromInput.bind(wizard));
}
function showBlockingDialog(object) {
dialog.show();
return object;
}
function hideBlockingDialog(object) {
dialog.hide();
return object;
}
function fetchObject(objectId) {
return self.getObjectService().getObjects([objectId]).then(function (objects) {
return objects[objectId];
@@ -140,14 +156,22 @@ define(
.then(resolveWith(clonedObject));
}
function onFailure() {
hideBlockingDialog();
return false;
}
return getParent(domainObject)
.then(doWizardSave)
.then(showBlockingDialog)
.then(getParent)
.then(cloneIntoParent)
.then(commitEditingAfterClone)
.catch(resolveWith(false));
.then(hideBlockingDialog)
.catch(onFailure);
};
/**
* Check if this action is applicable in a given context.
* This will ensure that a domain object is present in the context,

View File

@@ -0,0 +1,20 @@
define([], function () {
function SaveInProgressDialog(dialogService) {
this.dialogService = dialogService;
}
SaveInProgressDialog.prototype.show = function () {
this.dialogService.showBlockingMessage({
title: "Saving...",
hint: "Do not navigate away from this page or close this browser tab while this message is displayed.",
unknownProgress: true,
severity: "info"
});
};
SaveInProgressDialog.prototype.hide = function () {
this.dialogService.dismiss();
};
return SaveInProgressDialog;
});