mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 05:08:15 +00:00
Merging in Andrew's work so far on progress and blocking dialogs
open #163 open #170 Squashed commit of the following: commitec7edb58ca
Author: Henry <akhenry@aitutaki.ndc.nasa.gov> Date: Mon Oct 5 10:39:06 2015 -0700 Rename dialogSeverity to messageServity for reuse with notifications commitd20abe01dd
Author: Henry <akhenry@aitutaki.ndc.nasa.gov> Date: Fri Oct 2 16:40:29 2015 -0700 Fixed docs commit227da18498
Author: Henry <akhenry@aitutaki.ndc.nasa.gov> Date: Fri Oct 2 16:27:41 2015 -0700 Added semicolon commit22d424f96e
Author: Henry <akhenry@aitutaki.ndc.nasa.gov> Date: Fri Oct 2 16:26:29 2015 -0700 Fixed code errors commit2c77c3647c
Author: Henry <akhenry@aitutaki.ndc.nasa.gov> Date: Fri Oct 2 16:24:01 2015 -0700 Initial commit of blocking dialog service with test code to demonstrate usage
This commit is contained in:
@ -84,17 +84,7 @@ define(
|
||||
model.confirm = confirm;
|
||||
model.cancel = cancel;
|
||||
|
||||
if (this.dialogVisible) {
|
||||
// Only one dialog should be shown at a time.
|
||||
// The application design should be such that
|
||||
// we never even try to do this.
|
||||
this.$log.warn([
|
||||
"Dialog already showing; ",
|
||||
"unable to show ",
|
||||
model.name
|
||||
].join(""));
|
||||
deferred.reject();
|
||||
} else {
|
||||
if (this.canShowDialog(model)) {
|
||||
// Add the overlay using the OverlayService, which
|
||||
// will handle actual insertion into the DOM
|
||||
this.overlay = this.overlayService.createOverlay(
|
||||
@ -105,6 +95,8 @@ define(
|
||||
// Track that a dialog is already visible, to
|
||||
// avoid spawning multiple dialogs at once.
|
||||
this.dialogVisible = true;
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
@ -157,6 +149,104 @@ define(
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Tests if a dialog can be displayed. A modal dialog may only be
|
||||
* displayed if one is not already visible.
|
||||
* Will log a warning message if it can't display a dialog.
|
||||
* @returns {boolean} true if dialog is currently visible, false
|
||||
* otherwise
|
||||
*/
|
||||
DialogService.prototype.canShowDialog = function(dialogModel){
|
||||
if (this.dialogVisible){
|
||||
// Only one dialog should be shown at a time.
|
||||
// The application design should be such that
|
||||
// we never even try to do this.
|
||||
this.$log.warn([
|
||||
"Dialog already showing; ",
|
||||
"unable to show ",
|
||||
dialogModel.title
|
||||
].join(""));
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* dialogModel: {
|
||||
* severity: string "error" | "info",
|
||||
* title: string,
|
||||
* hint: string,
|
||||
* progress: int,
|
||||
* progressText: string,
|
||||
* unknownProgress: boolean,
|
||||
* actions: [{
|
||||
* label: String,
|
||||
* action: function
|
||||
* }]
|
||||
*/
|
||||
|
||||
/**
|
||||
* A user action that can be performed from a blocking dialog. These
|
||||
* actions will be rendered as buttons within a blocking dialog.
|
||||
*
|
||||
* @typedef DialogAction
|
||||
* @property {string} label a label to be displayed as the button
|
||||
* text for this action
|
||||
* @property {function} action a function to be called when the
|
||||
* button is clicked
|
||||
*/
|
||||
|
||||
/**
|
||||
* A description of the model options that may be passed to the
|
||||
* showBlockingMessage method
|
||||
*
|
||||
* @typedef DialogModel
|
||||
* @property {string} severity the severity level of this message.
|
||||
* These are defined in a bundle constant with key 'dialogSeverity'
|
||||
* @property {string} title the title to use for the dialog
|
||||
* @property {string} hint the 'hint' message to show below the title
|
||||
* @property {number} progress a percentage value (1-100)
|
||||
* indicating the completion of the blocking task
|
||||
* @property {string} progressText the message to show below a
|
||||
* progress bar to indicate progress. For example, this might be
|
||||
* used to indicate time remaining, or items still to process.
|
||||
* @property {boolean} unknownProgress some tasks may be
|
||||
* impossible to provide an estimate for. Providing a true value for
|
||||
* this attribute will indicate to the user that the progress and
|
||||
* duration cannot be estimated.
|
||||
* @property {DialogAction[]} actions a list of actions that will
|
||||
* be added to the dialog as buttons. These buttons are
|
||||
*/
|
||||
|
||||
/**
|
||||
* Displays a blocking (modal) dialog. This dialog can be used for
|
||||
* displaying messages that require the user's
|
||||
* immediate attention. The message may include an indication of
|
||||
* progress, as well as a series of actions that
|
||||
* the user can take if necessary
|
||||
* @param {DialogModel} dialogModel defines options for the dialog
|
||||
* @returns {boolean}
|
||||
*/
|
||||
DialogService.prototype.showBlockingMessage = function(dialogModel) {
|
||||
if (this.canShowDialog(dialogModel)) {
|
||||
// Add the overlay using the OverlayService, which
|
||||
// will handle actual insertion into the DOM
|
||||
this.overlay = this.overlayService.createOverlay(
|
||||
"blocking-message",
|
||||
{dialog: dialogModel}
|
||||
);
|
||||
this.dialogVisible = true;
|
||||
return true;
|
||||
} else {
|
||||
//Could not show a dialog, so return indication of this to
|
||||
//client code.
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
return DialogService;
|
||||
}
|
||||
|
Reference in New Issue
Block a user