Methods
(static) error(msg) → {Promise}
Displays a modal error dialog, similar to alert()
. By default a
single action is shown to close the dialog, but use the actions
options to configure otherwise. The returned promise resolves with the
action selected by the user.
- Parameters:
-
Name Type Description msg
{string|Object} the message text or message configuration options Properties
Name Type Attributes Default Description title
{string} <optional>
"Error" the dialog title text
{string} <optional>
"An error message" the message text html
{string} <optional>
the message in HTML format css
{string} <optional>
the dialog css actions
{Actions} <optional>
the action buttons to show - Returns:
- {Promise} a promise that resolves with the selected action
- Example:
-
try { ... } catch (e) { await RapidContext.UI.Msg.error(e.toString()); }
- Source:
- rapidcontext/ui/msg.js, line 221
(static) info(msg) → {Promise}
Displays a modal info dialog, similar to alert()
. By default a
single action is shown to close the dialog, but use the actions
options to configure otherwise. The returned promise resolves with the
action selected by the user.
- Parameters:
-
Name Type Description msg
{string|Object} the message text or message configuration options Properties
Name Type Attributes Default Description title
{string} <optional>
"Information" the dialog title text
{string} <optional>
"An information message" the message text html
{string} <optional>
the message in HTML format css
{string} <optional>
the dialog css actions
{Actions} <optional>
the action buttons to show - Returns:
- {Promise} a promise that resolves with the selected action
- Example:
-
await RapidContext.UI.Msg.info("System will now reboot. Please wait."); ...
- Source:
- rapidcontext/ui/msg.js, line 290
(static) success(msg) → {Promise}
Displays a modal success dialog, similar to alert()
. By default a
single action is shown to close the dialog, but use the actions
options to configure otherwise. The returned promise resolves with the
action selected by the user.
- Parameters:
-
Name Type Description msg
{string|Object} the message text or message configuration options Properties
Name Type Attributes Default Description title
{string} <optional>
"Success" the dialog title text
{string} <optional>
"A success message" the message text html
{string} <optional>
the message in HTML format css
{string} <optional>
the dialog css actions
{Actions} <optional>
the action buttons to show - Returns:
- {Promise} a promise that resolves with the selected action
- Example:
-
RapidContext.UI.Msg.success("Everything is proceeding as planned.");
- Source:
- rapidcontext/ui/msg.js, line 268
(static) warning(msg) → {Promise}
Displays a modal warning dialog, similar to alert()
. By default a
single action is shown to close the dialog, but use the actions
options to configure otherwise. The returned promise resolves with the
action selected by the user.
- Parameters:
-
Name Type Description msg
{string|Object} the message text or message configuration options Properties
Name Type Attributes Default Description title
{string} <optional>
"Warning" the dialog title text
{string} <optional>
"A warning message" the message text html
{string} <optional>
the message in HTML format css
{string} <optional>
the dialog css actions
{Actions} <optional>
the action buttons to show - Returns:
- {Promise} a promise that resolves with the selected action
- Example:
-
let text = "This will take some time to complete. Are you sure?"; let actions = { cancel: "No, I've changed my mind", warning: "Yes, I understand" } RapidContext.UI.Msg.warning({ text, actions }).then(...);
- Source:
- rapidcontext/ui/msg.js, line 247
(static) warning.remove(type, id) → {Promise}
Displays an object removal warning, similar to confirm()
. This is
a simplified preset that uses the generic warning
function.
- Parameters:
-
Name Type Description type
{string} the object type (e.g. "connection") id
{string} the object name or id - Returns:
- {Promise} a promise that resolves when confirmed, or rejects if cancelled
- Source:
- rapidcontext/ui/msg.js, line 305
Type Definitions
Actions
The message actions (i.e. buttons) to show in the message dialog. Each
action corresponds to a result value returned by the message promise.
The action values cancel
and reload
are handled specially, as they
either reject the promise or reload the page altogether.
Each action button can either use default styles, or be configured with
an options object. By default, the action key is used as both the
default button type (e.g. primary
, danger
, info
or success
), and
the returned action value.
- Type:
- {Object}
- Parameters:
-
Name Type Attributes Description *
{string|Object} the action text or options object *.text
{string} <optional>
the button text to show *.icon
{string} <optional>
the button icon to show *.css
{string} <optional>
the button CSS classes or styles, uses action key by default *.action
{string} <optional>
the action return value, uses action key by default *.href
{string} <optional>
the URL to follow if selected *.target
{string} <optional>
the link target (e.g. _blank
) - Example:
-
{ // Actions can use either default styles or configuration danger: "Yes, I know what I'm doing", custom: { text: "Ok", icon: "fa fa-lg fa-check", css: 'primary' }, // The special 'cancel' action rejects the returned promise cancel: { text: "Cancel", icon: "fa fa-lg fa-times" }, // The 'reload' action triggers a reload of the current page reload: { text: "Reload page" } }
- Source:
- rapidcontext/ui/msg.js, line 21