Skip to main content

dialog.action

DialogAction : d2/sdk/controls/dialogs/generic/dialog.action

DialogAction. Base class for defining handler of footer buttons in a D2SV generic dialog screen. All derived classes should override the asynchronous execute() method to implement appropriate handler logic. In its abstract notion, A dialog action should collect/validate the data state of currently showing screen of D2SV generic dialog and then call 'DialogState' method to trigger transition to a next possible state. A dialog action could be thought of as a 'controller' in an MVC pattern.

Extends: Marionette.Object
See: DialogActions
Example (A sample action implementation(goto.search.js) that triggers non-default state transition in generic dialog)

import DialogAction from 'd2/sdk/controls/dialogs/generic/dialog.action';

class GotoSearch extends DialogAction {
constructor(options={}) {
super(options);
}

async execute(options) {
const {formView, dialogState, dialog} = options;
const formValues = formView.getFlatFormValueMap(formView.getValues());
const {formName, formSchema: {generalConfig}} = await dialogState.applyFormStateMethod({
method: 'SEARCH',
formData: formValues
});

if(generalConfig) {//Go to search step only if the metadata indicates it.
dialog.gotoStep(formName);
}
}
}

Example (To associate this action with binding rule, an extension(my.dialog.actions.js) could be defined as)

import GotoSearch from 'mybundle/dialogs/generic/actions/goto.search';

const rules = [
{equals:{"button.id": "search"}, action: GotoSearch}
];

export default rules;

Example (To finally register the extension, in extensions.json)

{
"d2/sdk/controls/dialogs/generic/dialog.actions": {
"extensions": {
"mybundle": [
"mybundle/extensions/my.dialog.actions"
]
}
}
}

dialogAction.execute(options) ⇒ Promise

Implement controlling logic behind this action

Kind: instance method of DialogAction

ParamTypeDescription
optionsActionExecutionData

holder for various contextual data related to the action's execution

DialogAction~DynamicDialog ⇐ Marionette.View

Dynamic dialog UI interface.

Kind: inner class of DialogAction
Extends: Marionette.View

dynamicDialog.show(formName) ⇒ this

Shows a generic dialog post construction.

Kind: instance method of DynamicDialog

ParamTypeDescription
formNamestring

Show the generic dialog starting from this step

dynamicDialog.gotoStep(formName) ⇒ void

Triggers transition of the dialog to given step.

Kind: instance method of DynamicDialog

ParamTypeDescription
formNamestring

Id of the dialog state to transition into

dynamicDialog.handleError(e) ⇒ void

handles error during the dialog operations. DynamicDialog internally uses delegation pattern to to handoff the error into a fitting UI representation.

Kind: instance method of DynamicDialog

ParamTypeDescription
eError

The error to be handled.

dynamicDialog.cancel() ⇒ void

Execute cancellation flow on this dialog. Upon successful cancellation the dialog is finally closed & disposed off.

Kind: instance method of DynamicDialog

dynamicDialog.close() ⇒ void

Close the dialog and dispose it off.

Kind: instance method of DynamicDialog

DialogAction~DialogState ⇐ Marionette.Object

State model of the current dialog

Kind: inner class of DialogAction
Extends: Marionette.Object

dialogState.gotoForm(formName) ⇒ Promise

Retrieve metadata of the given form name & update state accordingly.

Kind: instance method of DialogState
Returns: Promise - Resolves with form's metadata or rejects with error.

ParamTypeDescription
formNamestring

Name of the form whose metadata is to be retrieved

dialogState.validateForm(formData) ⇒ Promise

Apply validation flow on current dialog state & auto-transition to next possible state.

Kind: instance method of DialogState
Returns: Promise - Resolves with next possible state's metadata or rejects with error.

ParamTypeDescription
formData*

Key value pairs representing data from currently visible screen.

dialogState.cancelForm(formData) ⇒ Promise

Apply cancellation flow on current dialog state & auto-transition to next possible state.

Kind: instance method of DialogState
Returns: Promise - Resolves with next possible state's metadata or rejects with error.

ParamTypeDescription
formData*

Key value pairs representing data from currently visible screen.

dialogState.applyFormStateMethod(options) ⇒ Promise

Apply an arbitrary flow on current dialog state & auto-transition to next possible state.

Kind: instance method of DialogState
Returns: Promise - Resolves with next possible state's metadata or rejects with error.

ParamTypeDescription
optionsStateMethodInput

holder of input parameters.

dialogState.getCurrentFormName() ⇒ string

Get form name of the current state of dialog.

Kind: instance method of DialogState
Returns: string - Returns current form name.

dialogState.getRelativeFormPosition(srcForm, destForm) ⇒ boolean

Given two form names, calculates relative positioning between them and hints whether the second from comes after/before the first one.

Kind: instance method of DialogState
Returns: boolean - Returns true if destForm comes after srcForm, returns false otherwise.

ParamTypeDescription
srcFormstring

Calculate positioning w.r.t this form.

destFormstring

Name of the form whose positioning is being calculated.

dialogState.nextForm() ⇒ Promise

Go to the next form state. Works only if the next form was already retrieved earlier as part of an earlier state transition.

Kind: instance method of DialogState
Returns: Promise - Resolves with next form's metadata, if exists locally otherwise rejects with error.

dialogState.previousForm() ⇒ Promise

Go to the previous form state. Works only if the previous form was already retrieved earlier as part of an earlier state transition.

Kind: instance method of DialogState
Returns: Promise - Resolves with previous form's metadata, if exists locally otherwise rejects with error.

DialogAction~StateMethodInput : Object

Holder of input parameters while applying an arbitrary flow on dialog's current state. Any number of arbitrary properties along with the ones documented below could be passed, they are in turn handed off to matching method implementors. See DialogStateMethod

Kind: inner typedef of DialogAction
Properties

NameTypeDescription
methodstring

Name of the state transition method to apply

[formName]string

Apply state transition method w.r.t this form name. Defaults to form name of the current state.

DialogAction~ButtonProperties : Object

Button properties. Additional attributes apart from the ones documented below might be present.

Kind: inner typedef of DialogAction
Properties

NameTypeDescription
idstring

Unique identifier of the button that was clicked. Scope of uniqueness is limited to current state/visible screen of the dialog only.

labelstring

Display name of the button clicked.

DialogAction~ActionExecutionData : Object

Holder for data relevant to this action's execution

Kind: inner typedef of DialogAction
Properties

NameTypeDescription
formNamestring

Dialog's visible screen's unique name

buttonButtonProperties

Properties of the the UI button which was clicked.

formViewMarionette.View

Instance of the view associated with currently visible screen

dialogStateDialogState

Reference to the state model of the dialog.

nodesNodeCollection

Set of objects on which this dialog is operating.

dialogDynamicDialog

Reference to the overall dialog UI.