dialog.state.method
DialogStateMethod : d2/sdk/controls/dialogs/generic/dialog.state.method
DialogStateMethod. Base class for implementing D2SV generic dialog state transition logic. All derived classes should override the
asynchronous execute()
method to actually implement the transition logic.
Also see DialogStateMethods
Extends: Marionette.Object
Example (A sample method implementation module that constructs state metadata by literal definition for a certain given state name)
import StateMethod from 'd2/sdk/controls/dialogs/generic/dialog.state.method';
class LiteralGetMethod extends StateMethod {
async execute(options, result) {
if(options.formName === 'MyFormName') {
result['page-content'] = {
dialog: {
id: 'user_dialog',
label: 'Name Form',
content: {
text: {
order: 1,
control: true,
id: 'full_name',
label: 'Full name',
value: 'John Doe'
}
},
buttons: {
button: [
{id: 'buttonOk', action: 'validDialog()', label: 'OK', order: 1}
]
}
}
};
return false; //So that no other succeeeding state method applies
}
return true;
}
}
export default LiteralGetMethod;
- DialogStateMethod :
d2/sdk/controls/dialogs/generic/dialog.state.method
- instance
- .execute(options, result) ⇒
Promise.<boolean>
- .execute(options, result) ⇒
- inner
- ~MethodMetadata :
Object
- ~OutputFormData :
Object
- ~DialogMetadata :
Object
- ~ButtonWrapper :
Object
- ~ButtonMetadata :
Object
- ~MethodMetadata :
- instance
dialogStateMethod.execute(options, result) ⇒ Promise.<boolean>
Implement state transition logic for D2SV generic dialog
Kind: instance method of DialogStateMethod
Returns: Promise.<boolean>
- Resolve with false
to stop executing any other matching state methods that are supposed to execute after it.
Param | Type | Description |
---|---|---|
options | MethodMetadata | holder for various current state related metadata |
result | OutputFormData | Output parameter, should be filled in with metadata pertaining to next possible state of the dialog. |
DialogStateMethod~MethodMetadata : Object
Metadata related to current state of the dialog
Kind: inner typedef of DialogStateMethod
Properties
Name | Type | Description |
---|---|---|
method | string | Name of the transition method which is getting applied |
formName | string | Form name of the current dialog state. |
nodes | NodeCollection | The object selection set on which this method is being applied. |
actionParams | Object | If the dialog was invoked through a menu, all the parameters associated with the menu are collection in this part of options. |
[formData] | Object | Data collected from currently visible screen of the dialog. |
DialogStateMethod~OutputFormData : Object
Type of form data to be populated by the state method. The overall structure should match response structure returned by D2-REST 'property-page' endpoint.
Kind: inner typedef of DialogStateMethod
Properties
Name | Type | Description |
---|---|---|
"page-content" | Object | wrapper for the form data |
["page-content".dialog] | DialogMetadata | Actual form data |
DialogStateMethod~DialogMetadata : Object
Metadata for a single screen in a dialog.
Kind: inner typedef of DialogStateMethod
Properties
Name | Type | Description |
---|---|---|
id | string | unique identifier of the form |
label | string | Displayable title of the form |
[buttons] | ButtonWrapper | Interaction buttons for the form |
[content] | * | Structure of the form. |
DialogStateMethod~ButtonWrapper : Object
Wrapper for buttons
Kind: inner typedef of DialogStateMethod
Properties
Name | Type | Description |
---|---|---|
button | Array.<ButtonMetadata> | collection of buttons |
DialogStateMethod~ButtonMetadata : Object
Metadata definition of a button
Kind: inner typedef of DialogStateMethod
Properties
Name | Type | Description |
---|---|---|
id | string | Uniqueue identifier of the button |
label | string | Display text for the button |
order | number | Sequential position of the button. |
action | string | The action this button represents |
[isPrimary] | boolean | Whether to visually indicate this button as primary button for the current form. |