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 :
d2/sdk/controls/dialogs/generic/dialog.action
- instance
- .execute(options) ⇒
Promise
- .execute(options) ⇒
- inner
- ~DynamicDialog ⇐
Marionette.View
- .show(formName) ⇒
this
- .gotoStep(formName) ⇒
void
- .handleError(e) ⇒
void
- .cancel() ⇒
void
- .close() ⇒
void
- .show(formName) ⇒
- ~DialogState ⇐
Marionette.Object
- .gotoForm(formName) ⇒
Promise
- .validateForm(formData) ⇒
Promise
- .cancelForm(formData) ⇒
Promise
- .applyFormStateMethod(options) ⇒
Promise
- .getCurrentFormName() ⇒
string
- .getRelativeFormPosition(srcForm, destForm) ⇒
boolean
- .nextForm() ⇒
Promise
- .previousForm() ⇒
Promise
- .gotoForm(formName) ⇒
- ~StateMethodInput :
Object
- ~ButtonProperties :
Object
- ~ActionExecutionData :
Object
- ~DynamicDialog ⇐
- instance
dialogAction.execute(options) ⇒ Promise
Implement controlling logic behind this action
Kind: instance method of DialogAction
Param | Type | Description |
---|---|---|
options | ActionExecutionData | 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 ⇐
Marionette.View
- .show(formName) ⇒
this
- .gotoStep(formName) ⇒
void
- .handleError(e) ⇒
void
- .cancel() ⇒
void
- .close() ⇒
void
- .show(formName) ⇒
dynamicDialog.show(formName) ⇒ this
Shows a generic dialog post construction.
Kind: instance method of DynamicDialog
Param | Type | Description |
---|---|---|
formName | string | 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
Param | Type | Description |
---|---|---|
formName | string | 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
Param | Type | Description |
---|---|---|
e | Error | 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 ⇐
Marionette.Object
- .gotoForm(formName) ⇒
Promise
- .validateForm(formData) ⇒
Promise
- .cancelForm(formData) ⇒
Promise
- .applyFormStateMethod(options) ⇒
Promise
- .getCurrentFormName() ⇒
string
- .getRelativeFormPosition(srcForm, destForm) ⇒
boolean
- .nextForm() ⇒
Promise
- .previousForm() ⇒
Promise
- .gotoForm(formName) ⇒
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.
Param | Type | Description |
---|---|---|
formName | string | 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.
Param | Type | Description |
---|---|---|
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.
Param | Type | Description |
---|---|---|
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.
Param | Type | Description |
---|---|---|
options | StateMethodInput | 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.
Param | Type | Description |
---|---|---|
srcForm | string | Calculate positioning w.r.t this form. |
destForm | string | 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
Name | Type | Description |
---|---|---|
method | string | 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
Name | Type | Description |
---|---|---|
id | string | Unique identifier of the button that was clicked. Scope of uniqueness is limited to current state/visible screen of the dialog only. |
label | string | Display name of the button clicked. |
DialogAction~ActionExecutionData : Object
Holder for data relevant to this action's execution
Kind: inner typedef of DialogAction
Properties
Name | Type | Description |
---|---|---|
formName | string | Dialog's visible screen's unique name |
button | ButtonProperties | Properties of the the UI button which was clicked. |
formView | Marionette.View | Instance of the view associated with currently visible screen |
dialogState | DialogState | Reference to the state model of the dialog. |
nodes | NodeCollection | Set of objects on which this dialog is operating. |
dialog | DynamicDialog | Reference to the overall dialog UI. |