commandhelper
CommandHelper : d2/sdk/utils/commandhelper
A few frequetnly used functions that helps reduce code duplication across CommandModel implementations.
Extends: Object
- CommandHelper :
d2/sdk/utils/commandhelper
- .getJustOneNode(status) ⇒
NodeModel
- .getOriginalAction(node, signature, [commandData]) ⇒
ActionModel
- .getOriginalActionLink(node, signature, linkrel, [params], [commandData]) ⇒
String
- .refreshNode(node, [widgetConfig]) ⇒
jQuery.Promise
- .showErrorPanel(node, errMessage, detailMessage) ⇒
*
- .blockD2ViewActions(view) ⇒
void
- .unblockD2ViewActions(view) ⇒
void
- .getJustOneNode(status) ⇒
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
.
Param | Type | Description |
---|---|---|
status | object | The |
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.
Param | Type | Description |
---|---|---|
node | NodeModel | The node whose actions are being looked up |
signature | string | The command singnature being looked up |
[commandData] | object |
|
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
Param | Type | Description |
---|---|---|
node | NodeModel | The node whose actions are being looked up |
signature | string | The command singnature being looked up |
linkrel | string | 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 |
|
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.
Param | Type | Description |
---|---|---|
node | NodeModel | The node being refreshed |
[widgetConfig] | object | Widet configuration to set the context of refresh |
widgetConfig.widgetName | string | Name of the widget |
widgetConfig.widgetType | string | 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
Param | Type | Description |
---|---|---|
node | NodeModel | The node to associate the message with |
errMessage | string | Brief message to be shown |
detailMessage | string | Verbose detail of the |
CommandHelper.blockD2ViewActions(view) ⇒ void
Enable blocker UI.
Kind: static method of CommandHelper
Param | Type | Description |
---|---|---|
view | Marionette.View | A view instance infused with the progress blocker API. See BlockingView. |
CommandHelper.unblockD2ViewActions(view) ⇒ void
Disable blocker UI.
Kind: static method of CommandHelper
Param | Type | Description |
---|---|---|
view | Marionette.View | A view instance infused with the progress blocker API. See BlockingView. |