Skip to main content

commandhelper

CommandHelper : d2/sdk/utils/commandhelper

A few frequetnly used functions that helps reduce code duplication across CommandModel implementations.

Extends: Object

CommandHelper.getJustOneNode(status) ⇒ NodeModel

Get exactly one node from the given status

Kind: static method of CommandHelper
Returns: NodeModel - Returns the first node from status.nodes.

ParamTypeDescription
statusobject

The status parameter from CommandModel's enabled or execute methods.

CommandHelper.getOriginalAction(node, signature, [commandData]) ⇒ ActionModel

Get the most matching action of a node for a given command signature. Usued for disambigutation of an action when it may be present multiple times due to repetitive menu config.

Kind: static method of CommandHelper
Returns: ActionModel - Returns the action that matches most. if commandData is not passed, the first action matching the signature is returned.

ParamTypeDescription
nodeNodeModel

The node whose actions are being looked up

signaturestring

The command singnature being looked up

[commandData]object

commandData associated with the status parameter from CommandModel's enabled or execute methods.

CommandHelper.getOriginalActionLink(node, signature, linkrel, [params], [commandData]) ⇒ String

Get the URL for given linkrel ID from the most matching action of a node. Internally calls getOriginalAction to lookup the matching action.

Kind: static method of CommandHelper
Returns: String - the URL

ParamTypeDescription
nodeNodeModel

The node whose actions are being looked up

signaturestring

The command singnature being looked up

linkrelstring

Linkrel identifier being looked up.

[params]object

If the link relation points to an href-template, then resolve the template using these params.

[commandData]object

commandData associated with the status parameter from CommandModel's enabled or execute methods.

CommandHelper.refreshNode(node, [widgetConfig]) ⇒ jQuery.Promise

Refresh the attributes of a node from server in the context of a widget

Kind: static method of CommandHelper
Returns: jQuery.Promise - it is resolve()-ed only if the refresh is successful, reject()-ed otherwise.

ParamTypeDescription
nodeNodeModel

The node being refreshed

[widgetConfig]object

Widet configuration to set the context of refresh

widgetConfig.widgetNamestring

Name of the widget

widgetConfig.widgetTypestring

Type of the widget

CommandHelper.showErrorPanel(node, errMessage, detailMessage) ⇒ *

Show an error toast associated with a node.

Kind: static method of CommandHelper
Returns: * - the toast instance

ParamTypeDescription
nodeNodeModel

The node to associate the message with

errMessagestring

Brief message to be shown

detailMessagestring

Verbose detail of the errMessage. The detail is shown in an expandable region of the toast.

CommandHelper.blockD2ViewActions(view) ⇒ void

Enable blocker UI.

Kind: static method of CommandHelper

ParamTypeDescription
viewMarionette.View

A view instance infused with the progress blocker API. See BlockingView.

CommandHelper.unblockD2ViewActions(view) ⇒ void

Disable blocker UI.

Kind: static method of CommandHelper

ParamTypeDescription
viewMarionette.View

A view instance infused with the progress blocker API. See BlockingView.