globalmessage
GlobalMessage : d2/sdk/controls/globalmessage/globalmessage
UI component used to show different types of toast messages.
Extends: Marionette.View
- GlobalMessage :
d2/sdk/controls/globalmessage/globalmessage
GlobalMessage.showMessage(type, message, [details], [options]) ⇒ Marionette.View
Show a toast message of particular type
Kind: static method of GlobalMessage
Returns: Marionette.View - The toast message view instance.
Note: success messages automatically disappear after some timeout.
| Param | Type | Description |
|---|---|---|
| type | string | Type of the message. Possible values are |
| message | string | The message to be shown. |
| [details] | string | Details associated with the message. |
| [options] | object | Control options |
| [options.configOption] | GMConfigOptions | Message display configuration. |
Example
define([
'd2/sdk/controls/globalmessage/globalmessage'
], function(GlobalMessage){
'use strict';
//To show information message
GlobalMessage.showMessage('info', 'Hello world!');
//To show success message
GlobalMessage.showMessage('success', 'This is a sample success message');
});
GlobalMessage.showSuccessMessageWithLink(options)
Show a success toast message with a clickable link that can execute a command model implementaion.
Kind: static method of GlobalMessage
| Param | Type | Description |
|---|---|---|
| options | object | Message options |
| options.showLink | Boolean | Whether to show a link |
| options.node | NodeModel | A NodeModel instance whose details is used to format the message. Also used later to execute the linked command when user clicks on the link. |
| options.context | Context | Reference to the application context. |
| options.messageFormat | string | A string template. First placeholder in the string will be replaced with the name attribute value from |
| options.linkLabel | string | Text to be shown as link. |
| options.linkCommandSignature | string | Signature of the command to be executed when user clicks on the displayed link. |
Example
define([
'd2/sdk/controls/globalmessage/globalmessage',
'd2/sdk/models/node.model',
'd2/sdk/utils/contexts/context.utils'
], function(GlobalMessage, NodeModel, contextUtil){
'use strict';
GlobalMessage.showSuccessMessageWithLink({
showLink: true,
node: new NodeModel({id: '090015fa80002d49', name: 'SampleDocument'}),
context: contextUtil.getPerspectiveContext(),
messageFormat: 'Hello "{0}"',
linkLabel: 'click to open overview',
linkCommandSignature: 'Browse'
});
});
GlobalMessage~GMConfigOptions : Object
Kind: inner typedef of GlobalMessage
Properties
| Name | Type | Description |
|---|---|---|
| enablePermanentHeaderMessages | Boolean | Whether to show the toast message without auto-dismiss. Defaults to |