Skip to main content

globalmessage

GlobalMessage : d2/sdk/controls/globalmessage/globalmessage

UI component used to show different types of toast messages.

Extends: Marionette.View

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.

ParamTypeDescription
typestring

Type of the message. Possible values are 'info', 'success', 'warning', 'error'.

messagestring

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

ParamTypeDescription
optionsobject

Message options

options.showLinkBoolean

Whether to show a link

options.nodeNodeModel

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.contextContext

Reference to the application context.

options.messageFormatstring

A string template. First placeholder in the string will be replaced with the name attribute value from options.node. Can also be used to pass a complete message disregarding the fact that it will try to interpret as a template.

options.linkLabelstring

Text to be shown as link.

options.linkCommandSignaturestring

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

NameTypeDescription
enablePermanentHeaderMessagesBoolean

Whether to show the toast message without auto-dismiss. Defaults to false.